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

Size: px
Start display at page:

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

Transcription

1 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

2 Three Sections of a HCS12/MC9S12 Assembly Program 1. Assembler Directives - Define data and symbol - Reserve and initialize memory locations - Set assembler and linking condition - Specify output format - Specifies the end of a program. 2. Assembly Language Instructions - HCS12/MC9S12 instructions 3. Comments - Explain the function of a single or a group of instructions

3 Identify the Four Fields of an Instruction Example loop adda #$40 ; add 40 to accumulator A (1) loop is a label (2) adda is an instruction mnemonic (3) #$40 is the operand (4) add #$40 to accumulator A is a comment movb 0,X,0,Y ; memory to memory copy (1) no label field (b) movb is an instruction mnemonic (c) 0,X,0,Y is the operand field (d) ; memory to memory copy is a comment

4 Fields of a HCS12 Instruction 1. Label field - Optional - Starts with a letter and followed by letters, digits, or special symbols (_ or.) - Can start from any column if ended with : - Must start from column 1 if not ended with : 2. Operation field - Contains the mnemonic of a machine instruction or an assembler directive - Separated from the label by at least one space 3. Operand field - Follows the operation field and is separated from the operation field by at least one space - Contains operands for instructions or arguments for assembler directives 4. Comment field - Any line starts with an * or ; is a comment - Separated from the operand and operation field for at least one space - Optional

5 Assembler Directives 1. end - ends a program to be processed by an assembler - any statement following the end directive is ignored 2. org - The assembler uses a location counter to keep track of the memory location where the next machine code byte should be placed. - This directive sets a new value for the location counter of the assembler. The sequence org $1000 ldab #$FF places the opcode byte for the instruction ldab #$FF at location $1000.

6 dc.b (define constant byte) db (define byte) fcb (form constant byte) - These three directives define the value of a byte or bytes that will be placed at a given location. - These directives are often preceded by the org directive. - For example, org $800 array dc.b $11,$22,$33,$44 dc.w (define constant word) dw (define word) fdb (form double bytes) - Define the value of a word or words that will be placed at a given location. - The value can be specified by an expression. - For example, org $1000 vec_tab dc.w $1234, $5620

7 fcc (form constant character) - Used to define a string of characters (a message). - The first character (and the last character) is used as the delimiter. - The last character must be the same as the first character. - The delimiter must not appear in the string. - The space character cannot be used as the delimiter. - Each character is represented by its ASCII code. - For example, msg fcc Please enter 1, 2 or 3:

8 ds (define storage) rmb (reserve memory byte) ds.b (define storage bytes) - Each of these directives reserves a number of bytes given as the arguments to the directive. - For example, buffer ds 100 reserves 100 bytes

9 ds.w (define storage word) rmw (reserve memory word) - Each of these directives increments the location counter by the value indicated in the number-of-words argument multiplied by two. - For example, dbuf ds.w 20 reserves 40 bytes starting from the current location counter. equ (equate) - This directive assigns a value to a label. - Using this directive makes one s program more readable. - Examples arr_cnt equ 100 oc_cnt equ 50

10 Macro - A name assigned to a group of instructions - Use macro and endm to define a macro. - Example of macro sumof3 macro ldaa adda adda endm arg1,arg2,arg3 arg1 arg2 arg3 - Invoke a defined macro: write down the name and the arguments of the macro sumof3 $1000,$1001,$1002 is replaced by ldaa $1000 adda $1001 adda $1002

11 Software Development Process 1 Problem definition: Identify what should be done 2 Develop the algorithm. Algorithm is the overall plan for solving the problem at hand. - An algorithm is often expressed in the following format: Step 1 Step 2 - Another way to express the overall plan is to use flowchart. 3 Programming. Convert the algorithm or flowchart into programs. 4 Program Testing. 5 Program maintenance.

