Question

In: Computer Science

Assembly Language Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that...

Assembly Language
Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that would count the number of 1s in a byte. The subroutine will receive the input parameter in A and return the result back in A. Use this subroutine to write a program that would count the number of 1s inside the 64-bit constant signed integer. Define a variable that would hold the total count of 1s.

(Application of Shift/Rotate instructions) (No specific Architecture)

Solutions

Expert Solution

Cloud plz check the code below.

Ldi zl, high(data*2)

ldi zl, low(data*2)

lpm r0, Z

srl ro, 3                  //Divide by 8 routine i.e right shift three times

mov r1,                   #0 (initialize R1 and R6 to zero)

mov r6,                    #0

count_1s: and r6, r6, r0, srl     #1 //Right shift by 1, right most bit is in carry flag)

addcs r1,                                    #1 //Add #1 to r1 if carry flag is set)

cmp r0,                                      #0 //update the status flags if r0 == 0 or not)

beq count_1s

// A.word can writes number 8 to flash memory

plz like us..it improves our community.


Related Solutions

Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that sums up all the numeric characters present in a phrase ("string" that follows the "C" language convention). By For example, if the phrase is "Today is the 28th of month 9", the subroutine must perform the following sum: 2 + 8 + 9 = 19. The subroutine must receive the address of the first character of the corresponding phrase in the "stack", and return...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that sums up all the numeric characters present in a sentence (“string” that follows the “C” language convention). For example, if the phrase is "Today is the 21st of month 5", the subroutine must perform the following sum: 2 + 1 + 5 = 8. The subroutine must receive the address of the first character of the corresponding phrase in the " stack ”, and...
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
1. How to create a newline subroutine in micro assembly language that sends the CR and...
1. How to create a newline subroutine in micro assembly language that sends the CR and LF codes to putchUSART0 (write down the full code in micro assembly language). Terminal programs move the cursor to the beginning of a line with a Carriage Return (CR) code 0x0D and down a line with the Line Feed (LF) code 0x0A.
using Windows 32 bit framework , Write an assembly language program to find the second minimum...
using Windows 32 bit framework , Write an assembly language program to find the second minimum element (formally, second minimum is larger than the minimum but smaller than all the other elements in the array) of an array of size 100. Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and show that your program works for the first five elements. Display the second minimum in a message box using Input output macro
Write a complete assembly program that inputs a small signed integer n, whose value can fit...
Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2 – n + 6.
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
How would you go about creating a subroutine in MARIE assembly language that swaps contents between...
How would you go about creating a subroutine in MARIE assembly language that swaps contents between two memory locations? In this instance the contents for each memory location are names
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT