LEA rises to the surface
A student writes:
Hello Dr. Patt
I apologize in advance for these 306 question so if you would rather me just ask
the TA's and save the emails for important questions then that's fine
1. On page 123, in your 306 book, data movement instructions are defined as
A. "move information between the general purpose registers and
B. move information "between the registers and the input/output
LEA is listed as data movement instruction but on page 129 it explains LEA and
says in this instruction "the operand to be loaded into the destination
register is obtained immediately, that is, without requiring any access of
memory." So going back to the definition of a data movement instruction, LEA
does not access memory so we can rule out "A", but it also does not move data
between registers and I/O. Is it not moving data from the PC to a Register so
isn't that register to register data movement or am I missing something?
Anyhow, this question keeps coming up, and is one of the reasons the 3rd edition
of my freshman book needs to get written.
Yes, data movement is between registers and memory-I/O. Yes, I/O devices as well
as memory, where we identify each I/O device by its individual address from the
memory address space. For example, from the keyboard to a register also constitutes
data movement. Done with a load instruction, where the keyboard has an address.
We call it memory-mapped I/O. One of the characteristics of an ISA that we will
talk about on Monday.
AND, LEA does not source memory to get the information to load into the designated
register, as you correctly point out.
Bottom line: You are absolutely right, LEA is not a data movement instruction in
the sense defined above. Perhaps better identified as an operate. That is, it
produces a value that gets loaded into a register.
In fact, we probably ought to call it something other than a load to differentiate
it from loads that go to memory and I/O. The reason for calling it LEA is that
*everyone* calls it that. But, it continues to confuse some students ...and faculty,
too, for that matter. It is also unbalanced -- there is no SEA instruction. So,
I am still looking for a new name for this instruction.
OK? Again, thanks for asking.