12 Symbols of Flowchart Terminal A Process Subroutine Input or output Decision no B off-page connector yes A on-page connector Figure 2.1 Flowchart symbols used in this book

13 Programs to do simple arithmetic Example 2.4 Write a program to add the values of memory locations at $1000, $1001, and $1002, and save the result at $1100. Solution: Step 1 A m[$1000] Step 2 A A + m[$1001] Step 3 A A + m[$1002] Step 4 $1100 A org $1500 ldaa $1000 adda $1001 adda $1002 staa $1100 end

14 Example 2.4 Write a program to subtract the contents of the memory location at $1005 from the sum of the memory locations at $1000 and $1002, and store the difference at $1100. Solution: org $1500 ldaa $1000 adda $1002 suba $1005 staa $1100 end

15 Example 2.6 Write a program to add two 16-bit numbers that are stored at $1000-$1001 and $1002-$1003 and store the sum at $1100-$1101. Solution: org $1500 ldd $1000 addd $1002 std $1100 end The Carry Flag - bit 0 of the CCR register - set to 1 when the addition operation produces a carry 1 - set to 1 when the subtraction operation produces a borrow 1 - enables the user to implement multi-precision arithmetic

16 Example 2.7 Write a program to add two 4-byte numbers that are stored at $1000-$1003 and $1004-$1007, and store the sum at $1010-$1013. Solution: Addition starts from the LSB and proceeds toward MSB. org $1500 ldd $1002 ; add and save the least significant two bytes addd $1006 ; std $1012 ; ldaa $1001 ; add and save the second most significant bytes adca $1005 ; staa $1011 ; ldaa $1000 ; add and save the most significant bytes adca $1004 ; staa $1010 ; end

17 Example 2.8 Write a program to subtract the hex number stored at $1004-$1007 from the the hex number stored at $1000-$1003 and save the result at $1100-$1103. Solution: The subtraction starts from the LSBs and proceeds toward the MSBs. org $1500 ldd $1002 ; subtract and save the least significant two bytes subd $1006 ; std $1102 ; ldaa $1001 ; subtract and save the difference of the second to most sbca $1005 ; significant bytes staa $1001 ; ldaa $1000 ; subtract and save the difference of the most significant sbca $1004 ; bytes staa $1100 ; end

18 Multiplication and Division

19 Example 2.10 Write an instruction sequence to multiply the 16-bit numbers stored at $1000- $1001 and $1002-$1003 and store the product at $1100-$1103. Solution: ldd $1000 ldy $1002 emul sty $1100 std $1102 Example 2.11 Write an instruction sequence to divide the signed 16-bit number stored at $1020-$1021 into the 16-bit signed number stored at $1005-$1006 and store the quotient and remainder at $1100 and $1102, respectively. Solution: ldd $1005 ldx $1020 idivs stx $1100 ; store the quotient std $1102 ; store the remainder

20 Illustration of 32-bit by 32-bit Multiplication - Two 32-bit numbers M and N are divided into two 16-bit halves M = M H M L N = N H N L

21 BCD numbers and addition - Each digit is encoded by 4 bits - Two digits are packed into one byte - The addition of two BCD numbers is performed by a binary addition and an adjust operation using the daa instruction - The instruction daa can be applied after the instructions adda, adca, and aba - Simplifies I/O conversion For example, the instruction sequence ldaa $1000 adda $1001 daa staa $1002 adds the BCD numbers stored at $1000 and $1001 and saves the sum at $1002.

22 Example 2.13 Write a program to convert the 16-bit number stored at $1000-$1001 to BCD format and store the result at $1010-$1014. Convert each BCD digit into its ASCII code and store it in one byte. Solution: - A binary number can be converted to BCD format by using repeated division by The largest 16-bit binary number is which has five decimal digits. - The first division by 10 generates the least significant digit, the second division by 10 obtains the second least significant digit, and so on. org $1000 data dc.w ; data to be tested org $1010 result ds.b 5 ; reserve bytes to store the result org $1500 ldd data ldy #result ldx #10 idiv addb #$30 ; convert the digit into ASCII code stab 4,Y ; save the least significant digit xgdx ldx #10

