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

Size: px
Start display at page:

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

Transcription

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

2 Texas and execution A $24 EEPROM $F800 $F801 $86 $F802 $24 $F803 }ldaa #36 The TExaS simulation of this instruction shows the following two cycles. Opcode fetch R 0xF801 0x86 from EEPROM Operand fetch R 0xF802 0x24 from EEPROM

3 Addressing modes Direct Page addressing mode uses an 8-bit address access from addresses 0 to $00FF called zero-page. on the 9S12 they reference the I/O ports the < operator forces direct addressing I/O EEPROM A $57 $0035 $0036 $57 $0037 $F800 $F801 $96 $F802 $24 $F803 }ldaa 36 Figure Example of the direct-page addressing mode. The TExaS 9S12 simulation this instruction shows the following three cycles. Opcode fetch R 0xF801 0x96 from EEPROM Operand fetch R 0xF802 0x24 from EEPROM Fetch using EARR 0x0024 0x57 from I/O

4 Addressing Modes Extended addressing uses a 16-bit address size of data depends on the op code (which register is uses) access all memory and I/O devices outside Motorola family this addressing mode is called direct the > operator forces extended addressing RAM EEPROM A $62 $0800 $0801 $62 $0802 $F800 $F801 $B6 $F802 $08 $F803 $01 }ldaa $0801 The TExaS 9S12 simulation of this instruction shows the following four cycles. Opcode fetch R 0xF801 0xB6 from EEPROM Operand fetch R 0xF802 0x08 from EEPROM Operand fetch R 0xF803 0x01 from EEPROM Fetch using EARR 0x0801 0x62 from RAM

5 Addressing modes Indexed mode is useful pointers into data structures parameters on the stack. local variables on the stack. 16-bit addition (leax, leay, leas), e..g., leax 10,x ; RegX=RegX+10 Indexed addressing mode fixed offset with the 16-bit registers: X, Y, SP, or PC 5-bit (-16 to +15), 9-bit (-256 to +255), or 16-bit unsigned (0 to 65535) or signed ( to )

6 Indexed Address modes Auto Pre/Post Decrement/Increment Indexed uses the 16-bit registers: X, Y, or SP. register is modified either before (pre) or after (post) amount added to (subtracted from) 1 to 8 In each case assume RegY is initially Post-increment examples: staa 1,Y+ [2345]=RegA, then RegY=2346 staa 4,Y+ [2345]=RegA, then RegY=2349 Pre-increment examples: staa 1,+Y RegY=2346, then [2346]=RegA staa 4,+Y RegY=2349, then [2349]=RegA Post-decrement examples: staa 1,Y- [2345]=RegA, then RegY=2344 staa 4,Y- [2345]=RegA, then RegY=2341 Pre-decrement examples: staa 1,-Y RegY=2344, then [2344]=RegA staa 4,-Y RegY=2341, then [2341]=RegA

7 Lab 2 The code to hand execute $3800 org $3800 $3800 Sum rmb 2 ;16-bit signed result $0003 SIZE equ 3 $4000 org $4000 $4000 CE401A main ldx #Array ;pointer to array $4003 CD0000 ldy #0 ;Sum=0 $4006 7D3800 sty Sum $4009 A630 loop ldaa 1,x+ ;get data from array $400B B704 sex a,d ;promote to 16-bits $400D F33800 addd Sum $4010 7C3800 std Sum ;Sum=Sum+data $4013 8E401D cpx #Array+SIZE $ F1 bne loop ;done? $ E done stop $401A F414D8 Array fcb -12,20,-40 ;array of data $FFFE org $FFFE ;reset vector $FFFE 4000 fdb main

8 Lab 2 Examples of the first 2 instructions. Instruction: ldx #$401F R/W Addr Data Changes R $4000 $CE PC=$4001, IR=$CE R $4001 $40 PC=$4002 R $4002 $1A PC=$4003, X=$401A The second instruction is Instruction: ldy #0 R/W Addr Data Changes R $4003 $CD PC=$4004, IR=$CD R $4004 $00 PC=$4005 R $4005 $00 PC=$4006, Y=$0000 The third instruction is Instruction: sty Sum R/W Addr Data Changes R $4006 $7D PC=$4007, IR=$7D R $4007 $38 PC=$4008 R $4008 $00 PC=$4009, EAR=$3800 W $3800 $00 W $3801 $00

9 Assembly Language Programming Assembly language development editor source code assembler crossassembler object code loader debugger

10 Assembly Language Programming Errors that occur during the assembly process 1) Label previously defined error: label occurs multiple times 2) Undefined opcode error: operation does not exist 3) Operand error: syntax error within the operand expression error undefined symbol in expression addressing mode error size of allocated storage too big, e.g., ds 100*1000 4) Phasing error: value of symbol changes from pass1 to pass2 5) Can't program address error 6) Branch too far error: destination address is too far away 7) Illegal string termination: e.g., "Hello World!

11 Assembly Language Programming Assembler pseudo-ops Pseudo-ops are specific commands to the assembler or assembly directive A B C Meaning org org.org Specific absolute address to put subsequent object code = equ Define a constant symbol set Define or redefine a constant symbol dc.b db fcb.byte Allocate byte(s) of storage with initialized values fcc Create an ASCII string (no termination character) dc.w dw fdb.word Allocate word(s) of storage with initialized values dc.l dl.long Allocate 32-bit long word(s) of storage with initialized values ds ds.b rmb.blkb Allocate bytes of storage without initialization ds.w.blkw Allocate bytes of storage without initialization ds.l.blkl Allocate 32-bit words of storage without initialization end end.end Signifies the end of the source code (TExaS ignores these)

12 Assembly Language Programming Equate symbol to a value <label> equ <expression> (<comment>) <label> = <expression> (<comment>) Redefinable equate symbol to a value <label> set <expression> (<comment>) More information about local variables in Chapter 8. Form constant byte (<label>) fcb <expr>(,<expr>,...,<expr>) (<label>) dc.b <expr>(,<expr>,...,<expr>) (<label>) db <expr>(,<expr>,...,<expr>) (<label>).byte <expr>(,<expr>,...,<expr>) str1 fcb "Hello World",0 Str2 fcb Hello World,0 str3 fcb \Hello World\,0

13 Assembly Language Programming Form constant character string (<label>) fcc <del><string><del> LABEL1 FCC 'ABC' LABEL2 fcc "Jon Valvano " LABEL4 fcc \Welcome to FunCity!\ Form double byte (<label>) fdb <expr>(,<expr>,...,<expr>) (<label>) dc.w <expr>(,<expr>,...,<expr>) (<label>) dw <expr>(,<expr>,...,<expr>) (<label>).word <expr>(,<expr>,...,<expr>) org $FFFE fdb main Define 32-bit constant (<label>) dc.l <expr>(,<expr>,...,<expr>) (<label>) dl <expr>(,<expr>,...,<expr>) (<label>).long <expr>(,<expr>,...,<expr>) S1 dl ,$ S2.long 1,1000, , S3 dc.l -1,0,1

14 Assembly Language Programming Set program counter origin org <expression> (<comment>).org <expression> (<comment>) Reserve multiple bytes (<label>) rmb <expression> (<comment>) (<label>) ds <expression> (<comment>) (<label>) ds.b <expression> (<comment>) (<label>).blkb <expression> (<comment>) Reserve multiple words (<label>) ds.w <expression> (<comment>) (<label>).blkw <expression> (<comment>) ds.l Reserve multiple 32-bit words (<label>) ds.l <expression> (<comment>) (<label>).blkl <expression> (<comment>) End of program (optional) end (<comment>).end (<comment>)

