Addressing Modes
Download
Report
Transcript Addressing Modes
Addressing Modes
the addressing mode defines how data is accessed
↑ # of addressing modes → ↑ flexibility → easier to program
↑ # of addressing modes → ↑ complex machine code
each operand has an addressing mode
e.g.
MOVE.B
Num1,D0
ideally, every addressing mode would work with every
instruction
≡ orthogonal instruction set
effective address ≡ <ea> ≡ EA
effective address indicates how the address of the operand is
calculated
all addressing modes with the exception of immediate have an
effective address
Basic Addressing Modes
1.
Immediate
#<data> or Imm
# (pound/hashtag) sign indicates that the
item that follows is immediate data
eg. #%1011, #$AF, #'The', #52*7, #NUM
operand is a constant or a constant expression
(evaluated at time of assembly)
operand is in the instruction machine code
<ea> = none
operand
instruction machine code
Basic Addressing Modes
1.
Immediate
e.g.
MOVE.B
#25,D0
e.g.
ADDI.B
#1,D2
e.g.
MOVE.W
….
DC.W
#num1,A0
num1
#<data> or Imm
255
“quick” instructions, e.g. ADDQ, SUBQ, MOVEQ, use
immediate data but with restricted range
Basic Addressing Modes
2.
Register Direct (Register)
Dn or An
operand is in a general register
registers
Rn
instruction machine code
<ea> = Rn
e.g.
MOVE.B
e.g.
ADDI.B
operand
…
#25,D0
#1,D2
Basic Addressing Modes
3.
Direct (Memory Direct)
(xxx).W or (xxx).L
operand is a variable ± constant expression
(evaluated at time of assembly)
the address of the operand is part of the
instruction
address
instruction mcode
<ea> = address
e.g.
MOVE.B
D0,num1
…
num1
DC.B $05
e.g.
MOVE.B
25,D0
operand
memory
(optional)
Direct (Memory Direct)
(xxx).W or Abs.W
absolute short
address stored as 16
bits specified as
final address is sign
extension of 16 bit
address
32K
= 32 x 1024
$00 7FFF
(xxx).L or Abs.L
absolute long
$FF 8000
address stored as 32
32K
bits
$FF FFFF
difference in machine code
as absolute short generates memory extremes have special uses
(system area, I/O interfaces, ROM)
more compact machine
code
$0 to $7FFF
$8000 to $FFFF
$00 0000
e.g.
shift a 16 bit variable left one bit; in place
eg. Divide an 8-bit variable into two 4-bit nibbles. Store the
top nibble of the original into the low nibble of the top byte of
the result and store the low nibble of the original into the low
nibble of the low byte of the result. “unpack” the number
For example, if byte =$5F, the resulting word would be $050F.
Reading/Expectations
Reading:
Endianness White Paper read pages 1-8 [pdf, 22p, Intel,
Orthogonal instruction set [Wikipedia®]
November 15, 2004]
Expectations:
you are able to write simple programs using the three
addressing modes
you can determine the addressing modes for any
instruction (currently limited to the 3 addressing modes
that you know)
you can explain the concept of effective address and
provide it for these and all future addressing modes