Outline. 2.8 Stack. 2.9 Subroutines
|
|
- Pamela Waters
- 6 years ago
- Views:
Transcription
1 Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27 Bit test and manipulate instructions 28 Stack 29 Subroutines
2 - Stack is a section of the memory reserved for special use - Elements can be accessed (read/write) from only its top - Last-in-first-out (LIFO) data structure Stack new top $1005 $1006 $1007 $1008 EF B1 F2 A5 Read: $EF $1006 $1007 $1008 B1 F2 A5 Much like a variable-length array $1007 $1008 F2 A5 $1006 $1007 $1008 FC F2 A5 2-97
3 How the stack can be implemented? - The stack pointer (SP) points at the top byte of the stack - A stack grows from a high address toward lower address - Push operation adds a new item on the top of the stack (write) 1- SP is decremented by the number of bytes to be written to point to the new top of the stack 2- Write on the location pointed by SP - Pull operation reads (= remove) an element from stack 1- Read the byte (or word) pointed by SP 2- SP is incremented by the number of bytes read to point to the new top of the stack $1005 Push (write) $1006 B1 SP $1007 $1008 F2 A5 Pull (read) 2-98
4 Pushing and pulling a byte $1005 $1006 $1007 $1008 EF B1 F2 A5 SP=$1006 $1005 $1006 $1007 $1008 Initial stack EF SP = $1005 B1 F2 A5 SP points at the top of stack SP = $ A = [SP] = EF 2- SP = SP +1 = $1006 A new top of stack $1004 C1 SP=$1004 $1005 EF $1006 $1007 B1 F2 $1008 A5 1- SP = SP - 1 = $ [SP] = A = C1 A new top of stack 2-99
5 Pushing and pulling a word $1005 EF $1006 B1 $1007 F2 SP $1008 A5 Initial stack $1005 EF $1006 B1 $1007 F2 $1008 A5 SP 1- X = [SP]: [SP+1] = EFB1 2- SP = SP + 2 = $1007 A new top of stack SP points at the top of stack SP = $1005 $1003 3F SP $1004 5C $1005 EF 1- SP = SP - 2 = $1003 $1006 B1 2- [SP]: [SP+1] = X = 3F5C $1007 F2 A new top of stack $1008 A
6 - Push and Pull instruction (except for Pulc) do not affect on CCR bits - Push and Pull all the registers except the SP - There is no push or pull for memory 2-101
7 Example: What is the stack contents after the execution of the following instruction sequence lds #$1006 ;SP = 1006 initial value ldaa #$20 ; A = $20 psha ;SP = SP -1 = 1005 and [SP] = A ldab #$28 ; B = $28 pshb ;SP = SP -1 = 1004 and [SP] = B ldx #$FF3A ; X = $FF3A pshx ; SP = SP - 2 = 1002 and [SP] = X $1002 $FF 0 SP SP = (= $1002 $14FC) $1003 $1004 $1005 $3A 0 $28 $20 $1006 lds instruction is used to initialize SP at the beginning of a program 2-102
8 Another example: See how SP and the stack contents change after push and pull operations From the example, observe 1- The stack returns to its initial contents when we pull the same amount of data we pushed 2- When the order of the pull operations is the opposite of those of the push operations, the registers get their initial values If you need to use registers but you do not want to lose their contents, save them in stack, use then and then return the original values 2-103
9 Common uses of stacks 1- Temporary data storage - The number of the registers is very limited - If you want to use a register but you need its value for a later use, you can save the value temporarily on the stack and retrieve it later See previous slide psha ;save the contents of A ; use A in computations pula ;restore the initial content of A 2- Subroutine calls The details will be in the next section 3- Swap and reverse the order of data Stack contents are retrieved in the reverse order from which they were placed onto the stack psha pshb pula pulb Swap a and b 2-104
10 The memory is used for data, program and stack If you push or pull too many, the processor writes in locations outside the area allocated to the stack the program may crash because you mistakenly write in the area of the data or the program Memory management is the responsibility of the programmer No hardware enforces the stack boundary It is the programmer responsibility to keep the SP within the stack area 2-105
11 Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27 Bit test and manipulate instructions 28 Stack 29 Subroutines
12 What is a Subroutine? - It is usual that a sequence of instructions needs to be executed in several places in the program -Ifwewritethesamecodeeachtimeitisneededtheprogramsize will be large - Subroutine is a group of instructions that is written in memory only once and can be called (executed) multiple times from anywhere in the program Why subroutines? - Save memory - Improve reusability of code: Subroutines can be used in different programs - Better organization/readability: A complicated program can be more organized with subroutines However, program execution time increases 2-106
13 Program memory A sequence of instructions (1) call A mechanism is need to: 1- Call 2- Return 3- Pass data 4- Return data (results) (5) (3) call subroutine (4) (2) Return Without subroutines Write the code each time it is needed The program flow with using a subroutine 2-107
14 1- Calling a subroutine bsr subroutine_label ;branch to subroutine The subroutine location should be in the range of -128 to +127 bytes from the instruction immediately after bsr jsr subroutine_label ;jump to subroutine The subroutine location can be anywhere in the memory How bsr and jsr work? 1- Save the return address that points to the next instruction after bsr or jsr Push PC onto the stack PC contains the address of the instruction following the jsr or bsr (the return address) 2- jump to the subroutine Load PC with the subroutine starting address At the beginning of a subroutine, the top of the stack always contains the return address 2-108
15 2- Returning from a subroutine rts ;Return from subroutine - The last instruction in a subroutine - It returns to the instruction immediately after the calling instruction - Restore the return address from stack and load it in PC When executing rts, the top of stack should contain the returning address, otherwise the program will crash To ensure that: the amount of pushed data in a subroutine should equal the amount of pulled data SP PCH PCL The stack after executing bsr and before executing rts PCH is the most significant byte in PC PCL is the least significant byte in PC 2-109
16 A good programming habit that can reduce the chance of errors Sub2: psha pshb pshc pushx ldda $1000 psha Store the register (and memory) you use in the subroutine bsr Sub1 Sub1 does not change the values stored in flags, registers or memory Local variable: Use A, B, the flags, X and location $1000 pula sta $1000 pulx pulc pulb Pula rts Notice the order Restore original values before returning This can be done in the program instead of the subroutine Use push instructions before bsr and pull instructions after bsr 2-110
17 3- Passing/returning data - Subroutines usually expect inputs from the caller of the subroutine, and the caller usually expects the subroutine to return certain results Parameter passing techniques: 1- Passing parameters using memory: The caller sets memory locations and the callee reads them Example: movb #2,$1000 movb #4,$1001 bsr addition The caller stores the data in memory locations, eg, $1000 and $1001 addition: ldaa $1000 adaa $1001 rts The subroutine reads the data from memory locations, eg, $1000 and $
18 2- Passing parameters using registers The caller sets registers and the callee reads them Example: ldaa #2 ldab #4 bsr addition The caller stores the data in registers, eg, a and b addition: aba rts The subroutine reads the data from the registers Parameter returning techniques: 1- Using memory: The subroutine places the results in memory and the caller reads them 2- Using registers: The subroutine places the results in registers and the caller reads them 2-112
19 Example: Draw the stack for the following program segment ldd #$1234 pshd ldx #$4000 pshx jsr sub_xyz sub_xyz: pshd pshx pshy (1) (2) (3) (4) (5) (6) (6) (5) (4) (3) (2) (1) Remember: when executing rts, the top of the stack must be the return address 2-113
20 Example on using lookup tables Write a subroutine Square to square an input number The number to be squared (assumed unsigned) is passed in A The result is returned in A If the result is too big to fit in A, return $FF in A What is lookup table? Pre calculate and store all the squared values (not many), and then look up the correct answer based on the input number Lookup tables applications Very useful when the function to be computed is very complicated (eg, sine, log, ), or represents some calibration values (eg, temperature as a function of voltage) 1- Calculate the lookup table values 2- Using indexed addressing, it is easy to get the right value from the table If X = the starting address of the table, and A = the input number (ie, 0 to 15), then ldaa a,x will fetch the square value 2-114
21 Pseudocode If (A > 15) Load A with $FF Else Load A with the value in the table, at the location indexed by X+A End ldaa #7 X jsr Square ;Call subroutine to compute the square of A ;A = 49, the square of Square: pshx ; save the content of X because it used by the subroutine ldx #Square_table ;x = Starting address of the lookup cmpa #15 ;Check if A > 15 bhi toobig ;Branch if A > 15 ldaa a,x ;A <= 15, so get the result bra _End toobig: ldaa #$FF ;Signal overflow with $FF _End: pulx rts Square_table dcb 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,255 X+0 X+1 X+2 X
22 Write a subroutine that returns FF if two strings are identical and 00 if they are not The beginning addresses of the strings are X and Y and the result is passed at memory location $1200 Each string ends with 0 string1 fcc Tennesee Tech University, 0 string1 fcc TN Tech University, ldx #string2 ldy #string1 bsr check_strings ---- check_strings: movb #$FF,$1200 ;Result = FF assume the two strings are identical Loop: ldaa 0,x+ ;a = the first byte of String1, x = x+1 ldab 0,y+ ;b = the first byte of String2, y = y+1 cba bne not_identical ;String1<>String2 if one byte is not equal ; the loop ends when a = b = 0 cmpa #0 ; enough to check a because a = b beq _end ; if a = 0, b = 0 because they are equal bra Loop not_identical: movb #$00,$1200 ;Result = 00 the strings are different _end: rts 2-116
23 Mohamed Mahmoud Questions
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 informationUsing 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 informationLecture 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 informationSample 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 informationCOSC345 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 informationExam 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 informationTable 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 informationCOE538 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 informationCHAPTER 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 information2. 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 informationIntroduction to Embedded Microcomputer Systems Lecture 10.1
Introduction to Embedded Microcomputer Systems Lecture 10.1 Recap Switch, LED interface Real board debugging if-then statements Overview Successive refinement Modular programming Subroutines, parameter
More informationExam 2 E2-1 Fall Name: Exam 2
Exam 2 E2-1 Fall 2004 1. Short Answer [20 pts] Exam 2 a. [4 points] Show the contents of registers A, B, SP, and X after the following code executes: lds #$a00 ldab #$23 A = ldaa #$87 ldx #$2543 B = pshd
More informationThe 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 informationBRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0
Midterm Review 1. Branch instructions BHI (unsigned), BGT (signed) Take a look at the preceding comparison instruction. Then, you can use this instead of using complex formula in the instruction reference.
More informationDisassembly 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 informationDisassembly 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 informationChapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh
Chapter 4: Advanced Assembly Programming EE383: Introduction to Embedded Systems University of Kentucky Samir Rawashdeh With slides based on material by H Huang Delmar Cengage Learning Chapter Summery
More informationMC9S12 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 informationLecture #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 informationm 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 information538 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 informationECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming
Assembly Programming HCS12 Assembly Programming Basic Assembly Programming Top Assembly Instructions (Instruction You Should Know!) Assembly Programming Concepts Assembly Programming HCS12 Assembly Instructions
More informationModule 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function
Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs
More informationModule 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 informationAddressing Mode Description Addressing Mode Source Format Abbrev. Description
Addressing Mode Description Addressing Mode Source Format Abbrev. Description Inherent INST (no operands) INH Operands (if any) are in CPU registers Immediate INST #opr8i or INST #opr16i IMM Operand is
More informationEE319K 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 informationExam 2 E2-1 Fall Name: Exam 2
Exam 2 E2-1 Fall 2002 1. Short Answer [10 pts] Exam 2 a.[2 pts] Briefly describe what each of the following instructions do so that it is clear what the differences between them are: STAA -2,X STAA 2,-X
More informationModule 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 informationEE 3170 Microcontroller Applications
EE 3170 Microcontroller Applications Lecture 12: Advanced Assembly Language Programming Part II- Stacks Calling Conventions & Base Pointer Usage & Subroutine Examples - Miller 5.5-5.7 Based on slides for
More informationSECTION 6 CENTRAL PROCESSING UNIT
SECTION 6 CENTRAL PROCESSING UNIT This section discusses the M68HC11 central processing unit (CPU), which is responsible for executing all software instructions in their programmed sequence. The M68HC11
More informationExam 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 information0b) [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 informationECE 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 informationCoe538 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 informationC SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions
C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions 1. (12 marks) Circle the correct answer for each of the following: The 8-bit two's complement representation of -15
More informationECE331 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 informationMIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.
MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to
More informationLecture 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 informationSubroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;}
Subroutines Also called procedures or functions Example C code: int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} // subroutine converts Celsius to kelvin int celtokel(int i) { return (i
More informationMicrocontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,
Microcontrollers 2IN60: Real-time Architectures (for automotive systems) Goals for this slide set Describe the architecture of a microcontroller Explain the purpose of an Instruction Set Architecture and
More informationME 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 informationHC11 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 informationReading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions
Reading Assignment EEL 4744C: Microprocessor Applications Lecture 5 68HC12 Instruction Set Software and Hardware Engineering (Old version) Chapter 4 Or Software and Hardware Engineering (New version) Chapter
More informationChapter 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 informationCOSC 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 informationEB301. 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 informationIntroduction 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 informationFri. Aug 25 Announcements
Fri. Aug 25 Announcements HW 1 / Lab 1 next week Tools and fundamentals of instructions Remember no in-lab quiz but HWs still marked Slides online Complete class for last year This year s slides available
More informationMotorola HC11. Fun with Microcontrollers and Embedded Systems
Motorola HC11 Fun with Microcontrollers and Embedded Systems Original Source: http://www.soe.ucsc.edu/classes/cmpe012c/winter04/notes/12_microcontrollers.ppt Microcontrollers What is a microcontroller?
More informationECE 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 informationLab 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 informationHC 11 Instructions! From Alex Hollowayʼs notes with! many thanks!
HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks! Instruction Classes! Accumulator and Memory! Stack and Index Register! Condition Code Register! Program Control! Accumulator and memory
More informationMost 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 informationCPU08RM/AD REV 3 8M68HC08M. CPU08 Central Processor Unit. Reference Manual
CPU08RM/AD REV 3 68HC08M6 HC08M68HC 8M68HC08M CPU08 Central Processor Unit Reference Manual blank CPU08 Central Processor Unit Reference Manual Motorola reserves the right to make changes without further
More informationCross 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 informationCS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri
CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:
More informationELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.
c 2 =1 c 1 =1 c 0 =0 c 2 =1 c 1 =1 c 0 =0 c 4 =0 c 3 =0 c 2 =0 c 1 =0 c 0 =0 c 2 =0 c 1 =0 c 0 =1 c 2 =0 c 1 =0 c 0 =0 ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY Notes - Unit 4
More informationUNIVERSITY 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 informationChapter 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 informationSubroutine. Chapter 8
Chapter 8 Subroutine Expected Outcomes Describe and apply the stack for data storage Describe the process of subroutine in any programs Develop a subroutine and code Interpret subroutine process in the
More information538 Lecture Notes Week 3
538 Lecture Notes Week 3 (Sept. 20, 2017) 1/24 538 Lecture Notes Week 3 Answers to last week's questions 1 Write code so that the least significant bit of Accumulator A is cleared, the most significant
More informationinstruction 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 informationMicrocontrollers. 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 informationMIGRATING 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 informationDecimal, 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 informationME 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 informationCET335 Microprocessor Interfacing Lab 5: LCD Interface (Bus Attached Peripheral)
CET335 Microprocessor Interfacing Lab 5: LCD Interface (Bus Attached Peripheral) Introduction: In this lab, you will learn the interface and operation of a bus-attached peripheral; in other words, a controller
More information2) [ 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 informationHC11 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 informationChapter 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 informationCMPEN 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 informationProgramming 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 informationEE 361 University of Hawaii Fall
C functions Road Map Computation flow Implementation using MIPS instructions Useful new instructions Addressing modes Stack data structure 1 EE 361 University of Hawaii Implementation of C functions and
More informationEE 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 informationLECTURE #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 informationAccumulator and memory instructions 1. Loads, stores, and transfers 2. Arithmetic operations 3. Multiply and divide 4. Logical operations 5. Data test
HC11 Instruction Set Instruction classes 1. 2. 3. 4. Accumulator and Memory Stack and Index Register Condition Code Register Program control instructions 2 1 Accumulator and memory instructions 1. Loads,
More informationHC11 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 informationDepartment of Computer Science and Engineering
Department of Computer Science and Engineering Instruction Set Overview This is a complete overview of the instruction set for the Motorola MC9S12DT256 microprocessor. Some of the groups are irrelevant
More information; 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 informationIntroduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3
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 informationAN1064. Motorola Semiconductor Application Note. Use of Stack Simplifies M68HC11 Programming By Gordon Doughman. Introduction
Order this document by /D Motorola Semiconductor Application Note Use of Stack Simplifies M68HC11 Programming By Gordon Doughman Introduction The architectural extensions of the M6800 incorporated into
More informationEE 42/100 Lecture 25: Binary Signals / Microcontrollers. Rev C 4/26/2012 (9:07 AM) Prof. Ali M. Niknejad
A. M. Niknejad University of California, Berkeley EE 100 / 42 Lecture 25 p. 1/33 EE 42/100 Lecture 25: Binary Signals / Microcontrollers ELECTRONICS Rev C 4/26/2012 (9:07 AM) Prof. Ali M. Niknejad University
More informationDisassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code:
Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code: ADDR DATA ---- ------------------------------------------------------
More informationHomework 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 informationChapter 2A Instructions: Language of the Computer
Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction
More informationMenu 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 informationME4447/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 informationShift and Rotate Instructions
Shift and Rotate Instructions Shift and rotate instructions facilitate manipulations of data (that is, modifying part of a 32-bit data word). Such operations might include: Re-arrangement of bytes in a
More informationCOSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)
COSC 243 Assembly Language Techniques 1 Overview This Lecture Source Handouts Next Lectures Memory and Storage Systems 2 Parameter Passing In a high level language we don t worry about the number of parameters
More informationDo-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero
Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers
More information538 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 informationECE3120: 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 informationIntroduction to 6811 Programming
Introduction to 6811 Programming Fred G. Martin September 9, 2004 Abstract This document provides an overview of the Motorola 68HC11 processor, focusing on programming the E1 series chip using the open-source
More informationEE319K Fall 2007 Quiz 1A Page 1. (5) Question 2. What will be the value of the carry (C) bit after executing the following? ldab #210 subb #60
EE319K Fall 2007 Quiz 1A Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire
More informationControl Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary
Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,
More informationControl Instructions
Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set
More informationCmpt 150 The Freescale CPU12 March, The Freescale HC12
The Freescale HC12 The instruction set architecture that we will use for assembly language programming is the HC12 ISA. Most recently, Freescale Semiconductor manufactured many System on Chip (SoC) implementations
More information538 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 information68HC11 PROGRAMMER'S MODEL
8H11 PROGRMMER'S MODEL s (,, and D) s and are general-purpose 8-bit accumulators used to hold operands and results of arithmetic calculations or data manipulations. Some instructions treat the combination
More information538 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