15 16 bit timers The register interfaces Addr Bit Bit 0 Name $0044 Bit Bit 8 TCNT $0045 Bit Bit 0 TCNT $0046 TEN TSWAI TSFRZ TFFCA TSCR1 $004D TOI TCRE PR2 PR1 PR0 TSCR2 $004F TOF TFLG2 PR2 PR1 PR0 Divide by TCNT clock w/4 MHz clk TCNT clock w/24 MHz clk ns 42 ns ns 84 ns µs 168ns µs 333ns µs 667ns µs 1.33 µs µs 2.67 µs µs 5.33 µs

16 Timers Timer_Wait EndT=TCNT+input positive EndT-TCNT negative rts ****Timer_Wait********** * Time delay function * Input: RegD is the time to wait * (in 125ns cycles) * Outputs: none * error: input must < Timer_Wait addd TCNT value at end Wloop cpd TCNT EndT<Tcnt? bpl Wloop rts

17 Timers Fixed time delay using the timer ****Timer_Init********** * Initialize Timer * Input: none * Outputs: none * error: none Timer_Init movb #$80,TSCR1 enable TCNT rts ****Timer_Wait********** * Time delay function * Input: RegD time to wait (125ns cycles) * Outputs: none * error: input must be less than Timer_Wait adddtcnt TCNT at end of delay Wloop cpd TCNT is EndT<TCNT bpl Wloop rts Examples, assume TCNT = 31 (can be any value), Reg D = 4000 (means 1ms, in 250-ns units) the addd will make RegD = 4031 (remains fixed for the rest of the subroutine)

18 Timers Real time systems Bounded latency Input interface: input interface latency RDRF -> Read SCIDRL Output interface: output interface latency TDRE -> Write SCIDRL Periodic process (square wave, Labs 7 and 9): software activity occurs at a periodic rate, Dt let t n be the nth time the process executes goal to make t n t n-1 = Dt dt=jitter Dt-dt < t i t i-1 < Dt+dt for all i

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

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

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

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

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

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

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

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE EE319 K Lecture 3 Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator University of Texas ECE Introduction (von Neumann architecture) processor Bus Memory Mapped I/O System Input Devices

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

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

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

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

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume.

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume. ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume Timers Lecture Outline General Description of Main Timer Input Capture Concept

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

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

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff CodeWarrior 1 Assembler An assembler is a program that translates assembly language into machine code. Machine code are the numbers that the CPU recognizes as instructions. $B6 $10 $00 Assembly language

More information

m 1 se 7 m 23 Introduction to Embedded Microcomputer Systems Lecture 16.1 Recap Finite State Machines Pointer implementation

m 1 se 7 m 23 Introduction to Embedded Microcomputer Systems Lecture 16.1 Recap Finite State Machines Pointer implementation Introduction to Embedded Microcomputer Systems Lecture 16.1 Recap Finite State Machines Pointer implementation Overview Fixed-point: why, when, how Local variables: scope and allocation How these concepts

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

EE 308 Spring A software delay

EE 308 Spring A software delay A software delay To enter a software delay, put in a nested loop, just like in assembly. Write a function delay(num) which will delay for num milliseconds void delay(unsigned int num) volatile unsigned

More information

ECE 367 -Experiment #1 Fall 2012

ECE 367 -Experiment #1 Fall 2012 Due at the beginning of lab during week 3 (9/1/2012) Introduction ECE 367 -Experiment #1 Fall 2012 The goal of this experiment is the acquaint you with the Technological Arts nanocore12 microcontroller

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

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

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

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram History of the Microprocessor ECE/CS 5780/6780: Embedded System Design Chris J. Myers Lecture 1: 68HC12 In 1968, Bob Noyce and Gordon Moore left Fairchild Semiconductor and formed Integrated Electronics

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

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

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

Macro Assembler. Defini3on from h6p://www.computeruser.com

Macro Assembler. Defini3on from h6p://www.computeruser.com The Macro Assembler Macro Assembler Defini3on from h6p://www.computeruser.com A program that translates assembly language instruc3ons into machine code and which the programmer can use to define macro

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

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

