Write an LC-3 assembly language program that counts the number of 1s in the value stored in R0 and stores the result in R1. For example, if R0 contains 0001001101110000 (x1370), then after the program executes, the value stored in R1 would be 0000000000000110 (decimal 6) Here are some hints ORIG x3000 AND R5, R5, #0 ADD R5, R5, #1 ;R5 will act as a mask AND R1, R1, #0 ;zero out the result register AND R2, R2, #0 ;R2 will act as a counter LD R3, NegSixt MskLoop AND R4, R0, R5 ;mask off the bit Add code here... if you want more than a 0 Solicit the number to be inspected via the keyboard. 10 points for a single digit (e.g. 5) decimal number, which must be converted to binary. 20 points for a two digit (e.g. 55) decimal number, which must be converted to binary.
Write an LC-3 assembly language
Here are some hints
ORIG x3000
AND R5, R5, #0
ADD R5, R5, #1 ;R5 will act as a mask
AND R1, R1, #0 ;zero out the result register
AND R2, R2, #0 ;R2 will act as a counter
LD R3, NegSixt
MskLoop AND R4, R0, R5 ;mask off the bit
Add code here... if you want more than a 0
Solicit the number to be inspected via the keyboard.
10 points for a single digit (e.g. 5) decimal number, which must be converted to binary.
20 points for a two digit (e.g. 55) decimal number, which must be converted to binary.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps