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

Size: px
Start display at page:

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

Transcription

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

2

3 Reading Assignments Reading assignments for this week and next week Read Chapters 5-8 in Basic Microprocessors and the 6800, by Ron Bishop. Chapter 5 Microcomputers-What Are They? Chapter 6 Programming Concepts Chapter 7 Addressing Modes Chapter 8 M6800 Software There will be questions and answers the rest of this week and next week based on your reading assignment.

4 Why use Assembly Language? HC12S CPU can only understand instructions written in binary called Machine Language. Writing programs in Machine Language is extremely difficult Mnemonics are simple codes, usually alphabetic, that is representative of instruction it represents (example: LDAA [LoaD Accumulator A]) A program written using Mnemonic Instructions is called Assembly Language program An Assembler can be used to translate Assembly Language program to Machine Language Program

5 Assembly Language Notations Address: Common term for memory location. Always written in hexadecimal. $4000 is the 4000 th 16 Memory Location (Note: $ signifies hexadecimal) Literal Value: A number used as data in program indicated by #. Can be represented in the following ways: #$FF = hexadecimal number FF #%1011 = binary number 1011 (Note: % signifies binary) #123 = decimal number 123 A Literal Value can be stored in an address Example: Literal Value #$FF is stored in address $4000 Example 2: Literal Value #$FE0A is stored in address $2000 (Note: #$FE is stored in address $2000 #$0A is stored in address $2001)

6 Assembly Language Directives Directives: Instructions from the programmer to Assembler NOT to microcontroller Example 1: ORG <address> Store translated machine language instructions in sequence starting at given address for any mnemonic instructions that follow Example 2: END Stop translating mnemonics instructions until another ORG is encountered (Note: More will be covered in later lectures)

7 Left margin of assembly program A Tab (8 white spaces) or Label (Note: A Label is another Assembly Directive and will be covered in later lectures) Assembly Language Format Assembly Directive Or Mnemonic Instruction (Note: Last three options are called Operands) Data that the Assembly Directive uses Or Blank if Mnemonic Instruction does not need Data Or Offset Address used to modify Program Counter by a Mnemonic Instruction Or Data that Mnemonic Instruction uses Or Address where the Data that Mnemonic Instruction will use is stored

8 In the previous slide, there were several options for the operand: Blank if Mnemonic Instruction does not need Data Offset Address used to modify Program Counter by a Mnemonic Instruction Data that Mnemonic instruction uses Address were Data that Mnemonic instruction uses is stored Which option a programmer uses is defined by the following addressing modes: Inherent Immediate Extended Addressing Modes Direct Indexed Relative Indexed Indirect (Note: All instructions are not capable of all addressing modes. Example: BLE [Branch if Less than or Equal to Zero] is only capable of Relative addressing mode)

9 Example: Programming Reference Guide Page 6

10

11

12

13

14

15 Blank if Mnemonic Instruction does not need Data If Mnemonic Instruction does not need data then it uses Inherent Addressing Mode Example: Write a program to clear accumulator A. Start programming at address $1000 Solution: ORG $1000 CLRA SWI END CLRA [ CLeaR accumulator A] is an instruction using Inherent Addressing (NOTE: SWI [SoftWare Interrupt] is a mnemonic instruction which tells the 9SC32 to store the content of cpu registers on the stack. Sets the I bit (the interrupt bit) on the CCR. Loads the program counter with the address stored in the SWI interrupt vector, and resume program execution at this location. If no address is stored in the SWI vector, the main program will stop execution at this point. Used The George in this W. course Woodruff to return School control of Mechanical to Mon12 Engineering Program)

16 Offset Address used to modify Program Counter by a Mnemonic Instruction If Mnemonic Instruction uses operand to modify Program counter then it uses Relative Addressing Mode Usually used in conjunction with Labels (Note: will be explained further in later lectures)

17 Data that Mnemonic instruction uses The Mnemonic instruction is using Immediate Addressing mode if the operand is Data used by the instruction Example: Write a program to load accumulator A with #$12. Start programming at address $1000 Solution: ORG $1000 LDAA #$12 SWI END LDAA is an instruction using Immediate Addressing mode in this example

18 Address were Data that Mnemonic instruction uses is stored The following addressing modes apply if the operand is an Address containing Data used by Mnemonic instruction : Direct Data is contained in Memory locations $00 to $FF Address is given as a single byte address between $00 to $FF Instructions using Direct addressing has fastest access to memory Example: LDAA $00 Loads accumulator A with Data value stored at memory location $00 Extended Data is contained in Memory locations $0100 to $FFFF Address is given as a two byte address between $0100 to $FFFF Example: LDAA $2000 Loads accumulator A with Data value stored at memory location $2000