23 idiv adcb #$30 stab 3,Y ; save the second to least significant digit xgdx ldx #10 idiv addb #$30 stab 2,Y ; save the middle digit xgdx ldx #10 idiv addb #$30 stab 1,Y ; save the second most significant digit xgdx addb #$30 stab 0,Y ; save the most significant digit end

24 ASCII Table

25 Program Loops Types of program loops: finite and infinite loops Looping Mechanisms 1. do statement S forever 2. For i = n1 to n2 do statement S or For i = n2 downto n1 do statement S 3. While C do statement S 4. Repeat statement S until C Program loops are implemented by using the conditional branch instructions and the execution of these instructions depends on the contents of the CCR register.

26

27 Condition Code Register Four types of branch instructions: - Unary (unconditional) branch: always execute - Simple branches: branch is taken when a specific bit of CCR is in a specific status - Unsigned branches: branches are taken when a comparison or test of unsigned numbers results in a specific combination of CCR bits - Signed branches: branches are taken when a comparison or test of signed quantities are in a specific combination of CCR bits

28

29 Compare and Test Instructions - Condition flags need to be set up before conditional branch instruction should be executed. - The HCS12 provides a group of instructions for testing the condition flags.

30 Loop Primitive Instructions - HCS12 provides a group of instructions that either decrement or increment a loop count to determine if the looping should be continued. - The range of the branch is from $80 (-128) to $7F (+127).

31 Implementation of Looping Constructs for I = n1 to n2 do S n1 equ xx ; starting index n2 equ yy ; ending index i ds.b 1 ; loop index variable movb #n1,i ; initialize i to n1 loopf ldaa i ; check index i cmpa #n2 bgt next ; if i is greater than n2, exit the loop ; performs loop operations ; inc i ; increment loop index bra loopf next

32 for i = n2 downto n1 do S n1 equ xx ; starting index n2 equ yy ; ending index i ds.b 1 ; loop index variable movb #n2,i ; initialize i to n2 loopf ldaa i ; check index i cmpa #n1 blt next ; if i is less than n1, exit the loop ; perform loop operations ; dec i ; increment loop index bra loopf next

33 While loop Loop terminating condition is checked at the start of the loop In the following example, icount == 0 is the condition to be check. The update of icount is done by an interrupt service routine (not shown below). N equ xx icount ds.b 1 movb #N,icount wloop ldaa #0 cmpa icount beq next bra wloop next

34 Repeat S until C Often used when a certain operation need to be performed a fixed number of times The template of this looping construct is as follows: N equ xx ldy #N ; Y is used as the loop counter loopr ; perform the desired operations ; dbne Y,loopr ; decrement the loop counter and decide whether to ; to continue

35 Example 2.14 Write a program to add an array of N 8-bit numbers and store the sum at memory locations $1000~$1001. Use the For i = n1 to n2 do looping construct. Solution: N equ 20 org $1000 sum ds.b 2 i ds.b 1 org $1500 movb #0,i movw #0,sum ; sum 0 loop ldab i cmpb #N ; is i = N? beq done ldx #array abx ldab 0,X ; sum sum + array[i] ldy sum ; aby ; sty sum ; inc i bra loop done swi

36 array dc.b 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 end Example 2.15 Write a program to find the maximum element from an array of N 8-bit elements using the repeat S until C looping construct. Solution:

37 N equ 20 org $1000 max_val ds.b 1 org $1500 ldaa array ; set array[0] as the temporary max max staa max_val ; ldx #array+n-1 ; start from the end of the array ldab #N-1 ; set loop count to N - 1 loop ldaa max_val cmpa 0,x bge chk_end ldaa 0,x staa max_val ; update the array max chk_end dex ; move to the next array element dbne b,loop ; finish all the comparison yet? forever bra forever array db 1,3,5,6,19,41,53,28,13,42,76,14 db 20,54,64,74,29,33,41,45 end