Program Development. Chapter 5

Program Development. Chapter 5 Chapter 5 Program Development Expected Outcomes Distinguish between various codes in the programming language Explain the role of assembler and compiler Distinguish between different data types Use directive

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

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

MC9S12 Address Space

MC9S12 Address Space MC9S12 Address Space MC9S12 has 16 address lines MC9S12 can address 2 16 distinct locations For MC9S12, each location holds one byte (eight bits) MC9S12 can address 2 16 bytes 2 16 = 65536 2 16 = 2 6 2

More information

EE 308 Spring Exam 1 Feb. 27

EE 308 Spring Exam 1 Feb. 27 Exam 1 Feb. 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 and

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

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

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

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

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

Menu. >Debugging/Simulating in Atmel Studio >Downloading and Debugging/Emulating with the UF-board. Machine Codes 6811: $86 $0A GCPU: $02 $0A

Menu. >Debugging/Simulating in Atmel Studio >Downloading and Debugging/Emulating with the UF-board. Machine Codes 6811: $86 $0A GCPU: $02 $0A Big Picture Assembler Directives Examples using: Menu >Debugging/Simulating in Atmel Studio >Downloading and Debugging/Emulating with the UF-board Look into my... See on web-site: GCPU_to_XMEGA.pdf, Examples:

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

ECE/CE 3720: Embedded System Design

ECE/CE 3720: Embedded System Design Basic Components of Input Capture Slide 1 ECE/CE 3720: Embedded System Design Chris J. Myers Lecture 12: Input Capture Slide 3 Basic Principles of Input Capture Basic Principles of Input Capture (cont)

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

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

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

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016 Lecture #4 Microcontroller Instruction Set 2 18-348 Embedded System Engineering Philip Koopman Monday, 25-Jan-2016 Electrical& Computer ENGINEERING Copyright 2006-2016, Philip Koopman, All Rights Reserved

More information

Lecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015

Lecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015 Lecture #3 Microcontroller Instruction Set 18-348 Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015 Electrical& Computer ENGINEERING Copyright 2006-2015, Philip Koopman, All Rights Reserved

More information

Capstone Design Course. Lecture-2: The Timer

Capstone Design Course. Lecture-2: The Timer Capstone Design Course Lecture-2: The Timer By Syed Masud Mahmud, Ph.D. Copyright 2002 by Syed Masud Mahmud 1 The Timer The 68HC11 has a 16-Bit Free Running Timer. The count value of the timer is available

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

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

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

EE319K Laborartory Manual Univ of Texas at Austin Bard, Daniels, Welker Spring 2008

EE319K Laborartory Manual Univ of Texas at Austin Bard, Daniels, Welker Spring 2008 Jonathan W. Valvano Page 1 EE319K Laborartory Manual Univ of Texas at Austin Bard, Daniels, Welker Spring 2008 Table of Contents LAB 1. A DIGITAL LOCK...3 LAB 2 ANALYSIS OF MICROCONTROLLER EXECUTION...5

More information

ECE3120: Computer Systems Chapter 8: Timer Module

ECE3120: Computer Systems Chapter 8: Timer Module ECE32: Computer Systems Chapter 8: Timer Module Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun2 Email: msjeedigun2@tntech.edu Tel: 93-372-68, Prescott Hall 2 Why are Timer Functions Important?

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

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

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

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

ECE/CE 3720: Embedded System Design

ECE/CE 3720: Embedded System Design Sequence of Events During Interrupt 1. Hardwere needs service (busy-to-done) transition. 2. Flag is set in one of the I/O status registers. (a) Interrupting event sets the flag (ex., STAF=1). Slide 1 ECE/CE

More information

ECE/CS 3720: Embedded System Design (ECE 6960/2 and CS 6968)

