Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11 ECE 447: Groups of Instructions (1) 1. Data handling instructions a. Move instructions (e.g., load, store, exchange) b. Alter data instructions (e.g., clear, increment, decrement) c. Edit instructions (e.g., shift, rotate) 2. Logic instructions (e.g., and, or, xor) 3. Arithmetic instructions (e.g., add, subtract, multiply, divide, negate) ECE 447: Groups of Instructions (2) 4. Data test instructions (e.g. compare, test, bit test) 5. Control instructions (e.g., jump, branch) 6. Condition code instructions (e.g., set carry, clear overflow flag) 7. Stack operations (e.g. push, pull) ECE 447: Groups of Instructions (3) 8. Subroutine-related instructions (e.g. jump to subroutine, return from subroutine) 9. Interrupt-related instructions (e.g. software interrupt, return from interrupt, wait for interrupt) 10. Miscellaneous instructions (e.g. no operation, stop) ECE 447: Move Instructions (1) 1. memory register LDA[A, B] M LD[D, X, Y, S] M N Z V C IMM, DIR, EXT, IND 0 – 2. register memory STA[A, B] M ST[D, X, Y, S] M DIR, EXT, IND 0 – 3. register register TAB, TBA 4. memory memory INH 0 – ECE 447: Move Instructions (2) N Z V C 1. register register XGD[X, Y] INH – – – – ECE 447: Alter Data Instructions (1) NZVC 1. 0 register CLR[A, B] INH 01 00 EXT, IND 01 00 2. 0 memory CLR M ECE 447: Alter Data Instructions (2) NZVC 3. increment X++ INC[A, B] INC M IN[X, Y] INH EXT, IND INH 4. decrement X-DEC[A, B] DEC M DE[X, Y] INH EXT, IND INH – – –– – – –– ECE 447: Logic Instructions (1) Acc & M Acc 1. AND AND[A, B] 2. OR M IMM, DIR, EXT, IND 0– IMM, DIR, EXT, IND 0– IMM, DIR, EXT, IND 0– Acc | M Acc ORA[A, B] 3. XOR NZVC M Acc M Acc EOR[A, B] M ECE 447: Logic Instructions (2) 3. complement XX COM[A, B] COM M 4. bit set NZVC INH EXT, IND 01 DIR, IND 0– DIR, IND 0– M | mask M BSET M, mask 5. bit clear M & mask M BCLR M, mask ECE 447: Arithmetic Instructions (1) 1. addition ADD[A, B, D] ADC[A, B] Acc + M [+ C] Acc M M IMM, DIR, EXT, IND 2. subtraction Acc – M [-C] Acc SUB[A, B, D] SBC[A, B] M M IMM, DIR, EXT, IND NZVC ECE 447: Arithmetic Instructions (2) 3. negation -X INH EXT, IND NEG[A, B] NEG M 4. addition Reg + B Reg ABA AB [X, Y] INH 5. subtraction A – B A SBA INH – – – – ECE 447: Signed vs. Unsigned B = b7 b6 b5 b4 b3 b2 b1 b0 Unsigned number weights 128 64 32 16 8 4 2 1 B = b7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 7 B = b020 + b121 + b222 + b323 + b424 + b525 + b626 + b727 = bi2i i=0 Signed number weights -128 64 32 16 8 4 2 1 B = b7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 6 B = b020 + b121 + b222 + b323 + b424 + b525 + b626 - b727 = - b727 + b2 i i=0 i ECE 447: 2’s Complement Representation X>0 0 X<0 X 0 X+2k = X+1 -8 -7 -6 -5 -4 -3 -2 -1 0 1 k=4 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ECE 447: Unsigned vs. Signed Addition Programmer Machine 128 64 32 16 8 4 weight carry Unsigned mind 2 1 Signed mind 1 1 1 0 0 0 1 0 0 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 0 0 0 X +Y =S c8 x7 y7 x6 y6 x5 y5 x4 y4 FA FA FA FA s7 c7 s6 c6 s5 c5 s4 x3 y3 c4 FA s3 x2 y2 c3 FA s2 x1 y1 c2 FA s1 x0 y0 c1 FA s0 ECE447: Definitions of CCR flags (1) Zero flag - Z Z=1 0 zero result if result = 0 otherwise Negative flag- N negative result N = sign bit of the result r7 - for 8-bit operands r15 - for 16-bit operands ECE447: Definitions of CCR flags (2) Carry flag - C C=1 if 0 out-of-range for unsigned numbers result > MAX_UNSIGNED or result < 0 (a borrow occurred) otherwise where MAX_UNSIGNED = 28-1 for 8-bit operands (registers A, B) 216-1 for 16-bit operands (register D) Overflow flag - V V=1 0 out-of-range for signed numbers if result > MAX_SIGNED or result < MIN_SIGNED otherwise where MAX_SIGNED = 27-1 for 8-bit operands (registers A, B) 215-1 for 16-bit operands (register D) MIN_SIGNED = -27 for 8-bit operands (registers A, B) -215 for 16-bit operands (register D) ECE 447: Overflow of Signed Numbers Indication of overflow Positive + Positive = Negative Negative + Negative = Positive Formulas Overflow2’s complement = xk-1 yk-1 sk-1 + xk-1 yk-1 sk-1 ECE 447: Arithmetic Instructions (3) 1. unsigned multiplication MUL 2. unsigned division IDIV AxB D INH – – – D/IX IX D mod IX D INH – 3. unsigned fractional division D < IX 16) D/ IX IX (scaled by 2 FDIV (scaled by 216) D mod IX D INH 4. decimal adjustment DAA NZVC INH 0 – ? ECE 447: Sign Extension Extending the number of bits of a signed number X Y xk-1 xk-2 … x1 x0 yk’-1 yk’-2 … yk yk-1 yk-2 … y1 y0 two’s complement xk-1 xk-1 xk-1 . . .xk-1 xk-2 … x1 x0 ECE 447: Data Test Instructions NZVC 1. comparison CMP[A, B] CP[D, X, Y] R-M M M IMM, DIR, EXT, IND 2. comparison A – B CBA INH 3. test register TST[A, B] INH 00 ECE 447: Data Test Instructions NZVC 4. test memory TST M 5. Bit test Acc & M BIT[A, B] M EXT, IND 00 IMM, DIR, EXT, IND 0 – ECE 447: Branch Instructions (1) NZVC – – – – after comparison register vs. memory REL unsigned numbers BHI higher BLO lower > < signed numbers BGT greater than > BLT less than < BHS higher or same BLS lower or same BGE greater than or equal BLE less than or equal BEQ equal = BNE not equal ECE 447: Brach Instructions (2) after arithmetic operations (testing for overflow) unsigned numbers BCS BCC carry set carry clear signed numbers BVS overflow set BVC overflow clear after testing register or memory BPL plus BMI minus 0 <0 unconditional BRA always BRN never ECE 447: Bit test and branch instructions 1. Bit test and branch BRCLR M, mask label 2. Bit test and branch BRSET branch if DIR, IND branch if M, mask label (M & mask) == 0 – – – – (M & mask) == 0 DIR, IND – – – –