Presentation is loading. Please wait.

Presentation is loading. Please wait.

HCS12 Technical Training Module 3 - Instruction Set, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other.

Similar presentations


Presentation on theme: "HCS12 Technical Training Module 3 - Instruction Set, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other."— Presentation transcript:

1 HCS12 Technical Training Module 3 - Instruction Set, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. HCS12 Instruction set

2 HCS12 Technical Training Module 3 - Instruction Set, Slide 2 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. INSTRUCTION SET Data Handling Arithmetic Logic Data Test Branch Jump & Subroutine Calls

3 HCS12 Technical Training Module 3 - Instruction Set, Slide 3 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (DATA MOVEMENT) (M) R (M+1) R FUNCTIONMNEMONICOPERATION LOAD ACMLTRLDAA LDAB (M) B LOAD 16 BIT REG LOAD LEAX X LEAY Y LEAS SP LDD LDX LDY LDS H L (M) A EXAMPLE: LEAX B,Y YBYB X REG 2025 + ACCB 2 5 Y 2000 MEM

4 HCS12 Technical Training Module 3 - Instruction Set, Slide 4 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (DATA MOVEMENT) R (M) R (M+1) FUNCTION MNEMONIC OPERATION STORE ACMLTR STAA STAB A (M) B (M) STORE 16 BIT REG STD STX STY STS H L PUSH DATA TO STACK PSHA PSHB PSHC PSHD PSHX PSHY PULL DATA FROM STACK PULB PULC PULD PULX PULY PULA MOVE MOV MEM MEM EXAMPLE: MOVW 2,X+, 2,-Y ( SP ) (SP) - 1 SP ( REG) M (M ) REG (SP) (SP) - 2 SP (R : R ) (M ):(M ) (SP)(SP+1) HL (SP) + 1 SP (M ):(M ) R : R (SP) + 2 SP LH (SP)(SP)+1

5 HCS12 Technical Training Module 3 - Instruction Set, Slide 5 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. STACK OPERATION MEM TOP OF STACK EXAMPLE: PSHX BEFORE MEM XH XL TOP OF STACK PSHX AFTER INCREASING ADDRESSES INCREASING ADDRESSES SP $3FFE SP $4000 SP $3FFF SP $4000 B7B0

6 HCS12 Technical Training Module 3 - Instruction Set, Slide 6 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (TRANSFER AND EXCHANGE) FUNCTIONMNEMONICOPERATION TRANSFER DATA TRANSFER REG TO REG TFR A, B, CCR, D, X, Y, SP A, B, CCR, D, X, Y, SP EXCHANGE EXG A, B, CCR, D, X, Y, SP A, B, CCR, D, X, Y, SP TBA TAB TXS TYS TSX TSY XGDX XGDY EXCHANGE DATA B A A B R SP SP R D X D Y EXAMPLE1: TFR X,A EXAMPLE2: EXG Y,B

7 HCS12 Technical Training Module 3 - Instruction Set, Slide 7 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (ALTER DATA) FUNCTIONMNEMONICOPERATION DECREMENTDEC DECA DECB DEX DEY DES (M)-1 (M) A-1 A B-1 B X-1 X Y-1 Y S-1 S INCREMENTINC INCA INCB INX INY INS (M)+1 (M) A+1 A B+1 B X+1 X Y+1 Y S+1 S

8 HCS12 Technical Training Module 3 - Instruction Set, Slide 8 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (ALTER DATA) FUNCTIONMNEMONICOPERATION COMPLEMENT, 2'S (NEGATE) NEG NEGA NEGB COM COMA COMB COMPLEMENT, 1'S CLEAR CLR CLRA CLRB 0-(M) (M) 0-A A 0-B B (M) A B 0 (M) 0 A 0 B BIT(S) CLEAR BCLR(M)MASK (M) BIT(S) SETBSET(M) +MASK (M) Bit Manipulation Example: BSET OFFSET,X, #MASK

