.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.
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