6 Jump to top if the value in register 1 is less than zero 7

6. Jump to \"top\" if the value in register 1 is less than zero 7. Decrement register 1 by 2 (subtract 2 from the value currently in register 1, with the result left in register 1) 8. Store a zero in each memory location from 50000 to 50100

Solution

1)
INC   r1
CMP   r1,0   ; Compares r1 value with 0
JLE   TOP ; If r1 is less than or equal to 0, then jump to TOP label

2)
SUB   r1, r1,2 ;substracts 2 from r1 and stores in r1 i.e r1=r1-2

3)

L1:   MOV r1,0   ;r1=0
   MOV r2,50000   ;r2=50000
   MOV [r2],r1   ; moving r1 i.e. to the location 50000
   ADD r2,1   ;r2=r2+1
   CMP r2,50100   ;comparing r2,50100
   JLE L1       ;if r2 is less than or equal to 50100 then jump to L1 label

4)
   L1:   MOV r1,1   ;r1=1
   MOV r2,50000   ;r2=50000
   MOV [r2],r1   ; moving r1 i.e. to the location 50000
   ADD r1,1   ;r1=r1+1
   ADD r2,1   ;r2=r2+1
   CMP r2,50100   ;comparing r2,50100
   JLE L1       ;if r2 is less than or equal to 50100 then jump to L1 label

 6. Jump to \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site