38 Bit Condition Branch Instructions [<label>] brclr (opr),(msk),(rel) [<comment>] [<label>] brset (opr),(msk),(rel) [<comment>] where opr specifies the memory location to be checked and must be specified using either the direct, extended, or index addressing mode. msk is an 8-bit mask that specifies the bits of the memory location to be checked. The bits of the memory byte to be checked correspond to those bit positions that are 1s in the mask. rel is the branch offset and is specified in the 8-bit relative mode. For example, in the sequence loop inc count brclr $66,$e0,loop the branch will be taken if the most significant three bits at $66 are all zeros.

39 Example 2.17 Write a program to compute the number of elements that are divisible by 4 in an array of N 8-bit elements. Use the repeat S until C looping construct. Solution: A number divisible by 4 would have the least significant two bits equal 0s. N equ 20 org $1000 total ds.b 1 org $1500 clr total ; initialize total to 0 ldx #array ldab #N ; use B as the loop count loop brclr 0,x,$03,yes ; check bits 1 and 0 bra chkend yes inc total chkend inx dbne b,loop forever bra forever array db 2,3,4,8,12,13,19,24,33,32,20,18,53,52,80,82,90,94,100,102 end

40 Instructions for Variable Initialization 1. [<label>] CLR opr [<comment>] where opr is specified using the extended or index addressing modes. The specified memory location is cleared. 2. [<label>] CLRA [<comment>] Accumulator A is cleared to 0 3. [<label>] CLRB [<comment>] Accumulator B is cleared to 0

41 Shift and Rotate Instructions The HCS12 has shift and rotate instructions that apply to a memory location, accumulators A, B and D. A memory operand must be specified using the extended or index addressing modes. There are three 8-bit arithmetic shift left instructions: [<label>] asl opr [<comment>] -- memory location opr is shifted left one place [<label>] asla [<comment>] -- accumulator A is shifted left one place [<label>] aslb [<comment>] -- accumulator B is shifted left one place The operation is C b b0 0

42 The HCS12 has one 16-bit arithmetic shift left instruction: [<label>] asld [<comment>] The operation is The HCS12 has arithmetic shift right instructions that apply to a memory location and accumulators A and B. [<label>] asr opr [<comment>] -- memory location opr is shifted right one place [<label>] asra [<comment>] -- accumulator A is shifted right one place [<label>] asrb [<comment>] -- accumulator B is shifted right one place The operation is C b b0 b b0 0 accumulator A accumulator B b b0 C

43 The HCS12 has logical shift left instructions that apply to a memory location and accumulators A and B. [<label>] lsl opr [<comment>] -- memory location opr is shifted left one place [<label>] lsla [<comment>] -- accumulator A is shifted left one place [<label>] lslb [<comment>] -- accumulator B is shifted left one place The operation is C b b0 0 The HCS12 has one 16-bit logical shift left instruction: [<label>] lsld [<comment>] The operation is C b b0 b b0 0 accumulator A accumulator B

44 The HCS12 has three logical shift right instructions that apply to 8-bit operands. [<label>] lsr opr [<comment>] -- memory location opr is shifted right one place [<label>] lsra [<comment>] -- accumulator A is shifted right one place [<label>] lsrb [<comment>] -- accumulator B is shifted right one place The operation is 0 b b0 C The HCS12 has one 16-bit logical shift right instruction: [<label>] lsrd [<comment>] The operation is 0 b b0 b b0 accumulator A accumulator B C

