Addressing modes and instruction formats

By: Nicholas Duchon (Apr 15, 2014)


Addressing Modes

In this table, we think of the PC as pointing to an instruction,
and the address field of the instruction located in the memory location PC+1.
Adjustments need to be made for other instruction formats.
Symbol Mode Name Effective Address
DR Direct [ PC + 1 ]
IM Immediate PC + 1
ID Indirect [ [ PC + 1 ] ]
RV Relative PC + 2 + [ PC + 1 ]
IX Indexed XR + [ PC + 1 ]
RG Register R1
RI Register Indirect [ R1 ]
AI AutoIncrement [ XR ], then XR <-- XR + 1
AD AutoDecrement XR <-- XR - 1, then [ XR ]


Addressing modes Example

Note # 3
by Nick Duchon

Working with the example on pg 265 of Mano:

Registers:

PC = 200
RI = 400
XR = 100
AC

Memory map:

Address Data Notes
200 Load AC + Mode Instruction
201 Address = 500 Address field of instruction
202 Next Instruction  
Space   Space
399 450 Auto decrement
400 700 Used in RI + AI
Space    
500 800 Used in DR + IM
Space    
600 900 Used in IX(XR)
Space    
702 325 Used in RV
Space    
800 300 Used in ID

Notes:

Mode Name Effective Address AC EA calculation
DR Direct 500 800 [ PC + 1 ]
IM Immediate 201 500 PC + 1
ID Indirect 800 300 [ [ PC + 1 ] ]
RV Relative 702 325 PC + 2 + [ PC + 1 ]
IX Indexed 600 900 XR + [ PC + 1 ]
RG Register - 400 ( none )
RI Register Indexed 400 700 [ RI ]
AI AutoIncrement 400 700 EA ← RI, RI ← RI + 1
AD AutoDecrement 399 450 RI ← RI - 1, EA ← RI


Instruction formats - 0, 1, 2, 3 address instruction formats

By example:

Statement RPN
3 address 2 address 1 address 0 address
x = a - b a b -
sub x,a,b move x,a
sub  x,b

load  a
sub   b
store x
push a
push b
sub
pop  x
x = (a - b) / c a b - c /
sub x,a,b
div x,x,c
move x,a
sub  x,b
div  x,c
load  a
sub   b
div   c
store x
push a
push b
sub
push c
div
pop  x
x = (a-b*c)/d a b c * - d /
mult x,b,c
sub  x,a,x
div  x,x,d
move y,b
mult y,c
move x,a
sub  x,y
div  x,d
load  b
mult  c
store y
load  a
sub   y
div   d
store x
push a
push b
push c
mult
sub
push d
div
pop  x
x = (a*b-c*d)/(e-f) a b * c d * - e f - /
mult x,a,b
mult y,c,d
sub  x,x,y
sub  y,e,f
div  x,x,y
move y,c
mult y,d
move x,a
mult x,b
sub  x,y
move y,e
sub  y,f
div  x,y
load  e
sub   f
store y
load  c
mult  d
store x
load  a
mult  b
sub   x
div   y
store x
push a
push b
mult
push c
push d
mult
sub
push e
push f
sub
div
pop  x