Presentation is loading. Please wait.

Presentation is loading. Please wait.

M68k Arithmetic Instructions ECE 511: Digital System & Microprocessor.

Similar presentations


Presentation on theme: "M68k Arithmetic Instructions ECE 511: Digital System & Microprocessor."— Presentation transcript:

1 M68k Arithmetic Instructions ECE 511: Digital System & Microprocessor

2 What we are going to learn in this session: M68k arithmetic instructions:  Plus  Minus  Multiply  Divide  Compare  Test  Negate

3 Introduction

4 M68k has instructions for simple arithmetic operations. Enhances ability to perform tasks:  Perform calculations + control tasks. Can also do floating-point, but requires math co-processor:  Not covered.

5 Some Basics

6 Addressing Modes

7 We have covered these addressing modes DRDD0  D7 ARDA0  A7 Dn and An ARI(An) ARI+PI(An)+ ARI+PD-(An) ARI+DD(An) ARI+ID(An,Dn/An.s) PC+D D(PC) PC+I D(PC,Dn/An.s) ALA$001001 ASA$FFAA IACCR, SR, PC Effective Address: ID #($/%/@/’’) Immediate data:

8 Addressing Modes Dn: Data Register (D0  D7)  32-bit register (32-bit max). An: Address Register (A0  A7).  32-bit register (24-bit max).  Don’t use A7.

9 Addressing Modes Effective address (24-bit value):  $000000  $FFFFFF  Also includes Address Register Indirect methods.  Anything else: address error. (Immediate Data):  Preceded by #.  Binary: %, Octal: @, Hex: $, Decimal: no sign, Character: ‘ ‘.

10 Addressing Modes Example D1, D2, D3, D4, … $123456 24(A0,D0.W) $123(PC) (A4) A1, A2, A3, A4, … #1000 #$1F34 #@4567 #$00011011 #’ABCD’

11 2’s Complement

12 Used by M68k to represent negative numbers. MSB as sign bit.  If 0, positive number.  If 1, negative number.

13 2’s Complement Example Converting 10 to -10: 10 (decimal) = 00001010 (binary) 1. Start with positive number 2. Invert all the bits 00001010 (invert)11110101 3. Add 1 to inverted result 11110101 + 1 11110110 2’s Complement (-10)

14 2’s Complement Example Converting -5 to 5: -5 (decimal) = 11111011 (binary) 1. The 2’s complement representation: 2. Invert all the bits 11111011 (invert) 00000100 3. Add 1 to inverted result 00000100 + 1 00000101 Positive value (+5)

15 Condition Code Register

16 Condition Code Register (CCR) Used to store status of evaluated conditions. Final 5-bits of SR. CCR = XNZVC  X: rotate, multi-precision BCD operations.  N: result is negative  Z: result is zero  V: overflow has occurred.  C: carry/borrow has occurred.

17 X Example – Rotate 11001100 ROXL.B#1,D0 D0.B = 11001100 10011001 X X = 1C = 1 *X keeps extra bit And moves it to the back… C set as well

18 N Example MOVE.B#0,D0 MOVE.B#100,D1 SUB.BD1,D0 D0 = $00 (0) D1 = $64 (100) D0 = 0 – 100 = $9C (-100) $9C = 11001100 MSB = 1, N = 1

19 Z Example MOVE.L#$FFFFFFFF,D0 SUB.B #$FF,D0 Z = 1 * Only B is tested, since.B was used Initial D0 = FFFFFFFF Final D0 = FFFFFF00

20 V- Overflow Bit Set during arithmetic/divide overflow. For ADD, SUB & CMP:  P + P = N  N + N = P  P – N = N  N – P = P More on divide overflow later. * P = Positive Number (MSB = 0) N = Negative Number (MSB = 1)

21 V Example MOVE.B#$41,D0 MOVE.B#$46,D1 ADD.BD1,D0 01000001 01000110 D0.B = +D1.B = 10000111 New D0.B = V = 1 +65 +70 -121? 2’s complement D0 = 65 + 70

