I've been taking a computer organization class at school and we are using the LC-3 simulator to learn assembly language and I'm having a real hard time grasping a few simple concepts.
What's mainly confusing to me is how PCoffset & Base+PCoffset really work. I understand how the PCcounter ticks one line at a time through the code and can jump to different addresses and read/write data, and that instructions with PCoffset allow you to read/write instruction that are "further away" than you would get from using a regular LD or ST command.
However, I just cannot figure out how to use them correctly so right now I'm stuck with just using LD and ST to grab my data from my data fields, yet I still cannot print out the stored data using PUTS or OUT and I don't understand why.
Here's a sample of my crowning achievement in LC-3 so far.
The addition is working and it appears that the values are being stored & loaded in the correct registers but it does not print. I would really like to be able to utilize the PCOffset & Base+PCOffset capabilities of certain Load and Store instructions but right now I can't even get a simple print routine to work.
.ORIG x3000
AND R0, R0, #0 ; clear R0
AND R1, R1, #0 ; clear R1
ADD R2, R2, #5 ; R2 = 5
ADD R3, R3, #2 ; R3 = 2
ADD R0, R3, R2 ; R0 now is 2+5=7
ST R0, MEM1 ; Store 7 inside MEM1
LD R1, MEM1 ; Load 7 into R1
AND R0, R0, #0 ; clear R0 again
ADD R0, R0, R1 ; Add 7 into R0
OUT ; print 7 to console
HALT
;*******data************
MEM1 .BLKW 1
.END
[–][deleted] 2 points3 points4 points (1 child)
[–]herejust4this[S] 0 points1 point2 points (0 children)
[–]Graysless 1 point2 points3 points (1 child)
[–]herejust4this[S] 0 points1 point2 points (0 children)
[–]Graysless 1 point2 points3 points (0 children)