19 Example Problem 1 Example : Write a program to add the numbers and Solution ORG $1000 LDAA #$0A *Puts number $0A in acc. A LDAB #$0B *Puts number $0B in acc. B ABA *Adds acc. B to acc. A STAA $00 *Stores results in address $00 SWI *Software interrupt END LDAB and LDAA use immediate addressing mode STAA uses direct addressing mode

20 Address were Data that Mnemonic instruction uses is stored (Continued) Indexed: Data is located within Memory locations $00 to $FFFF Address is given as a address offset between $00 to $FF plus content of the X or Y register Example: LDX #$2000 LDAA $03,X Loads accumulator A with Data value stored at memory location $2003 X + $03 = $ $03 = $2003 (Note: LDX [ LoaD index register X])

21 Why is Indexed Addressing Mode needed? Example: Store Data Value #$20 into memory locations $2000 to $3000 Without Indexed Addressing Mode ORG $1000 LDAA #$20 STAA $2000 STAA $ STAA $3000 SWI END With Indexed Addressing Mode ORG $1000 LDAA #$20 LDX #$2000 LOOP STAA $00,X INX CPX #$3001 BNE LOOP SWI END Program on the Left is much longer than program on Right

22 ORG $1000 LDAA #$20 LDX #$2000 LOOP STAA $00,X INX CPX #$3001 BNE LOOP SWI END Why is Indexed Addressing Mode needed? (Continued) Note: LDX [ LoaD accumulator X] STAA [ STore Accumulator A] INX [ INcrement X] CPX [ ComPare X] BNE [Branch if Not Equal] ( is using relative addressing in conjunction with label LOOP ) LOOP, BNE LOOP, INX, and CPX #$3001 creates a loop. Loop1: Data in accumulator A (#$20) is stored at $ $00 Data in X is incremented #$ #$0001 = #$2001 Data in X is compared to #$3001 Not equal so do another loop Loop2: Data in Accumulator A (#$20) is stored at $2001 Data in X is incremented #$ #$0001 = #$2002 Data in X is compared to #$3001 Not equal so do another loop Etc..

23 Types of Indexed modes of Addressing Indexed addressing may be implemented in multiple ways. The HCS12 CPU uses the X or Y index registers, Stack Pointer or Program Counter as the base index register for the instruction. The offset is then added to the base index register to form an effective address. The different indexed addressing modes are: Constant offset 5-, 9- or 16-bit signed offset The assembler will interpret all hex values < $8000 as positive numbers Hex values with a 1 in the 15 th bit are negative (recall 2 s compliment) The following three statements are equivalent: STAA -8,X Note: offset given in decimal STAA -$08,X Note: offset given in hex STAA $FFF8,X Note: offset given as 16-bit number Accumulator Offset A, B, or D accumulator added to base index register to form address Contents of accumulator is unsigned offset LDAB #$FF STAA B,X Note: Accumulator B is unsigned offset (= ) Value contained in accumulator A is stored in effective address formed by adding 255 The to George contents W. Woodruff of X School of Mechanical Engineering

24 Types of Indexed modes of Addressing - Continued Auto Pre-/Post-Increment/Decrement The base index register may be automatically incremented/decremented before or after instruction (Program Counter may not be used as the base register) No offset is available May be incremented/decremented 1 to 8 times Post-Increment: LDX 2,SP+ Note: Index register X is loaded with the contents of the memory location in the stack pointer, then the stack pointer is incremented twice Pre-Increment: LDX 2,+SP Note: the stack pointer is incremented twice, then Index register X is loaded with the contents of the memory location in the stack pointer Pre-Decrement: STAA 1,-X Note: Index register X is decremented, then the contents of Accumulator A are stored in the memory location contained in Index Register X

25 Why is Pre-/Post-Increment/Decrement Useful? Example: Store Data Value #$20 into memory locations $2000 to $3000 Without Post-Increment ORG $1000 LDAA #$20 LDX #$2000 LOOP STAA $00,X INX CPX #$3001 BNE LOOP SWI END With Post-Increment ORG $1000 LDAA #$20 LDX #$2000 LOOP STAA 1,X+ CPX #$3001 BNE LOOP SWI END Note: 1 refers to the number of post increments, not an offset! Program on the Left requires 1 more byte of program memory and takes 1 more cycle to execute per run through the loop then the program on the right. This may make a large difference when the program is large and complex or when dealing with values larger than 16-bits.

26 Types of Indexed modes of Addressing - Continued Indexed-Indirect Like other indexed addressing modes, an offset and base index register are added to form an effective address However, the effective address is understood to contain the address of the memory location containing the address to be acted upon. Example: Clear the contents of the memory location pointed to by a pointer located in memory location $2000 ORG $2000 PTR RMB 2 *Note: The user places the address of the memory location to be cleared here ORG $1000 LDX $2000 CLR [$00,X] SWI END (Note: CLR [ CLeaR Memory Location]) Useful for efficiently forming switch case statements and other program flow operations The George in high W. Woodruff level programming School of Mechanical languages Engineering