22 V Example MOVE.B#$41,D0 MOVE.B#$BA,D1 SUB.BD1,D0 01000001 10111010 D0.B = -D1.B = 10000111 New D0.B = V = 1 +65 -70 -79? 2’s complement D0 = 65 – (-70)

23 C Example - Carry MOVE.B#$FF,D0 MOVE.B#$FF,D1 ADD.BD1,D0 D0.B = 11111111 D1.B = 11111111 + 11111101 1 Carry occurred, C = 1

24 C Example - Borrow MOVE.B#$12,D0 MOVE.B#$34,D1 SUB.BD1,D0 D0.B = 00001001 D1.B = 01011000 - 11101101 Borrow occurred, C = 1

25 Add Instructions

26 Available Instructions Add Instructions ADD ADDA ADDI ADDQ ADDX

27 ADD Adds two numbers together. D = S + D. Can use BWL. Effects all CCR.

28 ADD DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss ddddddddd--- NZVCX ***** BWL

29 How ADD Effects CCR X = set according to C. N = 1 if MSB is 1. Z = 1 if all active bits are 0. V = 1 if overflow occurred (4 rules). C = 1 if carry occurred.

30 ADD Example D0 = $000011FF D1 = $22223333 ADD.BD0,D1 000011FF 22223333 D1 = + D0 = 22223332 D1 = Only lower byte changed, the rest are the same. CCR X = C N = 0, MSB = 0 Z = 0, result non-zero. V = 0, (N + P = P). C = 1, carry occurred.

31 ADDA (Add Address) Perform add to An:  Destination must be An. Can use WL:  W sign-extended to 32-bits before add. Doesn’t effect CCR.

32 ADDA DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss -d---------- NZVCX ----- WL

33 ADDA Example D0 = $0000AAAA A1 = $00001111 ADDA.W D0,A1 sign-extended. 00001111 FFFFAAAA + A0 = FFFFBBBB X = unchanged N = unchanged Z = unchanged V = unchanged C = unchanged

34 ADDA Example D0 = $0000AAAA A1 = $00001111 ADDA.L D0,A1.L is used, value in D0 not sign-extended. 00001111 0000AAAA + D0 = A0 = 0000BBBB X = unchanged N = unchanged Z = unchanged V = unchanged C = unchanged

35 ADDI (Add Immediate) Adds immediate data to destination. Source must be immediate data. Can use BWL. Effects all CCR (similar to ADD).

36 ADDI DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -----------s d-ddddddd--- NZVCX ***** BWL

37 ADDI Example D0 = $12345678 ADDI.L #$44,D0 12345678 D0= 44 + 123456BC CCR X = Set similar to C N = 0 (MSB = 0) Z = 0 (result nonzero) V = 0 (P + P = P) C = 0 (No carry)

38 ADDQ (Add Quick) Similar to ADDI, but immediate data between 1  8. Can use BWL. Effects all CCR (similar to ADD). Generates smaller MC, faster execution.

39 ADDQ DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -----------s ddddddddd--- NZVCX ***** BWL

40 ADDQ Example D0 = $12345678 ADDQ.B #1,D0 12345678 D0= 01 + 12345679 CCR X = Set similar to C N = 0 (MSB = 0) Z = 0 (result nonzero) V = 0 (P + P = P) C = 0 (No carry)

41 ADDX (Add Extended) Adds X together with results. D = D + S + X. Can use BWL. Limited addressing modes. Effects all CCR.

42 ADDX DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s---s------- d---d------- NZVCX ***** BWL

43 ADDX Example D0 = $12345678 D1 = $ABCDEF12 X = 1 ADDX.B D1,D0 12345678 D0= 1 + 1234568B CCR X = Set similar to C N = 1 (MSB = 1) Z = 0 (result nonzero) V = 1 (P + P = N) C = 0 (No carry) ABCDEF12 D1=

44 Subtraction Instructions