9 HCS12 Technical Training Module 3 - Instruction Set, Slide 9 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS MININUM OF TWO UNSIGNED 8-BIT VALUE FUNCTIONMNEMONIC OPERATION MIN ((A), (M)) (A) MINA MININUM OF TWO UNSIGNED 8-BIT VALUE MIN ((A), (M)) (M) MINM MAXIMUM OF TWO UNSIGNED 8-BIT VALUE MAX ((A), (M)) (A) MAXA MAXIMUM OF TWO UNSIGNED 8-BIT VALUE MAX ((A), (M)) (M) MAXM LOOP MINA 1,X+ BHS LOOP

10 HCS12 Technical Training Module 3 - Instruction Set, Slide 10 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS MININUM OF TWO UNSIGNED 16-BIT VALUE FUNCTIONMNEMONIC OPERATION MIN ((D), (M:M+1)) (D) EMIND MININUM OF TWO UNSIGNED 16-BIT VALUE EMINM MAXIMUM OF TWO UNSIGNED 16-BIT VALUE MAX ((D), (M:M+1)) (D) EMAXD MAXIMUM OF TWO UNSIGNED 8-BIT VALUE EMAXM MIN ((D), (M:M+1)) M:M+1 MAX ((D), (M:M+1)) M:M+1

11 HCS12 Technical Training Module 3 - Instruction Set, Slide 11 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA HANDLING INSTRUCTIONS (SHIFT AND ROTATE) FUNCTIONMNEMONICOPERATION ROTATE LEFTROL ROLA ROLB M A B ROTATE RIGHTROR RORA RORB M A B SHIFT LEFT, ARITHMETIC (LOGICAL) ASL(LSL) ASLA(LSLA) ASLB(LSLB) ASLD(LSLD) M A B D SHIFT RIGHT, ARITHMETIC ASR ASRA ASRB M A B SHIFT RIGHT, LOGICAL LSR LSRA LSRB LSRD M A B D Cb7b0 Cb7b0 Cb7b0 0 C b15b0 0 AB Cb7b0 0 0 C b7 b0 C b15b0 AB

12 HCS12 Technical Training Module 3 - Instruction Set, Slide 12 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. DATA TEST INSTRUCTIONS R -(M+1) R -(M)-C FUNCTIONMNEMONICTEST BIT TEST BITA BITB A (M) B (M) COMPARECBA CMPA CMPB CPD CPX CPY TEST, ZERO OR MINUS TST TSTA TSTB A-B A-(M) B-(M) (M)-0 A-0 B-0 L H COMPARE STACK CPS SP - ( M :M +1)

13 HCS12 Technical Training Module 3 - Instruction Set, Slide 13 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. CONDITIONAL BRANCH INSTRUCTIONS (1 0F 3) MNEMONICCONDITIONCCR TESTINDICATION (L) BMIMINUSN=1r=NEGATIVE (L) BPLPLUSN=0r=POSITIVE *(L) BVSOVERFLOWV=1r=SIGN ERROR *(L) BVCNO OVERFLOWV=0r=SIGN OK *(L)BLTLESS [N V]=1 *(L)BGEGREATER OR EQUAL [N V]=0 A < M A >= M * (L)BLELESS OR EQUAL [Z+(N V)]=1 A <= M *(L) BGTGREATER [Z+(N V)]=0 A > M (L)BEQ EQUALZ=1A=M (L) BNE NOT EQUALZ=0A <> M (L)BHI HIGHER[C+Z]=0A > M (L) BLSLOWER OR SAME[C+Z]=1A <= M (L)BCC (BHS) CARRY CLEARC=0A >= M (L) BCS (BLO) CARRY SETC=1A < M     Indication refers to the use of a CMPA M instruction immediately before the branch *Use for signed arithmetic only

14 HCS12 Technical Training Module 3 - Instruction Set, Slide 14 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. CONDITIONAL BRANCH INSTRUCTIONS (2 0F 3) DECREMENT & BRANCH DBEQ COUNTER - $01 COUNTER IF COUNTER =0, THEN (PC)+$0003 +REL PC DBNE COUNTER - $01, COUNTER IF COUNTER <>0, THEN (PC)+$0003 +REL PC INCREMENT & BRANCH IBEQ COUNTER + $01 COUNTER IF COUNTER =0, THEN (PC)+$0003 +REL PC IBNE COUNTER + $01 COUNTER IF COUNTER <>0, THEN (PC)+$0003 +REL PC TBEQ IF COUNTER = 0, THEN PC+$0003 + REL PC TBNE IF COUNTER <>0, THEN PC+$0003 + REL PC EXAMPLE: - LOOP MOVW $1000, 2,X+ DBNE D,LOOP - FUNCTIONMNEMONIC OPERATION TEST & BRANCH

