Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code:

Size: px
Start display at page:

Download "Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code:"

Transcription

1 Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code: ADDR DATA C6 05 FE 00 E B7 E EE 3F To determine the instructions, use Tables A.2 through A.7 of the S12CPUV2 Reference Manual. If the first byte of the instruction is anything other than $18, use Sheet 1 of Table A.2 (Page 395). From this table, determine the number of bytes of the instruction and the addressing mode. For example, $C6 is a two-byte instruction, the mnemonic is LDAB, and it uses the IMM addressing mode. Thus, the two bytes C6 05 is the op code for the instruction LDAB #$05. The op code FE is LDX using the EXT addressing mode, and has 3 bytes total, with the last two bytes being the extended address. Thus, FE 00 is the instruction LDX $00. Indexed addressing mode is fairly complicated to disassemble. You need to use Table A.3 to determine the operand. For example, the op code $E6 indicates LDAB indexed, and may use two to four bytes (one to three bytes in addition to the op code). The postbyte 01 indicates that the operand is 0,1, which is 5-bit constant offest, which takes only one additional byte. All 5-bit constant offset, pre and post increment and decrement, and register offset instructions use one additional byte. All 9-bit constant offset instructions use two additional bytes, with the second byte holding 8 bits of the 9 bit offset. (The 9th bit is a direction bit, which is held in the first postbyte.) All 16-bit constant offset instructions use three postbytes, withe the 2nd and 3rd holding the 16-bit unsigned offset. If the first byte is $18, use Sheet 2 of Table A.2 (Page 396). For example, is a two byte instruction, the mnemonic is ABA, and it uses the INH addressing mode, so there is no operand. Thus, the two bytes is the op code for the instruction ABA. Transfer (TFR) and exchange (EXG) instructions all have the op code $B7 with one post-byte. Use Table A.5 to determine whether it is TFR or an EXG, and to determine which registers are being used. If the most significant bit of the postbyte is 0, the instruction is a transfer instruction. B7 E5 is the code for the instruction EXG Y,X. Loop instructions (Decrement and Branch, Increment and Branch, and Test and Branch) all have the op code $04. To determine which instruction the op code $04 implies, and whether the branch is positive (forward) or negative (backward), use Table A.6. For example, in the sequence EE, the 04 indicates a loop instruction. The 35 indicates it is a X instruction (decrement register X and branch if result is not equal to zero), and the direction is backward (negative). The EE indicates a branch of -18 bytes (take the 2 s complement of EE. 1

2 Use up all the bytes for one instruction, then go on to the next instruction. ADDR DATA C6 05 FE 00 E B7 E EE 3F C6 05 => LDAB #$05 two-byte LDAB, IMM addressing mode 2002 FE 00 => LDX $00 three-byte LDX, EXT addressing mode 2005 E6 01 => LDAB 1,X two to four-byte LDAB, IDX addressing mode. Operand 01 => 1,X, a ant offset which uses only one postbyte => ABA two-byte ABA, INH addressing mode 2009 B7 E5 => EXG Y,X two-byte exchange/transfer instruction MSB of post-byte = 1 => exchange From Table A.5, E5 => (Y <=> X) 200b EE => X,(-18) three-byte loop instruction Postbyte 35 indicates X, negative 2 s complement of 0xEE is -18 decimal 200e 3F => SWI one-byte SWI, INH addressing mode 2

3 Freescale Semiconductor 395 S12CPUV2 Reference Manual, Rev BGND 01 5 MEM 02 1 INY 03 1 DEY 04 3 loop * RL JMP 06 3 JMP 07 4 BSR 08 1 INX 09 1 DEX 0A 7 RTC 0B 8 RTI 0C 4-6 BSET 0D 4-6 BCLR 0E 4-6 BRSET ID 4-6 0F 4-6 BRCLR ID ANDCC EDIV 12 1 MUL 13 3 EMUL 14 1 ORCC JSR 16 4 JSR 17 4 JSR 18 - Page LEAY 1A 2 LEAX 1B 2 LEAS 1C 4 BSET EX 4 1D 4 BCLR EX 4 1E 5 BRSET EX 5 1F 5 BRCLR EX BRA 21 1 BRN 22 3/1 BHI 23 3/1 BLS 24 3/1 BCC 25 3/1 BCS 26 3/1 BNE 27 3/1 BEQ 28 3/1 BVC 29 3/1 BVS 2A 3/1 BPL 2B 3/1 BMI 2C 3/1 BGE 2D 3/1 BLT 2E 3/1 BGT 2F 3/1 BLE 30 3 PULX 31 3 PULY 32 3 PULA 33 3 PULB 34 2 PSHX 35 2 PSHY 36 2 PSHA 37 2 PSHB 38 3 PULC 39 2 PSHC 3A 3 PULD 3B 2 PSHD 3C +5 wavr SP 1 3D 5 RTS 3E 7 WAI 3F 9 SWI 40 1 NEGA 41 1 COMA 42 1 INCA 43 1 DECA 44 1 LSRA 45 1 ROLA 46 1 RORA 47 1 ASRA 48 1 ASLA 49 1 LSRD 4A 7 CALL EX 4 4B 7- CALL ID 2-5 4C 4 BSET DI 3 4D 4 BCLR DI 3 4E 4 BRSET DI 4 4F 4 BRCLR DI 4 Key to Table A-2 Opcode Mnemonic Address Mode Table A-2. CPU12 Opcode Map (Sheet 1 of 2) 50 1 NEGB 51 1 COMB 52 1 INCB 53 1 DECB 54 1 LSRB 55 1 ROLB 56 1 RORB 57 1 ASRB 58 1 ASLB 59 1 ASLD 5A 2 STAA 5B 2 STAB 5C 2 STD 5D 2 STY 5E 2 STX 5F 2 STS NEG COM INC DEC LSR ROL ROR ASR ASL CLR 6A 2-4 STAA 6B 2-4 STAB 6C 2-4 STD 6D 2-4 STY 6E 2-4 STX 6F 2-4 STS 00 5 BGND IH I 70 4 NEG 71 4 COM 72 4 INC 73 4 DEC 74 4 LSR 75 4 ROL 76 4 ROR 77 4 ASR 78 4 ASL 79 3 CLR 7A 3 STAA 7B 3 STAB 7C 3 STD 7D 3 STY 7E 3 STX 7F 3 STS 80 1 SUBA 81 1 CMPA 82 1 SBCA 83 2 SUBD 84 1 ANDA 85 1 BITA 86 1 LDAA 87 1 CLRA 88 1 EORA 89 1 ADCA 8A 1 ORAA 8B 1 ADDA 8C 2 CPD 8D 2 CPY 8E 2 CPX 8F 2 CPS 90 3 SUBA 91 3 CMPA 92 3 SBCA 93 3 SUBD 94 3 ANDA 95 3 BITA 96 3 LDAA 97 1 TSTA 98 3 EORA 99 3 ADCA 9A 3 ORAA 9B 3 ADDA 9C 3 CPD 9D 3 CPY 9E 3 CPX 9F 3 CPS A0 3-6 SUBA A1 3-6 CMPA A2 3-6 SBCA A3 3-6 SUBD A4 3-6 ANDA A5 3-6 BITA A6 3-6 LDAA A7 1 NOP A8 3-6 EORA A9 3-6 ADCA AA 3-6 ORAA AB 3-6 ADDA AC 3-6 CPD AD 3-6 CPY AE 3-6 CPX AF 3-6 CPS B0 3 SUBA B1 3 CMPA B2 3 SBCA B3 3 SUBD B4 3 ANDA B5 3 BITA B6 3 LDAA B7 1 TFR/EXG B8 3 EORA B9 3 ADCA BA 3 ORAA BB 3 ADDA BC 3 CPD BD 3 CPY BE 3 CPX BF 3 CPS C0 1 SUBB C1 1 CMPB C2 1 SBCB C3 2 ADDD C4 1 ANDB C5 1 BITB C6 1 LDAB C7 1 CLRB C8 1 EORB C9 1 ADCB CA 1 ORAB CB 1 ADDB CC 2 LDD CD 2 LDY CE 2 LDX CF 2 LDS Number of HCS12 cycles ( indicates HC12 different) Number of bytes D0 3 SUBB D1 3 CMPB D2 3 SBCB D3 3 ADDD D4 3 ANDB D5 3 BITB D6 3 LDAB D7 1 TSTB D8 3 EORB D9 3 ADCB DA 3 ORAB DB 3 ADDB DC 3 LDD DD 3 LDY DE 3 LDX DF 3 LDS E0 3-6 SUBB E1 3-6 CMPB E2 3-6 SBCB E3 3-6 ADDD E4 3-6 ANDB E5 3-6 BITB E6 3-6 LDAB E7 3-6 TST E8 3-6 EORB E9 3-6 ADCB EA 3-6 ORAB EB 3-6 ADDB EC 3-6 LDD ED 3-6 LDY EE 3-6 LDX EF 3-6 LDS F0 3 SUBB F1 3 CMPB F2 3 SBCB F3 3 ADDD F4 3 ANDB F5 3 BITB F6 3 LDAB F7 3 TST F8 3 EORB F9 3 ADCB FA 3 ORAB FB 3 ADDB FC 3 LDD FD 3 LDY FE 3 LDX FF 3 LDS 3

4 396 Freescale Semiconductor S12CPUV2 Reference Manual, Rev MOVW IM-ID MOVW EX-ID MOVW ID-ID MOVW IM-EX MOVW EX-EX MOVW ID-EX ABA 07 3 DAA 08 4 MOVB IM-ID MOVB EX-ID 5 0A 5 MOVB ID-ID 4 0B 4 MOVB IM-EX 5 0C 6 MOVB EX-EX 6 0D 5 MOVB ID-EX 5 0E 2 TAB 0F 2 TBA 12 IDIV FDIV EMACS SP EMULS EDIVS IDIVS 16 2 SBA 17 2 CBA MAXA MINA 1A 4-7 EMAXD 1B 4-7 EMIND 1C 4-7 MAXM 1D D4-7 MINM 1E 4-7 EMAXM 1F 4-7 EMINM 20 4 LBRA 21 3 LBRN 22 4/3 LBHI 23 4/3 LBLS 24 4/3 LBCC 25 4/3 LBCS 26 4/3 LBNE 27 4/3 LBEQ 28 4/3 LBVC 29 4/3 LBVS 2A 4/3 LBPL 2B 4/3 LBMI 2C 4/3 LBGE 2D 4/3 LBLT 2E 4/3 LBGT 2F 4/3 LBLE A 3n REV SP 2 3B 5n/3n REVW SP A 4B A 5B A 6B A 7B A 8B A 9B A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB 3C 7B 4C 5C 6C 7C 8C 9C AC BC CC DC EC FC WAV SP 2 3D 6 4D 5D 6D 7D 8D 9D AD BD CD DD ED FD TBL ID 3 3E 8 STOP 3F ETBL ID 3 4E 4F Table A-2. CPU12 Opcode Map (Sheet 2 of 2) 5E 5F 6E 6F 7E 7F 8E 8F 9E 9F AE AF BE BF CE CF DE DF EE EF FE FF * The opcode $04 (on sheet 1 of 2) corresponds to one of the loop primitive instructions,,,,, or. Refer to instruction summary for more information. Refer to instruction summary for different HC12 cycle count. Page 2: When the CPU encounters a page 2 opcode ($18 on page 1 of the opcode map), it treats the next byte of object code as a page 2 instruction opcode. 4

5 Freescale Semiconductor 397 S12CPUV2 Reference Manual, Rev ,X 01 1,X 02 2,X 03 3,X 04 4,X 05 5,X 06 6,X 07 7,X 08 8,X 09 9,X 0A,X 0B 11,X 0C 12,X 0D 13,X 0E 14,X 0F 15,X 16,X 11 15,X 12 14,X 13 13,X 14 12,X 15 11,X 16,X 17 9,X 18 8,X 19 7,X 1A 6,X 1B 5,X 1C 4,X 1D 3,X 1E 2,X 1F 1,X 20 1,+X 21 2,+X 22 3,+X 23 4,+X 24 5,+X 25 6,+X 26 7,+X 27 8,+X 28 8, X 29 7, X 2A 6, X 2B 5, X 2C 4, X 2D 3, X 2E 2, X 2F 1, X 30 1,X+ 31 2,X+ 32 3,X+ 33 4,X+ 34 5,X+ 35 6,X+ 36 7,X+ 37 8,X+ 38 8,X 39 7,X 3A 6,X 3B 5,X 3C 4,X 3D 3,X 3E 2,X 3F 1,X Table A-3. Indexed Addressing Mode Postbyte Encoding (xb) 40 0,Y 41 1,Y 42 2,Y 43 3,Y 44 4,Y 45 5,Y 46 6,Y 47 7,Y 48 8,Y 49 9,Y 4A,Y 4B 11,Y 4C 12,Y 4D 13,Y 4E 14,Y 4F 15,Y 50 16,Y 51 15,Y 52 14,Y 53 13,Y 54 12,Y 55 11,Y 56,Y 57 9,Y 58 8,Y 59 7,Y 5A 6,Y 5B 5,Y 5C 4,Y 5D 3,Y 5E 2,Y 5F 1,Y 60 1,+Y 61 2,+Y 62 3,+Y 63 4,+Y 64 5,+Y 65 6,+Y 66 7,+Y 67 8,+Y 68 8, Y 69 7, Y 6A 6, Y 6B 5, Y 6C 4, Y 6D 3, Y 6E 2, Y 6F 1, Y Key to Table A-3 postbyte (hex) type offset used 70 1,Y+ 71 2,Y+ 72 3,Y+ 73 4,Y+ 74 5,Y+ 75 6,Y+ 76 7,Y+ 77 8,Y+ 78 8,Y 79 7,Y 7A 6,Y 7B 5,Y 7C 4,Y 7D 3,Y 7E 2,Y 7F 1,Y 80 0,SP 81 1,SP 82 2,SP 83 3,SP 84 4,SP 85 5,SP 86 6,SP 87 7,SP 88 8,SP 89 9,SP 8A,SP 8B 11,SP 8C 12,SP 8D 13,SP 8E 14,SP 8F 15,SP B0 #,REG type 90 16,SP 91 15,SP 92 14,SP 93 13,SP 94 12,SP 95 11,SP 96,SP 97 9,SP 98 8,SP 99 7,SP 9A 6,SP 9B 5,SP 9C 4,SP 9D 3,SP 9E 2,SP 9F 1,SP A0 1,+SP A1 2,+SP A2 3,+SP A3 4,+SP A4 5,+SP A5 6,+SP A6 7,+SP A7 8,+SP A8 8, SP A9 7, SP AA 6, SP AB 5, SP AC 4, SP AD 3, SP AE 2, SP AF 1, SP source code syntax B0 1,SP+ B1 2,SP+ B2 3,SP+ B3 4,SP+ B4 5,SP+ B5 6,SP+ B6 7,SP+ B7 8,SP+ B8 8,SP B9 7,SP BA 6,SP BB 5,SP BC 4,SP BD 3,SP BE 2,SP BF 1,SP C0 0,PC C1 1,PC C2 2,PC C3 3,PC C4 4,PC C5 5,PC C6 6,PC C7 7,PC C8 8,PC C9 9,PC CA,PC CB 11,PC CC 12,PC CD 13,PC CE 14,PC CF 15,PC D0 16,PC D1 15,PC D2 14,PC D3 13,PC D4 12,PC D5 11,PC D6,PC D7 9,PC D8 8,PC D9 7,PC DA 6,PC DB 5,PC DC 4,PC DD 3,PC DE 2,PC DF 1,PC E0 n,x 9b const E1 n,x 9b const E2 n,x 16b const E3 [n,x] 16b indr E4 A,X A offset E5 B,X B offset E6 D,X D offset E7 [D,X] D indirect E8 n,y 9b const E9 n,y 9b const EA n,y 16b const EB [n,y] 16b indr EC A,Y A offset ED B,Y B offset EE D,Y D offset EF [D,Y] D indirect F0 n,sp 9b const F1 n,sp 9b const F2 n,sp 16b const F3 [n,sp] 16b indr F4 A,SP A offset F5 B,SP B offset F6 D,SP D offset F7 [D,SP] D indirect F8 n,pc 9b const F9 n,pc 9b const FA n,pc 16b const FB [n,pc] 16b indr FC A,PC A offset FD B,PC B offset FE D,PC D offset FF [D,PC] D indirect 5

6 Freescale Semiconductor 399 S12CPUV2 Reference Manual, Rev. 4.0 Table A-5. Transfer and Exchange Postbyte Encoding TRANSFERS LS MS A A B A CCR A TMP3 L A B A X L A Y L A SP L A 1 A B B B CCR B TMP3 L B B B X L B Y L B SP L B 2 A CCR B CCR CCR CCR TMP3 L CCR B CCR X L CCR Y L CCR SP L CCR 3 sex:a TMP2 sex:b TMP2 sex:ccr TMP2 TMP3 TMP2 D TMP2 X TMP2 Y TMP2 SP TMP sex:a D SEX A,D sex:a X SEX A,X sex:a Y SEX A,Y sex:a SP SEX A,SP sex:b D SEX B,D sex:b X SEX B,X sex:b Y SEX B,Y sex:b SP SEX B,SP sex:ccr D SEX CCR,D sex:ccr X SEX CCR,X sex:ccr Y SEX CCR,Y sex:ccr SP SEX CCR,SP EXCHANGES TMP3 D D D X D Y D SP D TMP3 X D X X X Y X SP X TMP3 Y D Y X Y Y Y SP Y TMP3 SP D SP X SP Y SP SP SP LS MS 8 9 A B C D E F 0 A A B A CCR A 1 A B B B CCR B 2 A CCR B CCR CCR CCR 3 $00:A TMP2 TMP2 L A $00:B TMP2 TMP2 L B 4 $00:A D $00:B D $00:A X X L A $00:A Y Y L A $00:A SP SP L A TMP2 and TMP3 registers are for factory use only. $00:B X X L B $00:B Y Y L B $00:B SP SP L B $00:CCR TMP2 TMP2 L CCR $00:CCR D B CCR $00:CCR X X L CCR $00:CCR Y Y L CCR $00:CCR SP SP L CCR TMP3 L A $00:A TMP3 TMP3 L B $FF:B TMP3 TMP3 L CCR $FF:CCR TMP3 B A A B B B $FF A B CCR $FF:CCR D X L A $00:A X X L B $FF:B X X L CCR $FF:CCR X Y L A $00:A Y Y L B $FF:B Y Y L CCR $FF:CCR Y SP L A $00:A SP SP L B $FF:B SP SP L CCR $FF:CCR SP TMP3 TMP2 D TMP2 X TMP2 Y TMP2 SP TMP2 TMP3 D D D X D Y D SP D TMP3 X D X X X Y X SP X TMP3 Y D Y X Y Y Y SP Y TMP3 SP D SP X SP Y SP SP SP 6

7 Table A-6. Loop Primitive Postbyte Encoding (lb) 00 A 01 B 02 A 11 B A 21 B A 31 B A 41 B A 51 B A 61 B A 71 B A 81 B A 91 B 92 A0 A A1 B A2 B0 A B1 B B A3 B3 04 D 05 X 06 Y 07 SP 14 D 15 X 16 Y 17 SP 24 D 25 X 26 Y 27 SP 34 D 35 X 36 Y 37 SP 44 D 45 X 46 Y 47 SP 54 D 55 X 56 Y 57 SP 64 D 65 X 66 Y 67 SP 74 D 75 X 76 Y 77 SP 84 D 85 X 86 Y 87 SP 94 D 95 X 96 Y 97 SP A4 D A5 X A6 Y A7 SP B4 D B5 X B6 Y B7 SP Key to Table A-6 postbyte (hex) (bit 3 is don t care) branch condition B0 A _BEQ counter used sign of 9-bit relative branch offset (lower eight bits are an extension byte following postbyte) Table A-7. Branch/Complementary Branch Branch Complementary Branch Test Mnemonic Opcode Boolean Test Mnemonic Opcode Comment r>m BGT 2E Z + (N V) = 0 r m BLE 2F Signed r m BGE 2C N V = 0 r<m BLT 2D Signed r=m BEQ 27 Z = 1 r m BNE 26 Signed r m BLE 2F Z + (N V) = 1 r>m BGT 2E Signed r<m BLT 2D N V = 1 r m BGE 2C Signed r>m BHI 22 C + Z = 0 r m BLS 23 Unsigned r m BHS/BCC 24 C = 0 r<m BLO/BCS 25 Unsigned r=m BEQ 27 Z = 1 r m BNE 26 Unsigned r m BLS 23 C + Z = 1 r>m BHI 22 Unsigned r<m BLO/BCS 25 C = 1 r m BHS/BCC 24 Unsigned Carry BCS 25 C = 1 No Carry BCC 24 Simple Negative BMI 2B N = 1 Plus BPL 2A Simple Overflow BVS 29 V = 1 No Overflow BVC 28 Simple r=0 BEQ 27 Z = 1 r 0 BNE 26 Simple Always BRA 20 Never BRN 21 Unconditional For 16-bit offset long branches precede opcode with a $18 page prebyte. S12CPUV2 Reference Manual, Rev Freescale Semiconductor 7

8 Binary, Hex and Decimal Numbers (4-bit representation) Binary Hex A B C D E F Decimal

9 What does a number represent? Binary numbers are a code, and represent what the programmer intends for the code. 0x72 Some possible codes: r (ASCII) INC (HC12 instruction) 2.26V (Input from A/D converter) 114 (Unsigned 8 bit number) +114 (Signed 8 bit number) Set temperature in room to 69 F Set cruise control speed to 120 mph 9

10 Binary to Unsigned Decimal: Convert Binary to Unsigned Decimal x x x x x x x 2 1 x x x x x x x Hex to Unsigned Decimal Convert Hex to Unsigned Decimal 82D x x x x 16 8 x x x x

11 Unsigned Decimal to Hex Convert Unsigned Decimal to Hex Division Q R Decimal Hex 721/ / D 2/ = 2D

12 Signed Number Representation in 2 s Complement Form: If most significant bit is 0 (most significant hex digit 0 7), number is positive. Get decimal equivalent by converting number to decimal, and using + sign. Example for 8 bit number: 1 0 3A > + ( 3 x 16 + x 16 ) 16 + ( 3 x 16 + x 1 ) + 58 If most significant bit is 1 (most significant hex digit 8 F), number is negative. Get decimal equivalent by taking 2 s complement of number, converting to decimal, and using sign. Example for 8 bit number: A3 > ( 5D ) ( 5 x x 16 ) ( 5 x x 1 ) 93 12

13 One s Complement Table Makes It Simple To Find 2 s Complements One s Complement Table F E D C B A To take two s complement, add one to one s complement. Take two s complement of D0C3 : 2F3C + 1 = 2F3D 13

14 Addition and Subtraction of Hexadecimal Numbers. Setting the C (Carry), V (Overflow), N (Negative) and Z (Zero) bits How the C, V, N and Z bits of the CCR are changed Condition Code Register Bits N, Z, V, C N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0) V bit is set if operation produced an overflow C bit is set if operation produced a carry (borrow on subtraction) Note: Not all instructions change these bits of the CCR 14

15 ADDITION: Addition of Hexadecimal Numbers C bit set when result does not fit in word V bit set when P + P = N N + N = P N bit set when MSB of result is 1 Z bit set when result is 0 7A +52 2A +52 AC +8A AC +72 CC 7C 36 1E C: 0 C: 0 C: 1 C: 1 V: 1 V: 0 V: 1 V: 0 N: 1 N: 0 N: 0 N: 1 Z: 0 Z: 0 Z: 0 Z: 0 15

16 SUBTRACTION: Subtraction of Hexadecimal Numbers C bit set on borrow (when the magnitude of the subtrahend is greater than the minuend) V bit set when N P = P P N = N N bit set when MSB is 1 Z bit set when result is 0 7A 5C 8A 5C 5C 8A 2C 72 1E 2E D2 BA C: 0 C: 0 C: 1 C: 1 V: 0 V: 1 V: 1 V: 0 N: 0 N: 0 N: 1 N: 1 Z: 0 Z: 0 Z: 0 Z: 0 16

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory Table 1: Mnemonics s Dictionary ABA ABX ABY ADCA ADCB ADDA ADDB ADDD ANDA ANDB ASL ASLA ASLB ASLD ASR ASRA ASRB BCC BCLR BCS BEQ BGE BGT BHI BHS BITA BITB BLE BLO BLS BLT Add Accumulators Add B to X Add

More information

Department of Computer Science and Engineering

Department of Computer Science and Engineering Department of Computer Science and Engineering Instruction Set Overview This is a complete overview of the instruction set for the Motorola MC9S12DT256 microprocessor. Some of the groups are irrelevant

More information

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

Addressing Mode Description Addressing Mode Source Format Abbrev. Description Addressing Mode Description Addressing Mode Source Format Abbrev. Description Inherent INST (no operands) INH Operands (if any) are in CPU registers Immediate INST #opr8i or INST #opr16i IMM Operand is

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

EE319K Fall 2007 Quiz 1A Page 1. (5) Question 2. What will be the value of the carry (C) bit after executing the following? ldab #210 subb #60

EE319K Fall 2007 Quiz 1A Page 1. (5) Question 2. What will be the value of the carry (C) bit after executing the following? ldab #210 subb #60 EE319K Fall 2007 Quiz 1A Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire

More information

The Motorola 68HC11 Instruc5on Set

The Motorola 68HC11 Instruc5on Set The Motorola 68HC11 Instruc5on Set Some Defini5ons A, B * accumulators A and B D * double accumulator (A + B) IX, IY * index registers X and Y SP * stack pointer M * some memory loca5on opr * an operand

More information

EE319K Fall 2006 Quiz 1 Page 1

EE319K Fall 2006 Quiz 1 Page 1 EE319K Fall 2006 Quiz 1 Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire

More information

EE319K Fall 2003 Quiz 1 Page 1

EE319K Fall 2003 Quiz 1 Page 1 EE319K Fall 2003 Quiz 1 Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire

More information

EE319K Fall 2005 Quiz 1A Page 1

EE319K Fall 2005 Quiz 1A Page 1 EE319K Fall 2005 Quiz 1A Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire

More information

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the

More information

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the

More information

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

ECE331 Handout 3- ASM Instructions, Address Modes and Directives ECE331 Handout 3- ASM Instructions, Address Modes and Directives ASM Instructions Functional Instruction Groups Data Transfer/Manipulation Arithmetic Logic & Bit Operations Data Test Branch Function Call

More information

EE319K Fall 2010 Exam 1B Page 1

EE319K Fall 2010 Exam 1B Page 1 EE319K Fall 2010 Exam 1B Page 1 First: Last: This is a closed book exam. You must put your answers on pages 1,2,3,4 only. You have 50 minutes, so allocate your time accordingly. Show your work, and put

More information

EE319K Spring 2010 Exam 1A Page 1

EE319K Spring 2010 Exam 1A Page 1 EE319K Spring 2010 Exam 1A Page 1 First: Last: This is a closed book exam. You must put your answers pages 1,2,3 only. You have 50 minutes, so allocate your time accordingly. Show your work, and put your

More information

(5) Question 7. Simplified memory cycles (you may or may not need all 5 entries) R/W Addr Data

(5) Question 7. Simplified memory cycles (you may or may not need all 5 entries) R/W Addr Data EE319K Fall 2003 Quiz 3 Page 1 First: Middle Initial: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please

More information

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions Reading Assignment EEL 4744C: Microprocessor Applications Lecture 5 68HC12 Instruction Set Software and Hardware Engineering (Old version) Chapter 4 Or Software and Hardware Engineering (New version) Chapter

More information

Lecture 6 Assembly Programming: Branch & Iteration

Lecture 6 Assembly Programming: Branch & Iteration CPE 390: Microprocessor Systems Spring 2018 Lecture 6 Assembly Programming: Branch & Iteration Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ

More information

SECTION 6 CENTRAL PROCESSING UNIT

SECTION 6 CENTRAL PROCESSING UNIT SECTION 6 CENTRAL PROCESSING UNIT This section discusses the M68HC11 central processing unit (CPU), which is responsible for executing all software instructions in their programmed sequence. The M68HC11

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Q. 3.9 of HW3 EE 37 Microcontroller Applications (a) (c) (b) (d) Midterm Review: Miller Chapter -3 -The Stuff That Might Be On the Exam D67 (e) (g) (h) CEC23 (i) (f) (j) (k) (l) (m) EE37/CC/Lecture-Review

More information

0b) [2] Can you name 2 people form technical support services (stockroom)?

0b) [2] Can you name 2 people form technical support services (stockroom)? ECE 372 1 st Midterm ECE 372 Midterm Exam Fall 2004 In this exam only pencil/pen are allowed. Please write your name on the front page. If you unstaple the papers write your name on the loose papers also.

More information

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes o Review of Addressing Modes o Which branch instruction to use (signed vs unsigned) o Using X and Y registers

More information

EE 308 Spring The HCS12 has 6 addressing modes

EE 308 Spring The HCS12 has 6 addressing modes The HCS12 has 6 addressing modes Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access Effective Address: Memory address used by

More information

Fri. Aug 25 Announcements

Fri. Aug 25 Announcements Fri. Aug 25 Announcements HW 1 / Lab 1 next week Tools and fundamentals of instructions Remember no in-lab quiz but HWs still marked Slides online Complete class for last year This year s slides available

More information

EE4390 Microprocessors

EE4390 Microprocessors EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives Revised: Aug 1, 2003 1 68HC12 Instruction Set An instruction set is defined as a set of instructions that a

More information

Chapter 2 HCS12 Assembly Language

Chapter 2 HCS12 Assembly Language Chapter 2 HCS12 Assembly Language ECE 3120 Dr. Mohamed Mahmoud http://iweb.tntech.edu/mmahmoud/ mmahmoud@tntech.edu Outline 2.1 Assembly language program structure 2.2 Data transfer instructions 2.3 Arithmetic

More information

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh Chapter 2: HCS12 Assembly Programming EE383: Introduction to Embedded Systems University of Kentucky Samir Rawashdeh With slides based on material by H. Huang Delmar Cengage Learning 1 Three Sections of

More information

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ). AS12 Assembler Directives A Summary of 9S12 instructions Disassembly of 9S12 op codes Huang Section 1.8, Chapter 2 MC9S12 V1.5 Core User Guide Version 1.2, Section 12 o A labels is a name assigned the

More information

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference. 1) [ 9 marks] Write a sequence of directives for an HCS12 assembly language program that performs all of these tasks, in this order: a) Define an array called Measurements starting from memory location

More information

Motorola Semiconductor Technical Data. CPU12 Reference Guide. Figure 1. Programming Model. Order this document by CPU12RG/D Rev. 1

Motorola Semiconductor Technical Data. CPU12 Reference Guide. Figure 1. Programming Model. Order this document by CPU12RG/D Rev. 1 Motorola Semiconductor Technical Data 7 15 15 15 15 15 A 0 D X Y S C 7 B S X H I N Z V C 0 0 0 0 0 0 Figure 1. rogramming Model rder this document by RG/D Rev. 1 8-BIT ACCUMULATRS A AND B R 16-BIT DUBLE

More information

Menu. Programming Models for the Atmel XMEGA Architecture (and others devices) Assembly Programming Addressing Modes for the XMEGA Instruction Set

Menu. Programming Models for the Atmel XMEGA Architecture (and others devices) Assembly Programming Addressing Modes for the XMEGA Instruction Set Menu Programming Models for the Atmel XMEGA Architecture (and others devices) Assembly Programming Addressing Modes for the XMEGA Instruction Set Look into my... See examples on web-site: doc8331, doc0856

More information

Motorola 6809 and Hitachi 6309 Programmer s Reference

Motorola 6809 and Hitachi 6309 Programmer s Reference Motorola 6809 and Hitachi 6309 Programmer s Reference 2009 by Darren Atkinson A note about cycle counts The MPU cycle counts listed throughout this document will sometimes show two different values separated

More information

ECE/CS 5780/6780: Embedded System Design

ECE/CS 5780/6780: Embedded System Design ECE/CS 5780/6780: Embedded System Design Scott R. Little Lecture 3: Assembly Language Programming Scott R. Little (Lecture 3: Assembly) ECE/CS 5780/6780 1 / 59 Administrivia 2 versions of CodeWarrior are

More information

Transporting M68HC11 Code to M68HC12 Devices

Transporting M68HC11 Code to M68HC12 Devices SEMICONDUCTOR APPLICATION NOTE Order this document by: AN8/D Transporting M8HC Code to M8HC Devices By James M. Sibigtroth INTRODUCTION In general, the CPU is a proper superset of the M8HC CPU. Significant

More information

Assembly Language Development Process. ECE/CS 5780/6780: Embedded System Design. Assembly Language Listing. Assembly Language Syntax

Assembly Language Development Process. ECE/CS 5780/6780: Embedded System Design. Assembly Language Listing. Assembly Language Syntax Assembly Language Development Process ECE/CS 5780/6780: Embedded System Design Chris J. Myers Lecture 3: Assembly Language Programming Chris J. Myers (Lecture 3: Assembly Language) ECE/CS 5780/6780: Embedded

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014. c 2 =1 c 1 =1 c 0 =0 c 2 =1 c 1 =1 c 0 =0 c 4 =0 c 3 =0 c 2 =0 c 1 =0 c 0 =0 c 2 =0 c 1 =0 c 0 =1 c 2 =0 c 1 =0 c 0 =0 ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY Notes - Unit 4

More information

Administrivia. ECE/CS 5780/6780: Embedded System Design. Assembly Language Syntax. Assembly Language Development Process

Administrivia. ECE/CS 5780/6780: Embedded System Design. Assembly Language Syntax. Assembly Language Development Process Administrivia ECE/CS 5780/6780: Embedded System Design Scott R. Little Lecture 3: Assembly Language Programming 2 versions of CodeWarrior are on the lab machines. You should use the 4.5 version (CW for

More information

ECET Chapter 2, Part 3 of 3

ECET Chapter 2, Part 3 of 3 ECET 310-001 Chapter 2, Part 3 of 3 W. Barnes, 9/2006, rev d. 10/07 Ref. Huang, Han-Way, The HCS12/9S12: An Introduction to Software and Hardware Interfacing, Thomson/Delmar. In This Set of Slides: 1.

More information

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program Decimal, Hexadecimal and Binary Numbers Writing an assembly language program o Disassembly of MC9S12 op codes o Use flow charts to lay out structure of program o Use common flow structures if-then if-then-else

More information

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) COE538 Lecture Notes: Week 3 1 of 11 COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) Announcements My lecture sections should now be on Blackboard. I've also created a discussion forum (and anonymous

More information

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access HC12 Addressing Modes Instruction coding and execution o Inherent, Extended, Direct, Immediate, Indexed, and Relative Modes o Summary of MC9S12 Addressing Modes o Using X and Y registers as pointers o

More information

instruction 1 Fri Oct 13 13:05:

instruction 1 Fri Oct 13 13:05: instruction Fri Oct :0:0. Introduction SECTION INSTRUCTION SET This section describes the aressing modes and instruction types.. Aressing Modes The CPU uses eight aressing modes for flexibility in accessing

More information

ECET Chapter 2, Part 2 of 3

ECET Chapter 2, Part 2 of 3 ECET 310-001 Chapter 2, Part 2 of 3 W. Barnes, 9/2006, rev d. 10/07 Ref. Huang, Han-Way, The HCS12/9S12: An Introduction to Software and Hardware Interfacing, Thomson/Delmar. In This Set of Slides: 1.

More information

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0) Addition and Subtraction of Hexadecimal Numbers. Setting the C (Carry), V (Overflow), N (Negative) and Z (Zero) bits How the C, V, N and Z bits of the CCR are changed Condition Code Register Bits N, Z,

More information

EE319K Fall 2006 Final A Page 1

EE319K Fall 2006 Final A Page 1 EE319K Fall 2006 Final A Page 1 First: Middle Initial: Last: This is a closed book exam. You must put your answers in the space provided. You have 3 hours, so allocate your time accordingly. Please read

More information

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff Condition Code Register 1 Topics Condition code register Addition and subtraction instructions Conditional branches 2 Condition Code Register Condition code bits are automatically set by some instructions

More information

Exam I Review February 2017

Exam I Review February 2017 Exam I Review February 2017 Binary Number Representations Conversion of binary to hexadecimal and decimal. Convert binary number 1000 1101 to hexadecimal: Make groups of 4 bits to convert to hexadecimal,

More information

Lecture 7 Assembly Programming: Shift & Logical

Lecture 7 Assembly Programming: Shift & Logical CPE 390: Microprocessor Systems Fall 2017 Lecture 7 Assembly Programming: Shift & Logical Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030

More information

EE319K Fall 2007 Quiz 3 Page 1 of 8

EE319K Fall 2007 Quiz 3 Page 1 of 8 EE319K Fall 2007 Quiz 3 Page 1 of 8 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the

More information

538 Lecture Notes Week 2

538 Lecture Notes Week 2 538 Lecture Notes Week 2 (Sept. 13, 2017) 1/15 Announcements 538 Lecture Notes Week 2 Labs begin this week. Lab 1 is a one-week lab. Lab 2 (starting next week) is a two-week lab. 1 Answers to last week's

More information

538 Lecture Notes Week 3

538 Lecture Notes Week 3 538 Lecture Notes Week 3 (Sept. 20, 2017) 1/24 538 Lecture Notes Week 3 Answers to last week's questions 1 Write code so that the least significant bit of Accumulator A is cleared, the most significant

More information

Exam 2 E2-1 Fall Name: Exam 2

Exam 2 E2-1 Fall Name: Exam 2 Exam 2 E2-1 Fall 2002 1. Short Answer [10 pts] Exam 2 a.[2 pts] Briefly describe what each of the following instructions do so that it is clear what the differences between them are: STAA -2,X STAA 2,-X

More information

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7 ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 7 Reading Assignments Reading assignments for this week and next

More information

ECE3120: Computer Systems Hardware & Software Development Tools

ECE3120: Computer Systems Hardware & Software Development Tools ECE3120: Computer Systems Hardware & Software Development Tools Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun21 Email: msjeedigun21@tntech.edu Tel: 931-372-6181, Prescott Hall 120 Using the

More information

MIGRATING TO THE 68HC12 IN C

MIGRATING TO THE 68HC12 IN C MIGRATING TO THE 68HC12 IN C by Jean-Pierre Lavandier (Cosmic Software) and Greg Viot (Motorola) INTRODUCTION An important design goal of the 68HC12 was to maintain software compatibility with the 68HC11

More information

538 Lecture Notes Week 3

538 Lecture Notes Week 3 538 Lecture Notes Week 3 (Sept. 16, 2013) 1/18 538 Lecture Notes Week 3 Answers to last week's questions 1 Write code so that the least significant bit of Accumulator A is cleared, the most significant

More information

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming o A simple Assembly Language Program o Assembling an Assembly Language Program o Simple 9S12 programs o Hex code generated

More information

Exam 2 E2-1 Fall Name: Exam 2

Exam 2 E2-1 Fall Name: Exam 2 Exam 2 E2-1 Fall 2004 1. Short Answer [20 pts] Exam 2 a. [4 points] Show the contents of registers A, B, SP, and X after the following code executes: lds #$a00 ldab #$23 A = ldaa #$87 ldx #$2543 B = pshd

More information

ECE 3120 Computer Systems Arithmetic Programming

ECE 3120 Computer Systems Arithmetic Programming ECE 3120 Computer Systems Arithmetic Programming Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun21 Email: msjeedigun21@tntech.edu Tel: 931-372-6181, Prescott Hall 120 Today: Multiplication and

More information

A Simple MC9S12 Program

A Simple MC9S12 Program A Simple MC9S12 Program All programs and data must be placed in memory between address 0x1000 and 0x3BFF. For our programs we will put the first instruction at 0x2000, and the first data byte at 0x1000

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 37 Microcontroller Applications Lecture 8: Instruction Subset & Machine Language: A Brief Tour of the 68HC Instruction Set - Miller 2.4 & 5.2-5.3 & Appendix A Based on slides for ECE37 by Profs. Davis,

More information

The 6502 Instruction Set

The 6502 Instruction Set The 6502 Instruction Set Load and Store Group LDA Load Accumulator N,Z LDX Load X Register N,Z LDY Load Y Register N,Z STA Store Accumulator STX Store X Register STY Store Y Register Arithmetic Group ADC

More information

Lecture 9 Subroutines

Lecture 9 Subroutines CPE 390: Microprocessor Systems Spring 2018 Lecture 9 Subroutines Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030 Adapted from HCS12/9S12

More information

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming o A simple Assembly Language Program o Assembling an Assembly Language Program o Simple 9S12 programs o Hex code generated

More information

Figure 1. Programming Model

Figure 1. Programming Model Reference Guide CU12RG/D Rev. 2, 11/2001 CU12 Reference Guide (for HCS12 and original M68HC12) 7 15 A 0 D 7 B 0 0 8-BIT ACCUMULATRS A AND B R 16-BIT DUBLE ACCUMULATR D 15 X 0 INDEX REGISTER X 15 Y 0 INDEX

More information

Freescale Semiconductor, I

Freescale Semiconductor, I nc. Reference Guide CU12RG/D Rev. 2, 11/2001 CU12 Reference Guide (for HCS12 and original M68HC12) 7 15 15 15 15 15 A 0 D X Y S C 7 B S X H I N Z V C 0 0 0 0 0 0 8-BIT ACCUMULATRS A AND B R 16-BIT DUBLE

More information

Freescale Semiconductor, I

Freescale Semiconductor, I Reference Guide Rev. 2, 11/2001 CU12 Reference Guide (for HCS12 and original M68HC12) 7 15 15 15 15 15 A 0 D X Y S C 7 B S X H I N Z V C 0 0 0 0 0 0 8-BIT ACCUMULATRS A AND B R 16-BIT DUBLE ACCUMULATR

More information

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski, Microcontrollers 2IN60: Real-time Architectures (for automotive systems) Goals for this slide set Describe the architecture of a microcontroller Explain the purpose of an Instruction Set Architecture and

More information

ME 6405 Introduction to Mechatronics

ME 6405 Introduction to Mechatronics ME 6405 Introduction to Mechatronics Fall 2005 Instructor: Professor Charles Ume LECTURE 9 Homework 1 Solution 1. Write an assembly language program to clear the usable internal RAM in the M68HC11E9. Solution:

More information

Module 1-G. Marcos and Structured Programming

Module 1-G. Marcos and Structured Programming Module 1-G Marcos and Structured Programming 1 Learning Outcome #1 An ability to program a microcontroller to perform various tasks How? A. Architecture and Programming Model B. Instruction Set Overview

More information

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture) COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014. ECE-47/57: Microprocessor-Based System Design Fall 214 Notes - Unit 3 OVERVIEW OF THE HCS12 MICROCONTROLLER The HCS12 is a family of Freescale microcontrollers (MCUs) targeted to automotive and process

More information

Programming Book for 6809 Microprocessor Kit

Programming Book for 6809 Microprocessor Kit Programming Book for 6809 Microprocessor Kit Wichit Sirichote, wichit.sirichote@gmail.com Image By Konstantin Lanzet - CPU collection Konstantin Lanzet, CC BY-SA 3.0, Rev1.2 March 2018 1 Contents Lab 1

More information

CS 273 Machine Programming and Organization Lecture Notes

CS 273 Machine Programming and Organization Lecture Notes CS 273 Machine Programming and Organization Lecture Notes Joe Song Department of Computer Science NMSU, Spring 2009 March 9, 2009 Each lecture lasts 75 minutes Lecture 1 Announcements 1 fee payment for

More information

Sample Problem Set #1

Sample Problem Set #1 Sample Problem Set #1 Notes: These problems are typical exam problems; most are drawn from previous homeworks and exams. This exam is open book, open notes. It may help to have a calculator. For partial

More information

CHAPTER 8. Solutions for Exercises

