Sun, 1 Feb 2015, 02:02

I just got email from one of my TAs, telling me that a student asks if 
the LEA instruction is an operate instruction or a data movement instruction. 

This is not the first time this has come up, and the fact that I lumped LEA
with the six load and store instructions in my freshman book does not help.
In fact, in the 3rd edition (when it finally gets written), LEA will not be
treated in the same section with the loads and stores.

It is a troublesome case, and I admit that, with a little bit of arbitrariness,
I lump it with the operates.  My reasoning is the following: I prefer to 
identify data movement instructions as those instructions that move data between
the registers and memory or I/O.  LEA does not do that.  It has nothing to do
with memory or I/O.  It simply loads a register with an immediate value, which
happens to be an effective address.  ADD R1,R2,#n also loads a register with an
immediate value if R2 contains #0 before the ADD instruction executes.  In fact,
the operates do not touch memory or I/O either, only dealing with registers.
Thus, my rationale for lumping LEA with the operates.


Also, while I am at it, I should call your attention to the fact that LEA does
not set condition codes.  In the early days of my freshman book, I had LEA
setting condition codes because it seemed simpler to just say all loads and
operates set condition codes, and so students did not have to worry about it.
This bothered me for a long time.  Condition codes provide a mechanism for
getting a comparison without needing a comparison instruction.  Just check
the condition codes.  But LEA just loads an address into a register.  ...and
it is a little silly to label an address as negative, positive, or zero.  So,
I got rid of the silliness. LEA does not affect the condition codes.  Only the
operates and *real* loads affect condition codes, enabling a necessary 
comparison to be made without having to execute a separate instruction to
generate the result of that comparison.

Good luck with 460N/382N.1.

Yale Patt

He knows that the LEA instruction does not move data to/from memory or I/O, 
which the load and store instructions do.
unlike store and load instructions (both of which are
obviously data movement instructions). However, I see LEA as being similar
to MOVE instructions (for ISAs that have them) that move a constant into a
register. For this reason, I want to say the LEA instruction is a data
movement instruction (since MOVE instructions are obviously data movement
instructions, and LEA is like a MOVE of a constant into a general purpose

However, in LC3(b) we also move data between registers using ADD
instructions, as in ADD R2, R1, #0, to accomplish what in other ISAs would
be MOVE R2, R1.

Very good!  I was all set to tell you, "NO!" and then I read your sentence
ADD R2,R1,#0 which I was going write after saying, "no."  

It is a troublesome case, and in fact causes confusion among the freshmen
because it is harder for some reason for them to wrap their brain around.

The freshman book lumps it with the other six data movement instructions.
The 3rd edition won't.  I would rather keep data movement as instructions
that transfer information between the registers and memory-I/O.  This
instruction does not interact with memory or I/O at all.  It only loads an
immediate value into a register.  In some sence it is not operating on data,
but given that it only deals with registers, I arbitrarily consider it one
of the operate instructions.