COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)
|
|
- Amie Strickland
- 5 years ago
- Views:
Transcription
1 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 submissions are allowed.) Topics More Addressing Modes Arithmetic and logic Code Warrior Questions and Answers Indexed Addressing Mode Consider now another problem: We've got a bunch of bytes stored in sequential places in memory We want to add them all up. This calls for some kind of loop. But, unlike the previous situation, the location of the data changes each time through the loop. Extended addressing works when only the data changes (variable i in the previous example) but the address of where to find the data does not change. Indexed addressing solves this problem, First let's phrase the solution to the problem in C: byte data[] = {3, 1, 4, 5, 2, 7, 8}; byte sum = 0; char * nextdata = &data[0]; while (nextdata!= &data[0] + 7) { sum += *nextdata++; } //all done We start by defining our data using a new assembler directive fcb (form constant byte) which reserves a byte of memory and initializes its contents with the specified value: org $3000
2 COE538 Lecture Notes: Week 3 2 of 11 data fcb 3 ;initialize the contents of $3000 to 03 fcb 1 ;initialize the contents of $3001 to 01 fcb 4 fcb 5 fcb 2 fcb 7 fcb 8 sum ds.b 1 ;reserve 1 byte(at $3007) contents UNDEFINED We also introduce a few new instructions: clr address Uses extended addressing to set to zero the contents of the byte at the specified address. ldx operand Loads the 16-bit X register withthe operand which can be specified using immediate, extended or indexed addressing modes. adda 0,x Adds the operand to A. The operand here (0,x) uses indexed addressing which specifies the operand as the contents of the address contained in the X register. cpx operand Compares X with the operand to determine if X is smaller, equal to or bigger than the operand which can be specified using any addressing mode. Compare instructions are usually followed by a conditional branch instruction. We can now write: ldx #data ;initialize X as address of first byte clr sum ;set sum = 0 loop cpx #data+7 ;Compare X with end of data address+1 beq done ;Exit loop if X points past data end ldaa sum ;set sum = sum + *X adda 0,x staa sum inx ;set X = X + 1 (increment X) bra loop ;go back to loop start done:... And, yes, we could have made the loop shorter. But again, the important thing at this point is understanding how assembly language programming works. We'll leave optimization until you have a decent grasp of the basic ideas. (Donald Knuth, an influential computer scientist, once remarked Premature optimization is the root of all evil. ) Addressing mode summary Inherent mode is used when no operand is required. (eg. inca, clra, inx, incb...) Immediate mode (specified by # ) is used when the operand is a constant. Extended mode is used when the operand is a variable but is always found at the same address.
3 COE538 Lecture Notes: Week 3 3 of 11 Indexed mode is used when the address of the operand can change. Arithmetic and logic programming Adding and subtracting and the Condition Code register You can add (subtract) an operand to A, B or D with adda (suba), addb (subb) or addd (subd). Any addressing mode can be used. You can also increment (decrement) by one any of the registers A, B, S, X or Y with instructions inca (deca), incb (decb), ins (des), inx (dex), iny (dey). (But you can only increment D with addd #1.) Suppose you have two variables p, q and sum declared as: p ds.b 1 q ds.b 1 sum ds.b 1 How do you get the contents of sum to be p + q? How about this? adda q staa sum Seems OK. But what if the answer is wrong! At this point you do not have enough information to know if the answer is right or wrong. For example, if p is 0x7f and q is 0x02, the answer will be 0x81. Is this the right answer? It depends! If p and q are meant to represent unsigned integers, then the answer if correct. But if p and q are meant to represent signed integers, the answer is wrong! (The answer would be interpreted as meaning = 127!) Similarly, 0xff + 0xff yields 0xfe which is wrong if the numbers are unsigned (it says = 254) but correct if the numbers are signed (where it says = 2). Ultimately, the problem occurs because when 2 8-bit numbers (signed or unsigned) are added, the result may not fit into 8 bits. Unlike high-level languages (HLL) like C, the assembly language programmer cannot declare variables to be signed or unsigned and let the compiler take care of the details. Rather, assembly language programmers have to keep clear in their own heads whether a variable (the contents of a byte) is to be treated as signed or unsigned. Fortunately, there is hardware in the ALU that detects errors in addition. In particular, a bit in the Condition Code Register (CCR) called the Carry (C) bit indicates if the
4 COE538 Lecture Notes: Week 3 4 of 11 result is incorrect when unsigned numbers are added. Another CCR bit, the Overflow (V) bit, indicates if the result is incorrect when signed numbers are added. In short, here are the two ways to add p and q and determine if the result is correct: ;version for unsigned numbers adda q staa sum bcs unsigned_oops ;Branch if C is set ;version for signed numbers adda q staa sum bvs signed_oops ;Branch if V is set The N Z V and C bits We have now seen conditional branch instructions that use each of these CCR bits. (We will learn about the other 4 bits in the CCR later on in the course.) To summarize: N (Negative) is a copy of the most significant bit an ALU operation. It is used by instructions such as bmi or bpl. Z (Zero) is the NOR of all the result bits. (Hence it is 0 if any of the bits are 1.) It is used in instructions like beq or bne. C (Carry) is a copy of the carry-out of the most significant bit of the adder (ALU). It is used by instructions like bcs (branch if carry set) or bcc (branch if carry clear). V (overflow) is the exclusive-or betwen the carry-in and the carry out of the most significant bit. It is used by instructions like bvs (branch if overflow set) or bvc (branch if overflow clear). Conditionals and loops All programs involve conditions and loops. Consider the pseudo code: if (somthing is true) { do one thing } else { do other thing }
5 COE538 Lecture Notes: Week 3 5 of 11 In general this is translated into assembler as: branch if the "something" is false to else_clause_label do the "then" clause branch to endif_label else_clause_label: do the "else" clause endif_label Example: if (p == q ) p++ else q-- is translated to: cmpa q ;compare a to q setting CCR bits ;this works by computing a q and ;throwing away the answer bne else ;branch if NOT equal to else part inc p ;Increment p using extended addressing bra endif ;branch around the "else" clause else: dec q ;Decrement q using extended addressing endif: ;program continues here It is common for the conditional to involve comparing the sizes of integers. In these cases it is essential that the programmer be clear in their mind whether the numbers are signed or unsigned. Example: unsigned byte p, q; if (p > q ) p = p + q is translated to: endif: Notes: cmpa q bls endif ;branch is less or the same adda q; AccA now p + q staa p ;program continues We branch if (p > q) is false; the opposite of > is <= To branch if <= for unsigned numbers, we use the conditional branch bls. Had p and q been signed numbers, we would have to use ble (branch if less than or
6 COE538 Lecture Notes: Week 3 6 of 11 equal). The following table summarizes how the various signed and unsigned comparisons are used. Comparison Signed Signed Meaning Unsigned Unsigned Meaning > bgt Branch if greater bhi Branch if higher < blt Branch if lesser blo Branch if lower >= bge Branch if greater or equal bhs Branch if higher or same <= ble Branch if less than or equal bls Branch if lower or same Loops are basically: while (condition) { //while_label: if (condition) loop body //loop body } //goto while_label Example: signed byte p, q; while (p > q) { q++; } ;translation to assembler p ds.b 1 q ds.b 1 while: cmpa q ble end_while inc q bra while end_while: ;program continues Example: Counting number of characters in a null-terminated String char * cp = "blah blah"; strlen = 0; while (*cp) { strlen++; cp++; } ;translation to assembler ;NOTE: the address of the character changes ;each time through the loop --> indexed addressing
7 COE538 Lecture Notes: Week 3 7 of 11 ;mode is required ;Rather than keep "cp" in 2 memory bytes, ;we just maintain it in index register X ;Also, we just maintain "strlen" in Acc B. string fcc "blah blah" fcb 0 ;the null terminator ldx #string clrb ;Set Acc B (strlen) to zero while: ldaa 0,x beq end_while incb ;increment strlen leax 1,x ;add 1 to x bra while end_while: Notes: The fcc directive is new. It means "form constant character(s)". It places the ASCII code for each character in a string delimited by double quotes in sequential memory locations. We have only used indexed addressing in the form 0,x so far. This is the most common way to use it, but the 0 can be replaced by a a signed constant. In the form offset,x the effective address of the operand is offset + x. Thus if x is $1000, then ldaa 3,x would load A with the contents of address 0x1003. The instruction leax offset,x (load effective address) loads the effective address (NOT the contents) into X. In short, it adds offset to X. It is also possible to use any of the accumulators (A,B or D) as a variable offset. For example: ldd #$12 addd #2 ldx #$1000 leay d,x ldab 2,y would load Y with 0x1014 and load B with the contents of 0x1016
8 COE538 Lecture Notes: Week 3 8 of 11 Boolean (logic) operations and shifts/rotates In addition to arithmetic, the CPU's ALU (Arithmetic and Logic Unit) can also perform logical operations with instructions like ora, anda and eora perform the bitwise logical OR, AND or XOR between A and the specified operand. The coma instruction inverts each bit in A. An operand (memory or any Accumulator) can be shifted one position to the left or right. The bit shifted out is lost. For left shifts, the bit shifted in is 0. But there are two kinds of right shifts: logical right shift in which a 0 is shifted in. arithmetic right shift in which in which the most significant bit is shifted in. (This ensures that a signed number has the same sign after shifting. To divide a signed number by 2, do a right arithmetic shift; for an unsigned one, do a logical shift.) No bits are lost with a (left or right) rotate. The bit shifted in is the old Carry bit and the bit shifted out becomes the new Carry bit. Multiply and divide There are 3 multiply (8-bit unsigned, 16-bit signed and unsigned) instructions and there are 5 divide instructions. We will only use mul and idiv at this point. How to interpret the Instruction Set Reference Figure 1: Instruction Set Reference for ldaa instruction The Instruction Set Reference (Appendix A of the text and available here) contains a wealth of information presented in a compact fashion. (You will be provided a copy of this during the midterm and final; it is imperative that you learn how to use this reference.) The figure above shows the entry for the ldaa instruction. The first column gives the assembly language syntax for its use in 8 different addressing modes. The Machine Coding column (4 th column) gives the machine language in hexadecimal. The Access Detail column indicates how the bus is used. For our purposes, the number of letters is all that matters for now: this is the number of bus cycles required to fetch and execute
9 COE538 Lecture Notes: Week 3 9 of 11 the instruction. For example, in immediate addressing mode, 1 bus cycle is required while 3 bus cycles are required in the extended addressing mode. The last column (NZVC) indicates if and how these 4 CCR bits are affected by the instruction. In the case of ldaa, the N bit is set to 0 or 1 depending on the value loaded. Similarly, the Z bit is set to 1 if zero is loaded and set to 0 otherwise. The V bit is cleared to 0 unconditionally and the C bit is unaffected. Using Code Warrior Demonstration in class. Subroutines: a first look It's hard to imagine writing even a simple C program as one big "main" function. Programmers split the task into various components (functions). Functions in C also have the huge advantage of being usable many different times in the program. The equivalent of functions at the assembly language level are called subroutines. Like functions, subroutines may require parameters to be passed to them and may return some value. A first look at the Stack In addition to the X and Y index register, the SP register can also be used in indexed addressing. However, the SP has a more important role: it is a pointer to a Stack maintained in volatile memory (RAM). The Stack is usually access at the Top of Stack. Bytes can be pushed onto the stack at its top and later pulled (or "popped") of the Stack to retrieve them. To push a register, the instructions psha, pshb, pshc, pshd, pshx or pshy are used for registers A, B, D, CCR, X or Y respectively. They can then be retrieved with pula, pulb, pulc, puld, pulx or puly. How to use a subroutine The simplest kind of function to use in C is one that requires no passed parameters and returns no value. The following is an example in C of using such a function called foo() twice in a program:
10 COE538 Lecture Notes: Week 3 10 of 11 foo(); i++; //assume i is an 8-bit integer foo(); This would be translated to assembler as follows: jsr foo ;"jump to subroutine" foo inc i ;increment i jsr foo ;invoke foo again ;after foo completes, control is returned here How does the "jump to subroutine" instruction work? First, of course, the instruction is fetched. During the fetch phase the program counter is automatically incremented to point to the next sequential instruction. In the above example, after fetching (and before executing) the first jsr foo instruction, the PC would be the address of the inc i instruction. During the execute phase, the CPU does two things in the following order: First, the PC (which points to the next instruction) is pushed onto the stack Then, the PC is replaced with the target address specified as the jsr operand. Once the jsr is executed, the next instruction is the first instruction of the subroutine. When the subroutine has done its work, it returns to the calling program with the rts instruction which simply pops the top of the stack into the PC. Consequently, the next instruction executed following the rts is the instruction immediately following the jsr instruction that invoked the subroutine. How to write a simple subroutine The simplest type of subroutine has no passed parameters and does not return anything. A common example is a software delay loop. Basic I/O hcs12 Parallel Ports
11 COE538 Lecture Notes: Week 3 11 of 11 Programming the Liquid Crystal Display (LCD) interface Questions 1. Convert the following pseudo-c into assembler: byte bytes[] = {2, 7, 1, 8, 3, 1, 4, 8}; int i = 0 int sum = 0 byte * bp = bytes; //same as bp = &bytes[0] while(bp <= bytes+7) { sum = sum + (*bp)*2; bp = bp + 2; } 2. Assuming that the NZV and C bits are all zero, show how they evolve with each instruction: org $3000 ldaa #0f ora $3000 ;Note: some disassembly required! ldaa #$f0 adda #$e0 Answers
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 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 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 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 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 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 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 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 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 informationCondition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
Condition Code Register 1 Topics Condition code register Addition and subtraction instructions Conditional branches 2 Condition Code Register Condition code bits are automatically set by some instructions
More 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 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 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 informationEE 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 informationOutline. 2.8 Stack. 2.9 Subroutines
Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27
More 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 informationIntroduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949
Introduction to Embedded Microcomputer Systems Lecture 8.1 Computers in the future may weigh no more than 1.5 tons Popular Science, 1949 Recap Debugging: Monitor, dump TExaS Real 9S12DG Overview Addition
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationEE 3170 Microcontroller Applications
Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by
More 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 informationEE 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 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 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 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 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 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 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 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 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 informationWhat 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 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 information538 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 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 informationARM Assembly Language. Programming
Outline: ARM Assembly Language the ARM instruction set writing simple programs examples Programming hands-on: writing simple ARM assembly programs 2005 PEVE IT Unit ARM System Design ARM assembly language
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 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 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 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 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 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 informationMicrocontrollers and Embedded Systems. Fun with Motorola/Freescale HC11
Microcontrollers and Embedded Systems Fun with Motorola/Freescale HC11 What is a microcontroller? A microprocessor Usually not cutting edge Dependable All major bugs well known Predictable Critical for
More informationWed. 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 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 informationAssembly 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 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 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 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 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 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 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 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 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 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 informationEE319K Fall 2006 Quiz 1 Page 1
EE319K Fall 2006 Quiz 1 Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire
More informationMark 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 informationEE319K Fall 2003 Quiz 1 Page 1
EE319K Fall 2003 Quiz 1 Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire
More informationEE319K Fall 2005 Quiz 1A Page 1
EE319K Fall 2005 Quiz 1A Page 1 First: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please read the entire
More 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 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 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 informationECE232: Hardware Organization and Design
ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined
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 informationthe SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.
I. Intro the SAP-2 cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, 9.8 1. We ll do this in bits and pieces, doing the beginning of each section first. 1. The SAP-2 adds a lot of functionality to the SAP-1
More information1. 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 informationLecture #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 informationNET3001. Advanced Assembly
NET3001 Advanced Assembly Arrays and Indexing supposed we have an array of 16 bytes at 0x0800.0100 write a program that determines if the array contains the byte '0x12' set r0=1 if the byte is found plan:
More informationLecture 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 informationTiming 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 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 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 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 informationECE/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 informationEE319K Exam 1 Summer 2014 Page 1. Exam 1. Date: July 9, Printed Name:
EE319K Exam 1 Summer 2014 Page 1 Exam 1 Date: July 9, 2014 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help
More informationChapter 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 informationRCX internals (Revised February 24)
CMSC 23000 Winter 2006 Operating Systems Handout 3 January 27 RCX internals (Revised February 24) 1 Introduction This document collects together various pieces of information about the hardware in the
More informationEE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013
EE319K Fall 2013 Exam 1B Modified Page 1 Exam 1 Date: October 3, 2013 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will
More information(5) Question 7. Simplified memory cycles (you may or may not need all 5 entries) R/W Addr Data
EE319K Fall 2003 Quiz 3 Page 1 First: Middle Initial: Last: This is a closed book exam. You must put your answers on this piece of paper only. You have 50 minutes, so allocate your time accordingly. Please
More informationAdministrivia. 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 informationEE 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 informationCprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls
CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls Instructors: Dr. Phillip Jones 1 Announcements Final Projects Projects: Mandatory
More informationThe 6502 Instruction Set
The 6502 Instruction Set Load and Store Group LDA Load Accumulator N,Z LDX Load X Register N,Z LDY Load Y Register N,Z STA Store Accumulator STX Store X Register STY Store Y Register Arithmetic Group ADC
More informationAddition 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 informationECE 372 Microcontroller Design Basic Assembly Programming. ECE 372 Microcontroller Design Basic Assembly Programming
For Loop Example: for(j=0; j
More informationAddition 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 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 information