45 The HCS12 has three rotate left instructions that operate on 9-bit operands. [<label>] rol opr [<comment>] -- memory location opr is rotated left one place [<label>] rola [<comment>] -- accumulator A is rotated left one place [<label>] rolb [<comment>] -- accumulator B is rotated left one place The operation is b b0 C The HCS12 has three rotate right instructions that operate on 9-bit operands. [<label>] ror opr [<comment>] -- memory location opr is rotated right one place [<label>] rora [<comment>] -- accumulator A is rotated right one place [<label>] rorb [<comment>] -- accumulator B is rotated right one place The operation is C b b0

46 Example 2.18 Suppose that [A] = $95 and C = 1. Compute the new values of A and C after the execution of the instruction asla. Solution: accumulator A C flag Original value [A] = C = 1 New value [A] = C = Figure 2.11b Execution result of the ASLA instruction Figure 2.11a Operation of the ASLA instruction Example 2.19 Suppose that m[$800] = $ED and C = 0. Compute the new values of m[$800] and the C flag after the execution of the instruction asr $1000. Solution: memory location $ C flag Original value [$1000] = C = 0 New value [$1000] = C = Figure 2.12b Result of the asr $1000 instruction Figure 2.12a Operation of the ASR $1000 instruction

47 Example 2.20 Suppose that m[$1000] = $E7 and C = 1. Compute the new contents of m[$1000] and the C flag after the execution of the instruction lsr $1000. Solution: Example 2.21 Suppose that [B] = $BD and C = 1. Compute the new values of B and the C flag after the execution of the instruction rolb. Solution:

48 Example 2.22 Suppose that [A] = $BE and C = 1. Compute the new values of mem[$00] after the execution of the instruction rora. Solution:

49 Example 2.23 Write a program to count the number of 0s in the 16-bit number stored at $1000-$1001 and save the result in $1005. Solution: * The 16-bit number is shifted to the right 16 time. * If the bit shifted out is a 0 then increment the 0s count by 1. org $1000 db $23,$55 ; test data org $1005 zero_cnt rmb 1 lp_cnt rmb 1 org $1500 clr zero_cnt ; initialize the 0s count to 0 ldaa #16 staa lp_cnt ldd $1000 ; place the number in D loop lsrd ; shift the lsb of D to the C flag bcs chkend ; is the C flag a 0? inc zero_cnt ; increment 1s count if the lsb is a 1 chkend dec lp_cnt ; check to see if D is already 0 bne loop forever bra forever end

50 Shift a multi-byte number For shifting right 1. The bit 7 of each byte will receive the bit 0 of its immediate left byte with the exception of the most significant byte which will receive a Each byte will be shifted to the right by 1 bit. The bit 0 of the least significant byte will be lost. Suppose there is a k-byte number that is stored at loc to loc+k-1. method for shifting right Step 1: Shift the byte at loc to the right one place. Step 2: Rotate the byte at loc+1 to the right one place. Step 3: Repeat Step 2 for the remaining bytes.

51 For shifting left 1. The bit 0 of each byte will receive the bit 7 of its immediate right byte with the exception of the least significant byte which will receive a Each byte will be shifted to the left by 1 bit. The bit 7 of the most significant byte will be lost. Suppose there is a k-byte number that is stored at loc to loc+k-1. method for shifting left Step 1: Shift the byte at loc+k-1 to the left one place. Step 2: Rotate the byte at loc+k-2 to the left one place. Step 3: Repeat Step 2 for the remaining bytes.

52 Example 2.24 Write a program to shift the 32-bit number stored at $820-$823 to the right four places. Solution: ldab #4 ; set up the loop count ldx #$820 ; use X as the pointer to the left most byte again lsr 0,X ror 1,X ror 2,X ror 3,X dbne b,again end

53 Boolean Logic Instructions Changing a few bits are often done in I/O applications. Boolean logic operation can be used to change a few I/O port pins easily.

