Friday, 20 December 2013

a. Using the .FILL & .BLKW pseudo-ops, store the value x4000 in one location, and reserve the following location for storing a result. Label ONLY the .FILL location. b. Use the direct mode to load the stored value into R2. c. Double the number in R2, and use the relative mode to store it to the reserved location (i.e. the address following the .FILL). d. Now use the indirect mode to store the same number to the address x4000.

.ORIG    x3000                ; Starting program from address x3000;
LD R2,ONLY                ; Using Direct mode to store the value of ONLY into R2.

ADD R3,R2,R2                ; Adding R2 and R2 then Storing result in register R3.

LEA R4,ONLY                ; Loading the address stored in lable ONLY into register R4.
STR R3,R4,1                ; Using Relative mode store the value of R3 into
                    ; relative memory address (address stored in register R4+1) which was reserved.

STI R3,ONLY                ; Use Indirect mode to store the value of R3 into memory address stored in Label ONLY (i.e.-x4000). 
HALT
ONLY .FILL x4000            ; Fill the value x4000 into Label ONLY.
.BLKW 1                    ; Reserving 1 block for storing the result;
.END                    ; End of the Program.

No comments:

Post a Comment