CHAPTER 8. Solutions for Exercises CHAPTER 8 Solutions for Exercises E8.1 The number of bits in the memory addresses is the same as the address bus width, which is 20. Thus the number of unique addresses is 2 20 = 1,048,576 = 1024 1024

More information

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam.

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam. Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3 o Comparison of C and Assembly programs for the HC12 o How to compile a C program using the GNU-C compiler o Using pointers to access

More information

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12 EE383: Introduction to Embedded Systems University of Kentucky Samir Rawashdeh With slides based on material by H. Huang Delmar

More information

Outline. 2.8 Stack. 2.9 Subroutines

Outline. 2.8 Stack. 2.9 Subroutines Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by

More information

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions 1. (12 marks) Circle the correct answer for each of the following: The 8-bit two's complement representation of -15

More information

Exam 1 Feb. 23, 25, 27?

Exam 1 Feb. 23, 25, 27? Exam 1 Feb. 23, 25, 27? You will be able to use all of the Motorola data manuals on the exam. No calculators will be allowed for the exam. Numbers Decimal to Hex (signed and unsigned) Hex to Decimal (signed

More information

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS ECE 3610 Test 2 Solution 1 of 7 PRINT LAST NAME: STUDENT NUMBER PRINT FIRST NAME: UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING DATE: Feb. 28, 11; TIME: 6:00-8:00 P.M. Term Test

More information

Timing Generation and Measurements

Timing Generation and Measurements Timing Generation and Measurements Lab #7 Robert McManus & Junsang Cho April 2, 2004 Timing Generation and Measurements 1. Objective To gain experience using input capture to measure pulse width. To gain

More information

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003 Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 23 Name: Student Number: Time limit: 3 hours Section: Examiners: K Clowes,

More information

EE319K Spring 2011 Final Exam Version A Page 1 of 11

EE319K Spring 2011 Final Exam Version A Page 1 of 11 EE319K Spring 2011 Final Exam Version A Page 1 of 11 First: Last: This is a closed book exam. You must put your answers in the space provided. You have 3 hours, so allocate your time accordingly. Please

More information

4. Specifications and Additional Information

4. Specifications and Additional Information 4. Specifications and Additional Information AGX52004-1.0 8B/10B Code This section provides information about the data and control codes for Arria GX devices. Code Notation The 8B/10B data and control

More information

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0 Midterm Review 1. Branch instructions BHI (unsigned), BGT (signed) Take a look at the preceding comparison instruction. Then, you can use this instead of using complex formula in the instruction reference.

More information

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1 Version 1 1. (20 Points) Given the class A network address 117.0.0.0 will be divided into multiple subnets. a. (5 Points) How many bits will be necessary to address 4,000 subnets? b. (5 Points) What is

More information

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const EE319K Final Fall 2005 Solution C. Jonathan Valvano (3) Question 1. Consider a matrix with 4 rows and 6 columns, stored in column-major zero-index format. Each element is 16 bits. Which equation correctly

More information

A. CPU INSTRUCTION SET SUMMARY

A. CPU INSTRUCTION SET SUMMARY A. CPU INSTRUCTION SET SUMMARY This appendix summarizes the CPU instruction set. Table A-1 is a matrix of CPU instructions and addressing modes arranged by operation code. Table A-2 lists the CPU instruction

More information

AN1064. Motorola Semiconductor Application Note. Use of Stack Simplifies M68HC11 Programming By Gordon Doughman. Introduction

AN1064. Motorola Semiconductor Application Note. Use of Stack Simplifies M68HC11 Programming By Gordon Doughman. Introduction Order this document by /D Motorola Semiconductor Application Note Use of Stack Simplifies M68HC11 Programming By Gordon Doughman Introduction The architectural extensions of the M6800 incorporated into

More information

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1 Version 1 1. (24 Points) Show the routing tables for routers A, B, C, and D. Make sure you account for traffic to the Internet. NOTE: Router E should only be used for Internet traffic. Router A Router

More information

HC11 Instruction Set

HC11 Instruction Set HC11 Instruction Set Instruction classes 1. Accumulator and Memory 2. Stack and Index Register 3. Condition Code Register 4. Program control instructions CMPE12 Summer 2009 19-2 1 Accumulator and memory

More information

PROGRAMMING THE MICROCONTROLLER

PROGRAMMING THE MICROCONTROLLER PROGRAMMING THE MICROCONTROLLER ASSEMBLY LANGUAGE Assembly language is of higher level than machine language and hence easier to use. An assembly language code consists of a) Program statement lines b)

More information

Cross Assembly and Program Development

Cross Assembly and Program Development Cross Assembly and ENGG4640/3640; Fall 2004; Prepared by Radu Muresan 1 Introduction Text Editor Program Ex. DOS, Notepad, Word saved as ASCII Source Code Assembler or Cross-Assembler Object Code Machine

More information

Using the stack and the stack pointer

Using the stack and the stack pointer Using the stack and the stack pointer o The Stack and Stack Pointer o The stack is a memory area for temporary storage o The stack pointer points to the last byte in the stack o Some instructions which

More information

; Once Initialized, monitor character in calls to CN05 ; set carry for input, to be tested CN35 C SEC

; Once Initialized, monitor character in calls to CN05 ; set carry for input, to be tested CN35 C SEC // // Serialcode.s // 256 Byte Prom P8 and 512 Byte PROM P9A (second version) for Apple II Serial Card // P9A differs from P9 by adding RTS/ACK software flow control to output and // by removing batch

More information

S12CPUV2. Reference Manual HCS12. Microcontrollers. S12CPUV2/D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS

S12CPUV2. Reference Manual HCS12. Microcontrollers. S12CPUV2/D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS HCS12 Microcontrollers /D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS To provide the most up-to-date information, the revision of our documents on the World Wide Web will be the most current. Your printed

More information

EE319K Spring 2010 Final Exam Version B Page 1 of 12

EE319K Spring 2010 Final Exam Version B Page 1 of 12 EE319K Spring 2010 Final Exam Version B Page 1 of 12 First: Last: This is a closed book exam. You must put your answers in the space provided. You have 3 hours, so allocate your time accordingly. Please

More information

Lecture 11: Advanced Arithmetic Instructions

Lecture 11: Advanced Arithmetic Instructions Lecture 11: Advanced Arithmetic Instructions Today s Goals Use basic multiplication li and divisioni i instructions. ti Use shift and rotate instructions Multiplication Three different multiplication li

More information