27

28 As stated before the Assembler translates an assembly language program into a machine language program Format of machine language program Address where instruction is located Opcode Instruction Postbyte Operand Or Blank if instruction does not use Operands (Note: This format is for Lecture and Tests only!! The real format the assembler outputs is S19 and will be shown to you in Lab)

29 Postbyte and Opcode Reference All Mnemonics and associated Op-codes can be found in Programming Reference Guide pages 6-19 Example: Programming Reference Guide Page 12 (Note: LDAA outlined in red)

30 Postbyte Postbyte allows an op-code to be used for more than one instruction. Determined from Tables 1, 3 or 4 in the programming reference guide Instruction Opcode Postbyte LDAA 0,X A6 00 LDAA $02,SP+ A6 B1 LDAA B,Y A6 ED SUBB $1040,X E0 E0 SUBB D,Y E0 EE SUBB -14,X E0 12 Table 1 (Excerpt)

31 The George W. Woodruff (Programming School Reference of Mechanical Guide) Engineering

32

33

34

35 Hand Assembling Example: Assemble the following Program ORG $1000 LDAA #$0A LDAB #$0B ABA STAA $00 SWI END Address Opcode Postbyte Operand $ A $1002 C6 0B $ $1006 5A 00 $1008 3F (Note: $1002 since $86 is now at $1000 and $0A is at $1001)

36 Example Problem 1 (revisited) ORG $1000 LDAB #$0A *Load acc. B with number 0A STAB $1100 *Store acc. B in address $1100 INCB *Increment acc. B by 1 ADDB $1100 *Add memory location $1100 *to acc. B STAB $1090 *Store acc. B in address $1090 SWI *Software interrupt END

37 Hand Assemble Example Problem 1 (Revisited) ORG $1000 LDAB #$0A STAB $1100 INCB ADDB $1100 STAB $1090 SWI END Address Opcode Postbyte Operand 1000 C6 0A B FB B B 3F

38 Example Problem 2 Write a short assembly language program that stores the content of Port T in memory location $3000 after waiting for 0.05 seconds for the input data. Solution Recall: One machine cycle = x 10-6 s (8 MHz Bus Clock) We want the HCS12 to wait 0.05 s/0.125 x 10-6 s = 400,000 cycles One good way to make the HCS12 wait is to create a loop.

39 Wait Loop LDY #$C34F 2 cycles LDD #$ cycles LOOP ABA 2 cycles CPX $ cycles DEY 1 cycle BNE LOOP 3 cycles Note: These instructions are included to increase the operation time Assume the number of loops needed to wait is 2 bytes ( )*X + 4 = 400,000 cycles X = 44, = $AD9C

40 Example 2 Solution Solution *Remember that Port T is input upon reset ORG $1000 LDY #$C34F *Load Y with 44, LDD #$0000 *Clear Accumulator D LOOP ABA *Add the contents of B to A CPX $2000 *Compare X with the contents of *$2000 DEY *Decrement Y BNE LOOP *Branch to LOOP if Y is not equal *to zero LDAB $0240 *Load acc. B with content of $0240 STAB $0020 $3000 *Store content of acc. B in SWI *Software Interrupt END

41 Homework Homework 1 Write an assembly language program to clear the internal RAM in the MC9S12C32. Write a program to add even/odd numbers located in addresses $0800 through $0900. Homework 2 Write a program to find the largest signed number in a list of numbers stored in address $0A00 through $0BFF. Repeat for an unsigned number.

42 QUESTIONS???

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

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

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

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

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

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

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

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

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

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

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

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

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

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 6 MC9S12C Microcontroller Covered in Lecture 5: Quick Introduction

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

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

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

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

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

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

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

Introduction to Programming

Introduction to Programming Introduction to Programming Chapter 2 Microcontrollers Objectives Describe the difference between source code and machine code. Define opcode, operand, and address of an operand. Explain the purpose of

More information

What is an Addressing Mode?

What is an Addressing Mode? Addressing Modes 1 2 What is an Addressing Mode? An addressing mode is a way in which an operand is specified in an instruction. There are different ways in which an operand may be specified in an instruction.

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

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

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

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

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

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE The purpose of this lab is to introduce you to the layout and structure of Assembly Language programs and their format. You will write your own programs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Getting Started with the HCS12 IDE

Getting Started with the HCS12 IDE Getting Started with the HCS12 IDE B. Ackland June 2015 This document provides basic instructions for installing and using the MiniIDE Integrated Development Environment and the Java based HCS12 simulator.

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

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

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

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

538 Lecture Notes Week 1