45 Available Instructions Subtract Instructions SUB SUBA SUBI SUBQ SUBX

46 SUB Subtracts source from destination. D = D – S. Can use BWL. Effects all CCR.

47 SUB DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss ddddddddd--- NZVCX ***** BWL

48 How SUB Effects CCR X = set according to C. N = 1 if MSB is 1. Z = 1 if all active bits are 0. V = 1 if overflow occurred. C = 1 if borrow occurred.

49 SUB Example D0 = $00004444 D1 = $22223333 SUB.WD0,D1 00004444 22223333 -D0 = D1 = 2222EEEF (destination) X = C N = 1, MSB = 1 Z = 0, result non-zero. V = 0 (P – P = N). C = 1, borrow occurred.

50 SUBA (Subtract Address) Used to subtract values from address register. Can use WL. Source not sign-extended (unlike ADDA). Doesn’t effect CCR.

51 SUBA DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss -d---------- NZVCX ----- WL

52 SUBA Example A0 = $00002222 D1 = $2222EEEE SUBA.WD1,A0 2222EEEE 00002222 -D1 = A0 = 00003334 Only lower word changed, the rest are the same. (destination) XNZVC unchanged

53 SUBI (Subtract Immediate) Subtracts immediate data from destination. Can use BWL. Effects all CCR similar to SUB.

54 SUBI DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -----------s d-ddddddd--- NZVCX ***** BWL

55 SUBI Example D0 = $00001234 SUBI.W#$3345,D0 00003345 00001234 - D1 = 0000DEEF Only lower word changed, the rest are the same. (destination) X = C N = 1, MSB = 1 Z = 0, result non-zero. V = 0 (P – P = N). C = 1, borrow occurred.

56 SUBQ (Subtract Quick) Similar to SUBI, but immediate data between 1  8. Source must be immediate data. Can use BWL. Effects all CCR (similar to SUB). Generates smaller MC, faster execution.

57 SUBQ DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -----------s d-ddddddd--- NZVCX ***** BWL

58 SUBQ Example D0 = $12345678 SUBQ.B #$07,D0 12345678 D0= 07 - 12345671 CCR X = Set similar to C N = 0 (MSB = 0) Z = 0 (result nonzero) V = 0 (P - P = P) C = 0 (No carry)

59 SUBX (Subtract Extended) Subtracts X with results. D = D - S - X. Can use BWL. Limited addressing modes. Effects all CCR.

60 SUBX DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s---s------- d---d------- NZVCX ***** BWL

61 SUBX Example D0 = $12345678 D1 = $ABCDEFAB X = 1 SUBX.B D1,D0 12345678 D0= 1 - 123456CC CCR X = Set similar to C N = 1 (MSB = 1) Z = 0 (result nonzero) V = 1 (P – N = N) C = 1 (borrow occurred) ABCDEFAB D1=

62 Compare Instruction

63 Available Instructions Compare Instructions CMP CMPA CMPI CMPM

64 CMP (Compare) Compare destination to source:  Similar to SUB (D - S), but doesn’t modify source/destination.  Only modifies CCR.  Destination must be data register. Can use BWL. Effects all CCR except X.

65 CMP vs. SUB CMPSUB Subtracts source from destination. Final result Method of operation Subtracts source from destination. Result not stored, only CCR updated. Result stored in destination. CCR Result Updated according to “subtract” operation. Effects all CCR except X. Updated according to subtract operation. Effects all CCR. BWLValid operand sizeBWL Effect on XX unchanged.X = C

66 CMP DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss d----------- NZVCX ****- BWL

67 How CMP Effects CCR X = unchanged. N = 1 if MSB is 1. Z = 1 if all active bits are 0. V = 1 if overflow occurred. C = 1 if borrow occurred.

68 CMP Example D0 = $00001212 D1 = $22221234 CMP.BD0,D1 00001212 22221234 -D0 = D1 = X = unchanged N = 0 (MSB = 0) Z = 0 (result non-zero) V = 0 (P – P = P). C = 0 (no borrow). 22221222 “D1” = 22221234 Actual D1 =

