Quick viewing(Text Mode)

Addressing Modes

Addressing Modes

Addressing Modes

 the addressing mode defines how data is accessed  ↑ # of addressing modes → ↑ flexibility → easier to program  ↑ # of addressing modes → ↑ complex

 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  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 # 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  = none operand instruction machine code Basic Addressing Modes

1. Immediate # or Imm e.g. MOVE.B #25,D0

e.g. ADDI.B #1,D2

e.g. MOVE.W #num1,A0 …. num1 DC.W 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 operand instruction machine code …

= Rn e.g. MOVE.B #25,D0 e.g. ADDI.B #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 operand  = address e.g. MOVE.B D0,num1 … num1 DC.B $05 memory

e.g. MOVE.B 25,D0 (optional) Direct (Memory Direct)

 (xxx).W or Abs.W  absolute short  address stored as 16 specified as $00 0000  $0 to $7FFF 32K = 32 x 1024  $8000 to $FFFF $00 7FFF  final address is sign extension of 16 address  (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 more compact machine (system area, I/O interfaces, ROM) code 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:  White Paper read pages 1-8 [pdf, 22p, Intel, November 15, 2004]  Orthogonal instruction set [Wikipedia®]

 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