538 Lecture Notes Week 1 538 Clowes Lecture Notes Week 1 (Sept. 6, 2017) 1/10 538 Lecture Notes Week 1 Announcements No labs this week. Labs begin the week of September 11, 2017. My email: kclowes@ryerson.ca Counselling hours:

More information

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud. Chapter 1 Microprocessor architecture ECE 3130 Dr. Mohamed Mahmoud The slides are copyright protected. It is not permissible to use them without a permission from Dr Mahmoud http://www.cae.tntech.edu/~mmahmoud/

More information

Introduction to CPU architecture using the M6800 microprocessor

Introduction to CPU architecture using the M6800 microprocessor Introduction to CPU architecture using the M6800 microprocessor Basics Programs are written in binary object codes which could be understood (after the decoding process) by the designated target CPU. The

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

CHAPTER 8. Solutions for Exercises

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

More information

Chapter 1 Microprocessor architecture ECE 3120 Dr. Mohamed Mahmoud http://iweb.tntech.edu/mmahmoud/ mmahmoud@tntech.edu Outline 1.1 Computer hardware organization 1.1.1 Number System 1.1.2 Computer hardware

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 317 Microcontroller Applications Lecture 5 : Instruction Subset & Machine Language: Introduction to the Motorola 68HC11 - Miller 2.1 & 2.2 Based on slides for ECE317 by Profs. Davis, Kieckhafer, Tan,

More information

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming Laboratory: Introduction to Mechatronics Instructor TA: Edgar Martinez Soberanes (eem370@mail.usask.ca) 2015-01-12 Lab 2. PIC and Programming Lab Sessions Lab 1. Introduction Read manual and become familiar

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

Wed. Aug 23 Announcements

Wed. Aug 23 Announcements Wed. Aug 23 Announcements Professor Office Hours 1:30 to 2:30 Wed/Fri EE 326A You should all be signed up for piazza Most labs done individually (if not called out in the doc) Make sure to register your

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

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

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

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

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

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

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

EMCH 367 Fundamentals of Microcontrollers Example7 EXAMPLE 7

EMCH 367 Fundamentals of Microcontrollers Example7 EXAMPLE 7 EXAMPLE 7 OBJECTIVE This simple example has the following objectives: Introduce 2-digit hex arithmetic with carry Introduce the lost carry concept Introduce MSB carry PROGRAM Ex7.asm program performs the

More information

Chapter 7 Central Processor Unit (S08CPUV2)

Chapter 7 Central Processor Unit (S08CPUV2) Chapter 7 Central Processor Unit (S08CPUV2) 7.1 Introduction This section provides summary information about the registers, addressing modes, and instruction set of the CPU of the HCS08 Family. For a more

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

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

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

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

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

ECE/CE 3720: Embedded System Design

ECE/CE 3720: Embedded System Design Produce-Consumer Examples Slide 1 ECE/CE 3720: Embedded System Design Chris J. Myers Slide 3 Source/producer Keyboard input Program with data Sink/consumer Program that interprets Printer output Lecture

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

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

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

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

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

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

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

CPU12 REFERENCE MANUAL

CPU12 REFERENCE MANUAL CPU12 REFERENCE MANUAL Motorola reserves the right to make changes without further notice to any products herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its

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

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING Experiment PCO: Principles of Computer Operation Location: Part I Lab., CYC 102. Objective: The objective is to learn the basic

More information

Assembly Language programming (1)

Assembly Language programming (1) EEE3410 Microcontroller Applications LABORATORY Experiment 1 Assembly Language programming (1) Name Class Date Class No. Marks Familiarisation and use of 8051 Simulation software Objectives To learn how

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

ECE 331: PC Lab 3 Stack and Subroutines

ECE 331: PC Lab 3 Stack and Subroutines ECE 331: PC Lab 3 Stack and Subroutines Professor Andrew Mason Michigan State University Rev: S11 p.1 Announcements Objectives Topics Outline Review starting and using ASM development environment Pushing

More information

8051 Overview and Instruction Set

8051 Overview and Instruction Set 8051 Overview and Instruction Set Curtis A. Nelson Engr 355 1 Microprocessors vs. Microcontrollers Microprocessors are single-chip CPUs used in microcomputers Microcontrollers and microprocessors are different

More information

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

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

More information

ELEG3924 Microprocessor

ELEG3924 Microprocessor Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.2 Assembly Language Programming Dr. Jing Yang jingyang@uark.edu 1 OUTLINE Inside 8051 Introduction to assembly programming

More information

Example Programs for 6502 Microprocessor Kit

Example Programs for 6502 Microprocessor Kit Example Programs for 6502 Microprocessor Kit 0001 0000 0002 0000 GPIO1.EQU $8000 0003 0000 0004 0000 0005 0200.ORG $200 0006 0200 0007 0200 A5 00 LDA $0 0008 0202 8D 00 80 STA $GPIO1 0009 0205 00 BRK 0010

More information