ECE/CS 3720: Embedded System Design (ECE 6960/2 and CS 6968) Sequence of Events During Interrupt 1. Hardwere needs service (busy-to-done) transition. 2. Flag is set in one of the I/O status registers. (a) Interrupting event sets the flag (ex., STAF=1). Slide 1 ECE/CS

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

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

Homework 12 Solutions

Homework 12 Solutions Page 1/6 1. Here is a short program that shows all addressing modes: We are given a table of student's test scores where there are three scores in a semester per student. Unfortunately, the person who

More information

CS/ECE 5780/6780: Embedded System Design

CS/ECE 5780/6780: Embedded System Design CS/ECE 5780/6780: Embedded System Design John Regehr Lecture 2: 68HC12 Architecture & Lab 1 Introduction Duff s Device void foo (int x, int *y, int *z) { switch (x % 8) { case 0: do { *y++ = *z++; case

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

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

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly. More on Programming the 9S12 in C Huang Sections 5.2 through 5.4 Introduction to the MC9S12 Hardware Subsystems Huang Sections 8.2-8.6 ECT_16B8C Block User Guide A summary of MC9S12 hardware subsystems

More information

EE251: Tuesday September 5

EE251: Tuesday September 5 EE251: Tuesday September 5 Shift/Rotate Instructions Bitwise logic and Saturating Instructions A Few Math Programming Examples ARM Assembly Language and Assembler Assembly Process Assembly Structure Assembler

More information

Computer Organization I. Lecture 28: Architecture of M68HC11

Computer Organization I. Lecture 28: Architecture of M68HC11 Computer Organization I Lecture 28: Architecture of M68HC11 Overview Architecture of HC11 Microprocessor Format of HC11 Assembly Code Objectives To understand the simplified architecture of HC11 To know

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

ARM Cortex-M4 Architecture and Instruction Set 3: Branching; Data definition and memory access instructions

ARM Cortex-M4 Architecture and Instruction Set 3: Branching; Data definition and memory access instructions ARM Cortex-M4 Architecture and Instruction Set 3: Branching; Data definition and memory access instructions M J Brockway February 17, 2016 Branching To do anything other than run a fixed sequence of instructions,

More information

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets ME645 Introduction to Mechatronics Fall 24 Instructor: Professor Charles Ume Interrupts and Resets Reason for Interrupts You might want instructions executed immediately after internal request and/or request

More information

What happens when an HC12 gets in unmasked interrupt:

What happens when an HC12 gets in unmasked interrupt: What happens when an HC12 gets in unmasked interrupt: 1. Completes current instruction 2. Clears instruction queue 3. Calculates return address 4. Stacks return address and contents of CPU registers 5.

More information

ECE 3610 MICROPROCESSING SYSTEMS

ECE 3610 MICROPROCESSING SYSTEMS 24.361 Lab. 4 31 ECE 3610 MICROPROCESSING SYSTEMS Laboratory 4 LAB 4: ASSEMBLER DIRECTIVES, THE STACK, SUBROUTINES, AND BUBBLE SORTING 1 INTRODUCTION This lab deals with the use of the stack and subroutines

More information

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING CHAPTER 2 8051 ASSEMBLY LANGUAGE PROGRAMMING Registers Register are used to store information temporarily: A byte of data to be processed An address pointing to the data to be fetched The vast majority

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

Introduction to Embedded Systems. Some Nagging

Introduction to Embedded Systems. Some Nagging Introduction to Embedded Systems CS/ECE 6780/5780 Al Davis Today s topics: some logistics nagging assembly language programming 1 CS 5780 Some Nagging Apparently necessary several students do not yet have

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

Microcontrollers. Microcontroller

Microcontrollers. Microcontroller Microcontrollers Microcontroller A microprocessor on a single integrated circuit intended to operate as an embedded system. As well as a CPU, a microcontroller typically includes small amounts of RAM and

More information

Lecture #13 Interrupts Embedded System Engineering Philip Koopman Monday, 29-Feb-2016

Lecture #13 Interrupts Embedded System Engineering Philip Koopman Monday, 29-Feb-2016 Lecture #13 Interrupts 18-348 Embedded System Engineering Philip Koopman Monday, 29-Feb-2016 Electrical& Computer ENGINEERING Copyright 2006-2016, Philip Koopman, All Rights Reserved Example: Electronic

More information

8.7. Finite state machines with statically-allocated linked structures Stepper motor controller L 293

8.7. Finite state machines with statically-allocated linked structures Stepper motor controller L 293 Introduction to Embedded Microcomputer Systems Lecture 23.1 8.7. Finite state machines with statically-allocated linked structures Stepper motor controller Inputs: Go and Turn Outputs: two 4-wire bipolar

More information

OSIAC Read OSIAC 5362 posted on the course website

OSIAC Read OSIAC 5362 posted on the course website OSIAC 5362 Read OSIAC 5362 posted on the course website The Basic Structure of Control Unit m CLK Run/Inhibit Control Step Counter m Preset (to any new state) Reset IR Decoder/Encoder (combinational logic)

More information

EB301. Motorola Semiconductor Engineering Bulletin. Programming EEPROM on the MC68HC811E2 during Program Execution. Freescale Semiconductor, I

EB301. Motorola Semiconductor Engineering Bulletin. Programming EEPROM on the MC68HC811E2 during Program Execution. Freescale Semiconductor, I Order this document by /D Motorola Semiconductor Programming EEPROM on the MC68HC811E2 during Program Execution By Brian Scott Crow Austin, Texas Introduction The Problem The MC68HC811E2 microcontroller

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

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#: Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators

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

Lab Cover Page. Lab Date and Time: Teaching Assistant to whom you are submitting

Lab Cover Page. Lab Date and Time: Teaching Assistant to whom you are submitting Student Information First Name School of Computer Science Faculty of Engineering and Computer Science Last Name Student ID Number Lab Cover Page Please complete all fields: Course Name: Structure and Application

More information

COSC345 Software Engineering. Basic Computer Architecture and The Stack

COSC345 Software Engineering. Basic Computer Architecture and The Stack COSC345 Software Engineering Basic Computer Architecture and The Stack Outline Architectural models A little about the 68HC11 Memory map Registers A little bit of assembly (never did us any harm) The program

More information

Quick Guide to Using Code Warrior

Quick Guide to Using Code Warrior Quick Guide to Using Code Warrior So now that you have created a project, you are going to want to write an assembly program and assemble (compile) it. When you create a project a new panel appears on

More information

Input and Output Ports. How do you get data into a computer from the outside?

Input and Output Ports. How do you get data into a computer from the outside? Input and Output Ports How do you get data into a computer from the outside? SIMPLIFIED INPUT PORT D 7 Any read from address $0000 gets signals from outside H C 2 D a t a D D D4 D3 S i g n a l s F r o

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

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

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

EE345L Spring 2006 May 10, 2006, 2-5pm Page 1 of 8

EE345L Spring 2006 May 10, 2006, 2-5pm Page 1 of 8 EE345L Spring 2006 May 10, 2006, 2-5pm Page 1 of 8 Jonathan W. Valvano You can use the textbook, but no other materials. You must put your answers in the boxes on the answer pages. You have 3 hours, so

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

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

; export symbols XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for assembly entry point

; export symbols XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for assembly entry point **************************************************************** * This program for CMPEN 472, Flash Memory Writing * * By Kyusun Choi, ID=0000 * * Date: 11/15/2017 * * Freescale CodeWarrior, for the HCS12C128

More information

ECE 4510/5530 Microcontroller Applications Chapter 1

ECE 4510/5530 Microcontroller Applications Chapter 1 Microcontroller Applications Chapter 1 Dr. Bradley J. Bazuin Associate Professor Department of Electrical and Computer Engineering College of Engineering and Applied Sciences Chapter 1 Overview Basic Computer

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