Sun, 30 Oct 2011, 21:59


A student writes:

> Hey Dr. Patt,
>
> Just a quick question. While doing the Problem set 5, number 6. There 
> is an instruction that said
> ST R2 #5 and I was having trouble with this because in the book, the format 
> for the store instruction said ST SR LABEL and we know that immediate value 
> is only used ADDs and ANDs. 
> I was just wondering, if #5 were to be a label (which it cant because it 
> does not follow that label naming rules), is this a typo??
> And is there a rule about PC offset being there? Thank you for your time. 
> <<name withheld to protect the student who is absolutely right>>
  
Hey Ms. ***************,

Thank you for pointing this out.  This problem has been handed down from
generation to generation, starting in the old days when we let the assembly
language syntax put a PC-offset in the ST instruction.  That was a bad
decision (in my view) so we changed it to what you said, in this case:

			ST R2,Addr3

Actually, I do not remember whether we fixed the assembler or not.  In the
beginning the Assembler would correctly assemble ST R2,#5 into a store
instruction that is processed by storing R2 into Memory[PC+1+5].  Whether 
it still allows user code written this way to be assembled, I do not know.  
I would have to experiment with the Simulator.  In fact, how about you 
trying to assemble this program fragment and see what it transforms ST R2,#5 
into.  ...and let me know, of course.

Good luck on the midterm.

Yale Patt