54 Program Execution Time The HCS12 uses the E clock as a timing reference. The frequency of the E clock is half of that of the crystal oscillator. There are many applications that require the generation of time delays. The creation of a time delay involves two steps: 1. Select a sequence of instructions that takes a certain amount of time to execute. 2. Repeat the selected instruction sequence for an appropriate number of times. For example, the instruction sequence on the next page takes 40 E cycles to execute. By repeating this instruction sequence certain number of times, any time delay can be created. Assume that the HCS12 runs under a crystal oscillator with a frequency of 16 MHz, then the E frequency is 8 MHz and hence its clock period is 125 ns. Therefore the instruction sequence on the next page will take 5 ms to execute.

55 loop psha ; 2 E cycles pula ; 3 E cycles psha pula psha pula psha pula psha pula psha pula psha pula nop ; 1 E cycle nop ; 1 E cycle dbne x,loop ; 3 E cycles

56 Example 2.25 Write a program loop to create a delay of 100 ms. Solution: A delay of 100 ms can be created by repeating the previous loop times. The following instruction sequence creates a delay of 100 ms. ldx #20000 loop psha ; 2 E cycles pula ; 3 E cycles psha pula psha pula psha pula psha pula psha pula psha pula nop ; 1 E cycle nop ; 1 E cycle dbne x,loop ; 3 E cycles

57 From the CPU12 Reference Manual: PSHA takes 2 E-cycles to execute

58 Example 2.26 Write an instruction sequence to create a delay of 10 seconds. Solution: By repeating the previous instruction sequence 100 times, we can create a delay of 10 seconds. ldab #100 out_loop ldx #20000 in_loop psha ; 2 E cycles pula ; 3 E cycles psha pula psha pula psha pula psha pula psha pula psha pula nop ; 1 E cycle nop ; 1 E cycle dbne x,in_loop ; 3 E cycles dbne b,out_loop ; 3 E cycles

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Lecture 5 Assembly Programming: Arithmetic

Lecture 5 Assembly Programming: Arithmetic CPE 390: Microprocessor Systems Spring 2018 Lecture 5 Assembly Programming: Arithmetic Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030

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

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

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

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

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

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:

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: 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 ---- ------------------------------------------------------

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz G-CPU Important Notes (see Schwartz s lecture for a general overview) - The

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

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

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

HC11 Instruction Set Architecture

HC11 Instruction Set Architecture HC11 Instruction Set Architecture Summer 2008 High-level HC11 architecture Interrupt logic MEMORY Timer and counter M8601 CPU core Serial I/O A/D converter Port A Port B Port C Port D Port E CMPE12 Summer

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

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

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

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1 Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University What is Assembly Language? Assembly language is a programming language

More information

HC11 Instruction Set Architecture

HC11 Instruction Set Architecture HC11 Instruction Set Architecture High-level HC11 architecture Interrupt logic MEMORY Timer and counter M8601 CPU core Serial I/O A/D converter Port A Port B Port C Port D Port E CMPE12 Summer 2009 16-2

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

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my... Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my... See examples on web: DirAddr.asm, ExtAddr.asm, IndAddr.asm,

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

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

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (Sept. 30, 2013) 1/15 538 Lecture Notes Week 5 Answers to last week's questions 1. With the diagram shown for a port (single bit), what happens if the Direction Register is read?

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (October 4, 2017) 1/18 538 Lecture Notes Week 5 Announements Midterm: Tuesday, October 25 Answers to last week's questions 1. With the diagram shown for a port (single bit), what

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

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

Coe538 Final Study Guide 2016 (Questions & Answers)

Coe538 Final Study Guide 2016 (Questions & Answers) Coe538 Study Guide 1 of 8 Coe538 Final Study Guide 2016 (Questions & Answers) This version contains questions AND answers. This study guide is meant to help you review coe538 and prepare for the final.

More information

Lab 7: Asynchronous Serial I/O

Lab 7: Asynchronous Serial I/O CpE 390 Microprocessor Systems Lab 7: Asynchronous Serial I/O 1. Introduction Serial communications is the transfer of data, one bit at a time, over a communications channel. Serial communications can

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

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

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