69 CMP Example 01234567 D3 = CMP.W#$4567,D3 D3.W =$4567 - $4567 $0000 *Original D3 value unchanged. 01234567 Final D3 = X = unchanged N = 0 (MSB = 0) Z = 1 (result zero) V = 0 (P – P = P). C = 0 (no borrow).

70 CMP Example 00000050 D3 = CMP.BD4,D3 D3.B =$50 D4.B =-$60 $F0 00000060 D4 = *Original D3, D4 unchanged. 00000060 Final D4 = 00000050 Final D3 = X = unchanged N = 1 (MSB = 1) Z = 0 (result nonzero) V = 0 (P – P = N). C = 1 (borrow occurred).

71 CMPA (Compare Address) Compare address register to source:  Doesn’t modify source/destination.  Only modifies CCR.  Destination must be address register. Can use WL. Effects all CCR except X.

72 CMPA DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss -d---------- NZVCX ****- WL

73 CMPA Example A0 = $00002222 D1 = $2222EEEE CMPA.WD1,A0 2222EEEE 00002222 - D1 = A0 = 00003334 “A0” = X = unchanged N = 0 (MSB is 0) Z = 0 (result nonzero) V = 0 (P – N = P) C = 1 (borrow occurred) Final A0 = 00002222

74 CMPI (Compare Immediate) Compares destination to immediate data. Source must be immediate data. Can use BWL. Effects all CCR except X (same as CMP).

75 CMPI DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -----------s d-ddddddd--- NZVCX ****- BWL

76 CMPI Example D4 = $0000AABB CMPI.W#$7ABB,D4 00007ABB 0000AABB - D4 = 00003000 “D4” = X = unchanged N = 0, MSB = 0 Z = 0, result non-zero. V = 1 (N – P = P). C = 0, no borrow. 0000AABB Actual D4 =

77 CMPM (Compare Memory) Compare between two memory locations. Can use BWL. Source & destination must be memory. Effects all CCR except X (same as CMP). Only ARI + PI addressing allowed.

78 CMPM DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ---s-------- ---d-------- NZVCX ****- BWL

79 CMPM Example $200366 $200476 $200233 $200111 $2000AA $100333 $100444 $100222 $100111 $100000 A0 = $001002 A1 = $002000 CMPM.W (A0)+,(A1)+ 11AA (A1) = 3322 - (A0) = ED78 Result = X = unchanged N = 1 (MSB = 1) Z = 0 (Result non-zero) V = 0 (N – P = N) C = 0 (No carry) *Memory values unchanged. * A1, A0 increased by 2

80 Multiply Instructions

81 Available Instructions Multiply Instructions MULU MULS

82 MULU (Multiply Unsigned) Multiplies two 16-bit unsigned numbers and produces 32-bit unsigned result. Destination MUST be Dn. Effects all CCR except X.

83 MULU DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s-ssssssssss d----------- NZVCX **00- W x W

84 MULU Example 00C80000 D0 = D0 replaced completely 00020064 X 16-bit MULU D1,D0 00640000 00020000 D0 = D1 = 100 decimal 2 decimal 100 x 2 = 200 = $C8 X = unchanged N = 0 (MSB = 0) Z = 0 (result non-zero) V = 0 C = 0

85 MULS (Multiply Signed) Multiplies two 16-bit signed numbers and produces 32-bit signed result. Destination MUST be Dn. Effects all CCR except X.

86 MULS DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s-ssssssssss d----------- NZVCX **00- W x W

87 MULS Example F63CFFFF D0 = D0 replaced completely 0005FE0C X 16-bit FE0C0000 00050000 D0 = D1 = MULU D1,D0 -500 decimal 5 decimal -500 x 5 = -2500 = $F63C X = unchanged N = 1 (MSB is 1) Z = 0 (result non-zero) V = always cleared C = always cleared

