Essentially, transfer instructions are a subcategory of instructions that are part of the
instruction set of a
microprocessor. They cause the tranfer of
data from a
register or memory location to a
register or memory location. Although transfer instructions differ from
processor to
processor some general rules can be mentioned:
- A transfer instruction transfers multiples of bytes (not fractions) and if a register is involved the size of the transferred value is equal to the register size. In all cases the size of the source location is equal to the size of the destination.
- The source location (or register) is never modified by the transfer operation.
- The source may be a constant value, which in this case is an operand to the instruction. Such an operation is called an immediate transfer.
- The source or the destination memory address (when not a register) may be contained in a register. In this case we have an indexed addressing mode. Registers which may contain addresses to be used in addressing a memory location are called index registers.
According to the above
rules we can present the types of transfers as in the following which will give us the opportunity to start getting used to the syntax tradition which demands that the destinaation operand goes first and the source operand goes second.
=> operation destination,
source
This is at least fully applied in the
assembly language for the
Intel family of
processors.
Basic transfer instructions that exist in all processors
(mem<-mem transfers aren't in all
microprocessor instruction sets, but are common and do exist in the
x86 so don't you dare start with me).
Register (or constant) to register reg<-reg(const)
Register (or constant) to memory mem<-reg(const)
Memory to register reg<-mem
Memory to memory mem<-mem
When an operand is a register then we use its name, and by doing so we know:
i. in advance (
programming time) the identity of the
register
ii. the
size of the register
These are not necessarily known when the operand is memory.
Memory is
referenced using the
address of the first byte of the addressed value (every byte has an address which is a non-negative
integer number starting from 0). This means that knowing the address does not mean that we know the size. Although, since both
operands must be of equal size, in the case of reg<-mem or mem<-reg the size of the
register operand is enough to tell the size of the
operation. Obviously this is not the case when
source operand is a constant (mem<-constant). Normally the size of such a
transfer instruction will be declared in the program.
Memory is not only referenced by specifying an address at programming time, it may also be an indirect expression using the value of another register and this is really important because if unable to
dynamically reference memory, I doubt if there would be a case where computers would be applicable. As it is understood there is a hellovalot more about addressing the memory than simple talking about the above types of transfer instructions.
Addressing modes
Now this is what I’m talking about. Two of these have already been mentioned, here’re the rest of ‘em:
immediate The source operand is a constant
register This is the reg<-reg case
direct The address of a mem operand is in the instruction
indexed The address is contained in an index register
Furthermore there are subdivisions of the last
mode. An
indexed mode may involve two index register and in this case it is a
base relative indexed mode. If in addition it involves a constant number that must be added to the address then it is a "...indexed mode" with
displacement.