Tue, 10 Feb 2009, 23:37

A student writes:

	Dr. Patt:

	When calculating the address for LDB/LDW/STB/STW/etc., 
	what happen in cases like:

	R7 <- xFFFE

	LDW R0,R7,#1

	The LDW instruction means R0 <- MEM[R7 + SEXT(1) >> 1] = MEM[xFFFE + 2] 

	Same question regarding something like

	R7 <- x0000

	LDW R0, R7, #-1

	That would mean R0 <- MEM[x0000 - 2] = MEM[xFFFE]? 

You are fine in both examples.  In the base machine, there is no notion of
privileged memory.  So you compute the address (with wraparound, since
this is a 16 bit machine) and use the resulting address.

By the way, wrap-around is one case.  What about ill-formed addresses.
That is, LDW R1,R2,#0 where R2 contains x4001.  This would cause an exception
since LDW must access an aligned word of memory.  However, exceptions are
for a later lab.  In lab 2, you don't have to worry about it.  All addresses
will be properly formed.

Yale Patt

	<<name withheld to protect the student who addressed 1 of the 2 cases>>