1. Memory Mapped Systems 2. Adding Unsigned Numbers

1. Memory Mapped Systems 2. Adding Unsigned Numbers 1 Memory Mapped Systems 2 Adding Unsigned Numbers 1 1 Memory Mapped Systems Our system uses a memory space Address bus is 16-bit locations Data bus is 8-bit 2 Adding Unsigned Numbers 2 Our system uses

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

CMPEN 472 Sample EXAM II

CMPEN 472 Sample EXAM II CMPEN 472 Sample EXAM II Name: Student ID number (last 4 digit): Please write your name on every page. Write your solutions clearly. You may use backside of each page for scratch but the solutions must

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

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

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

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

Introduction to the 9S12 Microcontroller

Introduction to the 9S12 Microcontroller Introduction to the 9S12 Microcontroller o Harvard architecture and Princeton architecture o Memory map for a Princeton architecture microprocessor o 68HC12 Address Space o 68HC12 ALU o 68HC12 Programming

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

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

EE319 K Lecture 7. Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines. University of Texas ECE

EE319 K Lecture 7. Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines. University of Texas ECE EE319 K Lecture 7 Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines University of Texas ECE Texas and execution A $24 EEPROM $F800 $F801 $86 $F802 $24 $F803 }ldaa #36

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

HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks!

HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks! HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks! Instruction Classes! Accumulator and Memory! Stack and Index Register! Condition Code Register! Program Control! Accumulator and memory

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

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

It translates (converts) assembly language to machine code.

It translates (converts) assembly language to machine code. Assemblers 1 It translates (converts) assembly language to machine code. Example: LDAA $0180 Uses an instruction set manual: Tests/Final Exam. B6 01 80 Use software: Like the IDE in the Lab. 2 Assembler:

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

Module 1-D. Control Structure Applications. Tim Rogers 2017 [1.D]-1

Module 1-D. Control Structure Applications. Tim Rogers 2017 [1.D]-1 Module 1-D Control Structure Applications Tim Rogers 2017 [1.D]-1 Learning Outcome #1 An ability to program a microcontroller to perform various tasks How? A. Architecture and Programming Model B. Instruction

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

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

Chapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Chapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh Chapter 4: Advanced Assembly Programming EE383: Introduction to Embedded Systems University of Kentucky Samir Rawashdeh With slides based on material by H Huang Delmar Cengage Learning Chapter Summery

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers Memory Map I/O Registers Instruction

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

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

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

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

Mark II Aiken Relay Calculator

Mark II Aiken Relay Calculator Introduction to Embedded Microcomputer Systems Lecture 6.1 Mark II Aiken Relay Calculator 2.12. Tutorial 2. Arithmetic and logical operations format descriptions examples h 8-bit unsigned hexadecimal $00

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

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

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

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

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming Assembly Programming HCS12 Assembly Programming Basic Assembly Programming Top Assembly Instructions (Instruction You Should Know!) Assembly Programming Concepts Assembly Programming HCS12 Assembly Instructions

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

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports Lab 2 Part 1 Assembly Language Programming and 9S12 Ports In this sequence of three labs, you will learn how to write simple assembly language programs for the MC9S12 microcontroller, and how to use general

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

Wed. Sept 6 Announcements

Wed. Sept 6 Announcements Wed. Sept 6 Announcements HW 3 / Lab 3 posted [1.C]-1 Endianness Problem: Memory is byte addressed. Sometimes you want to access multi-byte values (16-bit, 32-bits etc.) X is 2-bytes Addr Memory Value

More information

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003 ******************************************************* * This program for CSE472, Flash Memory Writing * * By Kyusun Choi, ID=0000 * * Date: 11/14/2009 * * Freescale CodeWarrior, for the MC9S12C32 Program

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