88 Divide Instructions

89 Available Instructions Divide Instructions DIVU DIVS

90 DIVU (Divide Unsigned) Divides 32-bit unsigned number by 16-bit unsigned number. Produces 32-bit result.  Lower 16-bits are quotient (hasil).  Upper 16-bits are remainder (baki). Destination MUST be Dn. Effects all CCR except X.

91 DIVU / Source Divisor Quotient (Hasil) Remainder (Baki) Destination LW WW

92 DIVU DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s-ssssssssss d----------- NZVCX ***0- L ÷ W

93 How DIVU Effects the CCR X = unchanged. N = Set if quotient MSB is 1. Z = Set if quotient is zero. V = Set if division overflow occurs.  V = undefined if divide-by-zero. C = Always cleared.

94 DIVU Example D0 = $00186A1 (100,001 decimal) D1 = $000000C (12 decimal) DIVUD1,D0 100,001 / 12 = 8333, remainder 5 Decimal8,3335 QuotientRemainder Hex$208D$0005 280D New D0 = 0005 X = unchanged N = 0 (Q MSB is 0) Z = 0 (Q nonzero) V = 0 (no overflow) C = always cleared

95 DIVU Example - Overflow D0 = $00186A1 (100,001 decimal) D1 = $0000001 (1 decimal) DIVUD1,D0 100,001 / 1 = 100,001 = $186A1 Decimal100,0010 QuotientRemainder Hex$186A1$0000 8A61 New D0 = 0001 X = unchanged N = 0 (MSB is 0) Z = 0 (result nonzero) V = 1 (divide overflow) C = always cleared Quotient overflowed to remainder.

96 DIVS (Divide Signed) Divides 32-bit signed number by 16-bit signed number. Division method same as DIVU. Destination MUST be Dn. Effects CCR similar to DIVU.

97 DIVS DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s-ssssssssss d----------- NZVCX ***0- L ÷ W

98 DIVS Example D0 = #$00001389 (5,001) D1 = #$0000FFE7 (-25) 5,001 / (-25) = -200, remainder 1DIVSD1,D0 Decimal-2001 QuotientRemainder Hex$FF38$0001 F3F8 New D0= 0001 X = unchanged N = 1 (Q MSB is 1) Z = 0 (Q result nonzero) V = 0 (no overflow) C = always cleared

99 Test Instructions

100 TST (Test Operand) Allows CCR to be updated based on current destination value:  Compares destination to zero.  Similar to CMP.s#0, Destination not effected:  Only changes CCR. Can use BWL. Effects all CCR except X.

101 TST DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n d-ddddddd--- NZVCX **00- BWL

