micro-controller motorola hcs12 addressing modes mechatronics department faculty of engineering ain...

12
MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatron ics Departmen t culty of Engineering in Shams Univeristy

Upload: hester-fisher

Post on 23-Dec-2015

220 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

MICRO-CONTROLLER MOTOROLA HCS12Addressing Modes

Mechatronics

Department

Faculty of EngineeringAin Shams Univeristy

Page 2: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

HCS12 Addressing Modes

HCS12 instruction set can be categorized according to the type of operand used for every instruction.

Immediate Addressing. Direct/Extended Addressing. Indexed Addressing. Inherent Addressing. Relative Addressing.

Page 3: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

HCS12 Programmer’s model Accumulator (Operand Register). Index Registers X&Y (Keeps

addresses for specific instructions using addresses as operands).

Stack Pointer (Keeps track of program stack in the Ram).

Program Counter (Keeps track of the program script).

A B

X

Y

SP

PC

Page 4: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

$ 5000

$ 5001 Op-Code

$ 5002 Operand

$ 5003

$ 5004

$ 5005

Instruction Set Example

ldaa#$64; ldaa#$6464; Operand

Page 5: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Immediate Addressing ldaa#$64;

# = Immediate

A B

X

Y

SP

PC

#$64

Page 6: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Direct Addressing ldaa$64;

No sign= Direct Addressing

A B

X

Y

SP

PC

$ 0063 ……

$ 0064 $FF

$ 0065 ……

$64

$FF

Page 7: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Extended Addressing ldd $1234;

2 bytes operand= Extended Addressing

D

X

Y

SP

PC

$ 1233 ……

$ 1234 $FF

$ 1235 $FF

$1234

$FF$FF

Page 8: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Indexed Addressing ldaa!1,x;

Use index register X, Y, SP or PC

A B

X $0064

Y

SP

PC

$ 0064 ……

$ 0065 $FF

$ 0066 ……

$0064

$FF

+1

$0065

Page 9: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Indexed Pre-decrement Addressing

ldaa!1,-x;

Use sign before index register X, Y, SP or PC

A B

X $0065

Y

SP

PC

$ 0064 $FF

$ 0065 ……

$ 0066 ……

$0064

$FF

-1

$0065$0064

Page 10: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Indexed Post-increment Addressing

ldaa!1,x+;

Use sign after index register X, Y, SP or PC

A B

X $0064

Y

SP

PC

$ 0064 $FF

$ 0065 ……

$ 0066 ……

$0064

$FF

+1

$0065$0064

Page 11: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Indexed Indirect Addressing ldaa[!1,x];

Use [ ] with index register X, Y, SP or PC

A B

X $0064

Y

SP

PC

$ 0064 ……

$ 0065 $00

$ 0066 $67

$ 0067 $FF

$0064

$FF

+1

$0065 $006

7$0067

Page 12: MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy

Eng. Mohamed Mahmoud Hamdy

Eng. Mostafa Ahmed Arafa

Prepared by: