Docsity

Instruction Set, Branch Instructions, Assembler Directives - Microprocessors | EE 4390, Exams of Microprocessors

Partial preview of the text

Download Instruction Set, Branch Instructions, Assembler Directives - Microprocessors | EE 4390 and more Exams Microprocessors in PDF only on Docsity!

Revised: Aug 1, 2003^

EE4390 Microprocessors

Lesson 6,

Instruction Set, Branch Instructions,Assembler Directives

Revised: Aug 1, 2003^

68HC12 Instruction Set• An instruction set is defined as a set ofinstructions that a microprocessorunderstands to execute• 68HC12 has 209 instructions– group instructions into 7 basic categories

Revised: Aug 1, 2003^

Data Transfer and Manipulation

Instructions

-^ Load instruction: copies contents of specifiedlocation to specified accumulator or index register•^ Affect changes to N and Z bit of CCR•^ Reference Appx A Label^ Op-Code^ Operand(s)^ Comment LDAA^

#$^

LDS^

#$DFFF^

Revised: Aug 1, 2003^

Data Transfer and ManipulationInstructions (cont)• Store instruction: copies contents ofspecified accumulator or register tospecified memory location Label Op-Code

Operand(s)

Comment STAB^

$^

STD^

$CFFF^

Revised: Aug 1, 2003^

Rotate and Shift Operations• 21 different rotate and shift operations• Logical Shift– allows each bit to be studied by examining carry bit– shifts in specified direction– discards bit, brings in 0• Arithmetic Shift– used for arithmetic multiplication and division– preserves sign bit• Rotate– rotates bit positions within byte

Revised: Aug 1, 2003^

Rotate and Shift Operations (cont)

Revised: Aug 1, 2003^

Arithmetic Operations• Addition - 8 different instructions Label Op-Code^

Operand(s)^ Comment ABA^

;A+B->B

ADDB^

$^

;B + [$1234]->B

-^ Subtraction - Label^ Op-Code^ Operand(s)^ Comment SBA^

;A-B -> A

SUBB^

$^

;B - [$1234]->B

Revised: Aug 1, 2003^

Arithmetic Operations (cont)• Multiplication - 4 different instructions, integer numbers–^ MUL: multiply two 8-bit numbers in accumulator A and B andstore the result in D–^ EMUL: extended multiply: multiply two 16-bit numbers in indexregister Y and D. The 32-bit result stored in Y and D–^ EMULS: same operation as EMUL with

signed^ numbers Label^ Op-Code^ Operand(s)^ Comment LDAA^

LDAB^

MUL^

;result in D

Revised: Aug 1, 2003^

Logical Operations• AND: performs bit-by-bit AND operation Label Op-Code^ Operand Comment^ ANDA^ $

;A * M -> A

BITA^

;A * M (sets CCR)

-^ OR: bit-by-bit OR operation•^ EXOR: bit-by-bit EXOR operation

Revised: Aug 1, 2003^

Complement Instructions• NEGA: performs two’s complement of A• NEGB: performs two’s complement of B• COMA: performs one’s complement of A• COMB: performs one’s complement of B

Revised: Aug 1, 2003^

Data Test InstructionsCompares and Tests• 10 test instructions, affect the CCR bits, usually followedby Branch instruction• Compare: subtracts value from specified register and setsflags (N, Z, V, and C)– CMPA, CMPB, CBA, CPD, CPS, CPX, CPY– No effect on arguments• Test: subtracts zero from specified register and sets flags(N,Z)– TST, TSTA, TSTB– No effects on arguments

Revised: Aug 1, 2003^

Branch Instructions• Can alter execution order of instructions• Two types:– unconditional: BRA, JMP– conditional: Bxx relative-address• xx specifies which CCR flag is tested• precede branch instruction with test instruction toinsure flags in CCR current• “higher” and “lower” for

unsigned^ numbers

  • “greater” and “less” for

signed^ numbers