15 HCS12 Technical Training Module 3 - Instruction Set, Slide 15 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. BRANCH IF BITS SET OR CLEAR (3 of 3) SINGLE INSTRUCTION TO LOGICALLY "AND" MASK WITH OPERAND AND BRANCH IF BITS ARE EITHER SET OR CLEARED. USEFUL FOR POLLING INTERRUPT STATUS FLAGS, AND FOR MAKING PROGRAM DECISIONS BASED ON BIT(S) VALUES. BRANCH IS TAKEN FROM NEXT INSTRUCTION ADDRESS (OCL+4, 5, OR 6 ) ADDESSING MODES ALLOWED ARE: DIR, EXT, IDX, IDX1 & IDX2. EXAMPLE: WAIT BRCLR PORTD,Y $80, WAIT BRSET BRCLR (M) MASK SERVICE OP CODE OPERAND MASK BRANCH DISP. OCL

16 HCS12 Technical Training Module 3 - Instruction Set, Slide 16 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. IF NUMERATOR IS GREATER THAN OR EQUAL TO THE DENOMINATOR, FRACTIONAL DIVIDEFDIV RADIX POINT OF THE RESULT IS TO THE LEFT OF THE MSB THEN V FLAG IS SET. RESULT EXAMPLES: A RESULT OF 1 IS 1/$10000 WHICH IS.0001 A RESULT OF $C000 IS $C000/$10000 WHICH IS.75 A RESULT OF $FFFF IS $FFFF/$10000 WHICH IS.9999 ARITHMETIC INSTRUCTIONS (4 of 4) FRACTIONAL DIVIDE INSTRUCTION

17 HCS12 Technical Training Module 3 - Instruction Set, Slide 17 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. ARITHMETIC INSTRUCTIONS (1 of 4) A + (M) A B + (M) B D + (M+1) D ; D + M + C D FUNCTION MNEMONIC OPERATION ADDADDA ADDB ADDD L H L H ADD ACCUMULATORS ABA ABX ABY A + B A X + B X Y + B Y ADD WITH CARRY ADCA ADCB A + M + C A B + M + C B DECIMAL ADJUST DAA CONVERTS BINARY ADDITION OF BCD CHARS INTO BCD FORMAT

18 HCS12 Technical Training Module 3 - Instruction Set, Slide 18 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. ARITHMETIC INSTRUCTIONS (2 of 4) A – (M) B – (M) B D – (M+1) D ; D – (M) – C D FUNCTIONMNEMONICOPERATION SUBTRACTSUBA SUBB SUBD LH L H SUBTRACT ACCUMULATORS SBAA – B A SUBTRACT WITH CARRY SBCA SBCB A – (M) – C A B – (M) – C B A EXTENDED MULTIPLY EMUL D * Y Y : D EXTENDED MULTIPLY EMULS D * Y Y : D SIGNED MULTIPLY MUL A * B D

19 HCS12 Technical Training Module 3 - Instruction Set, Slide 19 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. ARITHMETIC INSTRUCTIONS (3 of 4) DIVIDE INSTRUCTIONS OPERATIOND REG / X REG RADIX POINT OF THE RESULT IS TO THE RIGHT OF THE LSB INTEGER DIVIDEIDIV/IDIVS EXTENDED DIVIDE 32-BIT BY 16-BIT ( [UN ]SIGNED) EDIV/EDIVS RESULTQUOTIENT IS IN X REMAINDER IS IN D EDIV EXAMPLE: EDIV[ S ] OPERATION (Y:D)/ (X) Y; REMAINDER D V = 1, IF RESULT > $FFFF FOR UNSIGNED, UNDEFINED IF DIVISOR IS $0000 V = 1, IF RESULT > $7FFF FOR SIGNED, UNDEFINED IF DIVISOR IS $0000 C = 1, IF DIVISOR WAS $0000