102 TST Example 8F234567 D3 = TST.LD3 D3.L =$F2345678 -$00000000 $F2345678 8F234567 Final D3 = X = unchanged N = 1 (MSB is 1) Z = 0 (data nonzero) V = always cleared C = always cleared *D3 unchanged, CCR updated. (TST.L D3 = CMP.L #0,D3)

103 TAS (Test & Set Operand) Similar to TST, but only tests 1 byte:  Tests byte and sets CCR.  Then set MSB to 1. Can only use B. Effects all CCR except X.

104 TAS DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n d-ddddddd--- NZVCX **00- B

105 TAS Example 8F234567 D3 = TASD3 D3.B =$78 -$00 $78 Only byte tested 8F23456F Final D3 = 01111100 D3.B = After testing, bit 7 is set. F8 X = unchanged N = 0 (MSB is 0) Z = 0 (result non-zero) V = always cleared. C = always cleared. 1 2

106 Other Instructions

107 NEG (Negate) Converts value to opposite sign:  Negative  Positive  Positive  Negative  0 – D = D 2’s Complement representation. Can use BWL. Effects all CCR.

108 NEG DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n d-ddddddd--- NZVCX ***** BWL

109 NEG Example Find the 2’s Complement value of -10 when D0 is loaded with 10. D0 = $0000000A NEG.BD0 0000000A - D0 = X = C N = 1 (MSB is 1) Z = 0 (result is nonzero) V = 0 (P – P = N) C = 1 (borrow occurred). 000000F6 D0 = 00000000 00 = 0 -10

110 What if we negate again? D0 = $000000F6 NEG.BD0 000000F6 - D0 = X = C N = 0 (MSB is 0) Z = 0 (result is nonzero) V = 0 (P – N = P) C = 1 (borrow occurred). 0000000A D0 = 00000000 00 = 0 -(-10) +10

111 NEGX (Negate with Extend) Same as NEG, but subtracts X as well:  0 – D – X = D 2’s Complement representation. Can use BWL. Effects all CCR.

112 NEGX DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n d-ddddddd--- NZVCX ***** BWL

113 NEGX Example D0 = $00000011 X = 1 NEGX.BD0 00000011 - D0 = X = C N = 1 (MSB is 1) Z = 0 (result is nonzero) V = 0 (P – P = N) C = 1 (borrow occurred). 000000EE D0 = 00000000 00 = 0 -17 -18 01 - X =

114 EXT (Sign Extend) Extends sign to remaining upper register bits. Can use WL only. Checks MSB (sign bit) and extends sign:  If.W used, extended to 16-bits.  If.L used, extended to 32-bits. Effects all CCR except X.

115 EXT DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n d----------- NZVCX **00- WL

116 EXT Example 000000AA D0 = EXT.WD0 0000FFAA D0 = $A = 1010 If.W used, check MSB of byte, then extend to word-length. MSB is 1 X = unchanged N = 1 (MSB is 1) Z = 0 (result is nonzero) V = always cleared C = always cleared.

117 EXT Example 000000AC D0 = EXT.LD0 000000AC D0 = $0 = 0000 If.L used, check MSB of word, then extend to long-length. MSB is 0 X = unchanged N = 0 (MSB is 0) Z = 0 (result is nonzero) V = always cleared C = always cleared.

118 Important Note on EXT If.W is used, EXT checks MSB of byte and extends to word value. If.L is used EXT checks MSB of word and extends to long value.

119 Conclusion

120 Summary of ADD Instructions Instruction ADDA ADD ADDI ADDQ ADDX Purpose Add source to address register Add together two numbers Add immediate data to destination Similar to ADDI, but immediate data 1  8 Add together source, destination and X bit. Operation An + S = D D + S = D D + = D D + S + X = D

121 Summary of SUB Instructions Instruction SUBA SUB SUBI SUBQ SUBX Purpose Subtract source from address register Subtracts source from destination Subtract immediate data from destination Similar to SUBI, but immediate data 1  8 Subtract source and X bit from destination. Operation An - S = D D - S = D D - = D D - S - X = D

122 Summary of CMP Instructions Instruction CMPA CMP CMPI CMPM Purpose Compare address register to source. Only updates CCR. Similar to SUB, but doesn’t modify D. Only updates CCR. Compare D to immediate data. Only updates CCR. Compare between 2 memory locations. Only updates CCR. Operation An - S = “D” D - S = “D” D - = “D” M1 – M2 = “D”

123 Summary of MUL & DIV Instructions Instruction MULS MULU DIVU DIVS Purpose Multiplies two signed W data and store in D Multiples two unsigned W data and store in D Divides unsigned L data with W data and store in D Divides signed L data with D data and store in D Operation W x W = L L/W = W Q,W R

124 Summary of Instructions Instruction TAS TST NEG NEGX Purpose Compare D B with zero, update CCR, and set MSB Compare D to zero, and update CCR Negates D (2’s complement) Negates D, then subtract X Operation CMP #0,D MSB = 1 CMP #0,D D = 0 - S D = 0 – S - X EXTSign extends B  W, W  LN/A

125 The End Please read: Antonakos, 69 - 76


Download ppt "M68k Arithmetic Instructions ECE 511: Digital System & Microprocessor."

Similar presentations


Ads by Google