Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i have a question on this lc3 and i need some help thank thank you In the figure

ID: 647096 • Letter: I

Question

i have a question on this lc3 and i need some help

thank thank you

In the figure, show the contents of memory after the following LC-3 assembly language program is assembled and loaded.

; This program counts the number of ones

in the value in R0.

      .ORIG x3000

      LD R1, MASK

      AND R3, R3, #0          ; counter = 0

LOOP AND R2, R0, R1          ; test bit

      BRz SHIFT

      ADD R3, R3, #1          ; incr counter

; shift mask to the left

SHIFT ADD R1, R1, R1

      BRnp LOOP               ; if zero, all done

      HALT

MASK .FILL #1

      .END

Memory

x0000

...

...

x3000

x3001

x3002

x3003

x3004

x3005

x3006

x3007

x3008

x3009

...

...

Xffff

Memory

x0000

...

...

x3000

x3001

x3002

x3003

x3004

x3005

x3006

x3007

x3008

x3009

...

...

Xffff

Explanation / Answer

Answer

(0000) 3000 0011000000000000 ( 1) .ORIG x3000
(3000) 2207 0010001000000111 ( 3) LD R1 MASK
(3001) 56E0 0101011011100000 ( 5) AND R3 R3 #0
(3002) 5401 0101010000000001 ( 7) LOOP AND R2 R0 R1
(3003) 0401 0000010000000001 ( 9) BRZ SHIFT
(3004) 16E1 0001011011100001 ( 11) ADD R3 R3 #1
(3005) 1241 0001001001000001 ( 17) SHIFT ADD R1 R1 R1
(3006) 0BFB 0000101111111011 ( 19) BRNP LOOP
(3007) F025 1111000000100101 ( 21) TRAP x25
(3008) 0001 0000000000000001 ( 23) MASK .FILL x0001