20 HCS12 Technical Training Module 3 - Instruction Set, Slide 20 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. EXTENDED MULTIPLY AND ACCUMULATE (EMACS) OPERATION: (M : M ) * (M : M ) + M ~ M+3) M ~ M+3 (X) (X+1) (Y) (Y+1) XY EXAMPLE: EMACS $2500 (* 32-BIT RESULT *) 15 0

21 HCS12 Technical Training Module 3 - Instruction Set, Slide 21 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. LOGIC INSTRUCTIONS A (M) A B (M) B FUNCTIONMNEMONICOPERATION ANDANDA ANDB ANDCC CCR MASK CCR EXCLUSIVE OREORA EORB A (M) A B (M) B INCLUSIVE ORORAA ORAB B + (M)B A + (M)A ORCC CCR + MASK CCR

22 HCS12 Technical Training Module 3 - Instruction Set, Slide 22 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. JUMP AND BRANCH INSTRUCTIONS PC (M ), SP-1 SP (M) PC, (M+1) PC SP H L FUNCTIONMNEMONICOPERATION/BRANCH TEST NO OPERATIONNOPPC ADVANCES TO NEXT INST. JUMP TO ADDRESSJMP(M) PC, (M+1) PC HL JUMP TO SUBROUTINEJSR LH RETURN FROM SUBRTNRTS SP+1 SP,(M ) PC L H BRANCH TO SUBRTN BRANCH ALWAYS BRANCH NEVER BSR BRA BRN NO TEST NO TEST, PC NEXT INST. SP PC (M ), SP-1 SP (M) PC, (M+1) PC SP H L H

23 HCS12 Technical Training Module 3 - Instruction Set, Slide 23 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. CONDITION CODE REGISTER INSTRUCTIONS FUNCTION MNEMONIC OPERATION CLEAR CARRY CLEAR INTERRUPT MASK CLEAR OVERFLOW SET CARRY SET INTERRUPT MASK SET OVERFLOW ACCUMULATOR A CCR CCR ACCUMULATOR A CLC CLI CLV SEC SEI SEV TAP TPA 0 C 0 I 0 V 1 C 1 I 1 V A CCR CCR A OR CONDITION CODE ORCC CCR + OPERAND AND CONDITION CODE ANDCC CCR ^ OPERAND

24 HCS12 Technical Training Module 3 - Instruction Set, Slide 24 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. BLOCK MOVE ROUTINE WRITE A BLOCK MOVE ROUTINE. THE ROUTINE COPIES DATA FROM MEMORY LOCATION $5000 TO MEMORY LOCATION $5100. THE ROUTINE WILL END WHEN A DATA BYTE WITH VALUE OF ZERO IS MOVED. WRITE YOUR PROGRAM HERE ORG $5000 SOURCE FCC ‘DATA TO MOVE’ FCB 0 ORG $4000 LOOP BEQ DONE BRA LOOP DONE BRA DONE SUGGESTED PROGRAM STEPS ORIGINATE DATA AT ADDRESS $4000. FORM TABLE OF DATA TO BE MOVED FORM CONSTANT BYTE OF ‘0’. PROGRAM BEGINS @$4000. 1. INIT SOURCE POINTER T0 $5000. 2. INIT DESTINATION POINTER TO $5100. 3. GET DATA FROM SOURCE ADDRESS. 4. WRITE DATA TO DESTINATION ADDRESS, 5. IF DATA MOVED = 0, GO TO STEP 9, ELSE GO TO 6. 6. INCREMENT SOURCE POINTER. 7. INCREMENT DESTINATION POINTER. 8. GO TO STEP 3. 9. STAY HERE.

25 HCS12 Technical Training Module 3 - Instruction Set, Slide 25 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2001. CLEAR RAM ROUTINE Write a routine to clear the HCS12 RAM memory, assume RAM begins at $5000 and ends at $5FFF.


Download ppt "HCS12 Technical Training Module 3 - Instruction Set, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other."

Similar presentations


Ads by Google