1 / 25

HCS12 Instruction set

HCS12 Instruction set. INSTRUCTION SET. Data Handling Arithmetic Logic Data Test Branch Jump & Subroutine Calls. DATA HANDLING INSTRUCTIONS (DATA MOVEMENT). Y. MEM. 2000. ACCB. 2 5. FUNCTION. MNEMONIC. OPERATION.

halen
Download Presentation

HCS12 Instruction set

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HCS12 Instruction set

  2. INSTRUCTION SET Data Handling Arithmetic Logic Data Test Branch Jump & Subroutine Calls

  3. DATA HANDLING INSTRUCTIONS(DATA MOVEMENT) Y MEM 2000 ACCB 2 5 FUNCTION MNEMONIC OPERATION (M) A LOAD ACMLTR LDAA (M) B LDAB (M) R LDD H • LOAD 16 BIT REG • LOAD <EA> LEAX <ea> X • LEAY <ea> Y • LEAS <ea> SP LDX (M+1) R L LDY LDS Y B EXAMPLE: LEAX B,Y + 2025 X REG

  4. DATA HANDLING INSTRUCTIONS(DATA MOVEMENT) FUNCTION OPERATION MNEMONIC A (M) STAA STORE ACMLTR B (M) STAB STD STORE 16 BIT REG R (M) H STX R (M+1) L STY STS PUSH DATA PSHA (SP) - 1 SP ( REG) M TO STACK PSHB PSHC (SP) PSHD PSHX PSHY (SP) - 2 SP (R : R ) (M ):(M ) (SP) (SP+1) H L PULA (M ) REG (SP) PULL DATA PULB PULC FROM STACK (SP) + 1 SP (M ):(M ) R : R (SP) + 2 SP PULD PULX PULY (SP) (SP)+1 H L MOVE MOV MEM MEM EXAMPLE: MOVW 2,X+ , 2,-Y

  5. STACK OPERATION EXAMPLE: PSHX BEFORE PSHX AFTER MEM MEM B7 B0 B7 B0 INCREASING ADDRESSES INCREASING ADDRESSES $3FFE SP • XH • XL • TOP OF STACK $3FFF SP TOP OF STACK $4000 $4000 SP SP

  6. DATA HANDLING INSTRUCTIONS(TRANSFER AND EXCHANGE) FUNCTION MNEMONIC OPERATION TBA B A • 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 TAB A B TXS R SP TYS TSY SP R TSX D X D Y EXCHANGE DATA XGDX XGDY EXAMPLE1: TFR X ,A EXAMPLE2: EXG Y ,B

  7. DATA HANDLING INSTRUCTIONS(ALTER DATA) FUNCTION MNEMONIC OPERATION DECREMENT DEC (M)-1 (M) DECA A-1 A DECB B-1 B X-1 X DEX Y-1 Y DEY S-1 S DES INCREMENT INC (M)+1 (M) INCA A+1 A INCB B+1 B INX X+1 X INY Y+1 Y INS S+1 S

  8. DATA HANDLING INSTRUCTIONS(ALTER DATA) FUNCTION MNEMONIC OPERATION COMPLEMENT, 2'S NEG 0-(M) (M) (NEGATE) NEGA 0-A A NEGB 0-B B COMPLEMENT, 1'S COM (M) (M) COMA A A COMB B B CLEAR CLR 0 (M) CLRA 0 A CLRB 0 B BIT(S) CLEAR BCLR (M) MASK (M) BIT(S) SET BSET (M) + MASK (M) • Bit Manipulation Example: BSET OFFSET,X, #MASK

  9. DATA HANDLING INSTRUCTIONS FUNCTION MNEMONIC OPERATION MININUM OF TWO UNSIGNED 8-BIT VALUE MINA MIN ((A), (M)) (A) MININUM OF TWO UNSIGNED 8-BIT VALUE MINM MIN ((A), (M)) (M) MAXIMUM OF TWO UNSIGNED 8-BIT VALUE MAXA MAX ((A), (M)) (A) MAXIMUM OF TWO UNSIGNED 8-BIT VALUE MAXM MAX ((A), (M)) (M) • LOOP MINA 1,X+ • BHS LOOP

  10. DATA HANDLING INSTRUCTIONS FUNCTION MNEMONIC OPERATION MININUM OF TWO UNSIGNED 16-BIT VALUE MIN ((D), (M:M+1)) (D) EMIND MIN ((D), (M:M+1)) M:M+1 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 MAX ((D), (M:M+1)) M:M+1 EMAXM

  11. DATA HANDLING INSTRUCTIONS(SHIFT AND ROTATE) FUNCTION MNEMONIC OPERATION ROTATE LEFT ROL M ROLA A ROLB B C b7 b0 M ROTATE RIGHT ROR A RORA B RORB C b7 b0 M SHIFT LEFT, ASL(LSL) 0 A ARITHMETIC ASLA(LSLA) C b7 b0 B (LOGICAL) ASLB(LSLB) 0 A B D ASLD(LSLD) C b15 b0 SHIFT RIGHT, ASR M ARITHMETIC ASRA A ASRB B b7 b0 C SHIFT RIGHT, LSR M 0 LOGICAL LSRA A b0 C b7 LSRB B LSRD 0 A B D b15 b0 C

  12. DATA TEST INSTRUCTIONS FUNCTION MNEMONIC TEST BITA A (M) BIT TEST BITB B (M) COMPARE CBA A-B CMPA A-(M) CMPB B-(M) CPD R -(M+1) L CPX R -(M)-C H CPY COMPARE STACK CPS SP - ( M :M +1) TST (M)-0 TEST, ZERO OR TSTA A-0 MINUS TSTB B-0

  13. CONDITIONAL BRANCH INSTRUCTIONS (1 0F 3) MNEMONIC CONDITION CCR TEST INDICATION (L) BMI MINUS N=1 r=NEGATIVE (L) BPL PLUS N=0 r=POSITIVE *(L) BVS OVERFLOW V=1 r=SIGN ERROR *(L) BVC NO OVERFLOW V=0 r=SIGN OK *(L)BLT LESS A < M [N V]=1  *(L)BGE GREATER OR EQUAL A >= M [N V]=0  * (L)BLE LESS OR EQUAL A <= M [Z+(N V)]=1  *(L) BGT GREATER A > M [Z+(N V)]=0  Indication (L)BEQ refers to the EQUAL Z=1 A=M use of a (L) BNE CMPA M NOT EQUAL Z=0 A <> M instruction immediately (L)BHI HIGHER [C+Z]=0 A > M before the branch (L) BLS LOWER OR SAME [C+Z]=1 A <= M *Use for signed arithmetic only CARRY CLEAR C=0 A >= M (L)BCC (BHS) CARRY SET C=1 A < M (L) BCS (BLO)

  14. CONDITIONAL BRANCH INSTRUCTIONS (2 0F 3) FUNCTION MNEMONIC OPERATION 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 TEST & BRANCH • EXAMPLE: • - • LOOP MOVW $1000, 2,X+ • DBNE D,LOOP • - • -

  15. OCL OP CODE OPERAND MASK BRANCH DISP. 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 ) BRSET (M) MASK SERVICE BRCLR • • ADDESSING MODES ALLOWED ARE: DIR, EXT, IDX, IDX1 & IDX2. • EXAMPLE: • WAIT BRCLR PORTD,Y $80, WAIT

  16. ARITHMETIC INSTRUCTIONS (4 of 4)FRACTIONAL DIVIDE INSTRUCTION FRACTIONAL DIVIDE FDIV RADIX POINT OF THE RESULT IS TO THE LEFT OF THE MSB IF NUMERATOR IS GREATER THAN OR EQUAL TO THE DENOMINATOR, 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

  17. ARITHMETIC INSTRUCTIONS (1 of 4) MNEMONIC FUNCTION OPERATION A + (M) A ADD ADDA B + (M) B ADDB D + (M+1) D ; D + M + C D ADDD H H L L ADD ABA A + B A ACCUMULATORS ABX X + B X ABY Y + B Y ADCA ADD WITH CARRY A + M + C A ADCB B + M + C B DECIMAL ADJUST CONVERTS BINARY ADDITION OF DAA BCD CHARS INTO BCD FORMAT

  18. ARITHMETIC INSTRUCTIONS (2 of 4) FUNCTION MNEMONIC OPERATION A A – (M) SUBTRACT SUBA B – (M) B SUBB D – (M+1) D ; D – (M) – C D SUBD H L L H SUBTRACT SBA A – B A ACCUMULATORS A – (M) – C A SUBTRACT WITH SBCA B – (M) – C B CARRY SBCB MULTIPLY MUL A * B D EXTENDED MULTIPLY EMUL D * Y Y : D EXTENDED MULTIPLY EMULS D * Y Y : D SIGNED

  19. ARITHMETIC INSTRUCTIONS (3 of 4)DIVIDE INSTRUCTIONS OPERATION D REG / X REG RESULT QUOTIENT IS IN X REMAINDER IS IN D INTEGER DIVIDE IDIV/IDIVS RADIX POINT OF THE RESULT IS TO THE RIGHT OF THE LSB • EXTENDED DIVIDE 32-BIT BY 16-BIT ( [UN ]SIGNED) EDIV/EDIVS 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. EXTENDED MULTIPLY AND ACCUMULATE(EMACS) OPERATION: (M : M ) * (M : M ) + M ~ M+3) M ~ M+3 (X) (X+1) (Y) (Y+1) 15 0 15 0 X Y EXAMPLE: EMACS $2500 (* 32-BIT RESULT *)

  21. A + (M) A B + (M) B LOGIC INSTRUCTIONS FUNCTION MNEMONIC OPERATION AND ANDA A (M) A ANDB ANDCC CCR MASK CCR B (M) B EXCLUSIVE OR EORA A (M) A EORB B (M) B INCLUSIVE OR ORAA ORAB ORCC CCR + MASK CCR

  22. JUMP AND BRANCH INSTRUCTIONS FUNCTION MNEMONIC OPERATION/BRANCH TEST NO OPERATION NOP PC ADVANCES TO NEXT INST. JUMP TO ADDRESS JMP (M) PC , (M+1) PC H L JUMP TO SUBROUTINE JSR PC (M ), SP-1 SP L SP PC (M ), SP-1 SP H SP (M) PC , (M+1) PC H L SP+1 SP,(M ) PC SP H RETURN FROM SUBRTN RTS SP+1 SP,(M ) PC SP L PC (M ), SP-1 SP BSR L SP BRANCH TO SUBRTN PC (M ), SP-1 SP H SP (M) PC , (M+1) PC H BRANCH ALWAYS BRA NO TEST BRANCH NEVER BRN NO TEST, PC NEXT INST.

  23. CONDITION CODE REGISTER INSTRUCTIONS MNEMONIC FUNCTION OPERATION 0 C CLEAR CARRY CLC 0 I CLEAR INTERRUPT MASK CLI 0 V CLEAR OVERFLOW CLV 1 C SET CARRY SEC 1 I SET INTERRUPT MASK SEI 1 V SET OVERFLOW SEV A CCR ACCUMULATOR A CCR TAP CCR A CCR ACCUMULATOR A TPA OR CONDITION CODE ORCC CCR + OPERAND AND CONDITION CODE ANDCC CCR ^ OPERAND

  24. 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. 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. • WRITE YOUR PROGRAM HERE • ORG $5000 • SOURCE FCC ‘DATA TO MOVE’ • FCB 0 • ORG $4000 • LOOP • BEQ DONE • BRA LOOP • DONE BRA DONE

  25. CLEAR RAM ROUTINE Write a routine to clear the HCS12 RAM memory, assume RAM begins at $5000 and ends at $5FFF.

More Related