BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

Similar documents
Lecture 9 Subroutines

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

Programming the Motorola MC68HC11 Microcontroller

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

Outline. 2.8 Stack. 2.9 Subroutines

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

Sample Problem Set #1

The Motorola 68HC11 Instruc5on Set

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

0b) [2] Can you name 2 people form technical support services (stockroom)?

538 Lecture Notes Week 3

Lecture 6 Assembly Programming: Branch & Iteration

EE 3170 Microcontroller Applications

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

Coe538 Final Study Guide 2016 (Questions & Answers)

538 Lecture Notes Week 3

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.

Using the stack and the stack pointer

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access

Exam I Review February 2017

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

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

538 Lecture Notes Week 2

EE 308 Spring The HCS12 has 6 addressing modes

Introduction to Embedded Microcomputer Systems Lecture 10.1

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:

Student # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering

OSIAC Read OSIAC 5362 posted on the course website

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.

Programming Book for 6809 Microprocessor Kit

SECTION 6 CENTRAL PROCESSING UNIT

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

Module 1-G. Marcos and Structured Programming

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

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

MIGRATING TO THE 68HC12 IN C

Introduction to Embedded Microcomputer Systems Lecture Synchronizing with an input device. Busy-Wait. Empty Fifo. Busy Status.

Exam 2 E2-1 Fall Name: Exam 2

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const

COSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)

Introduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949

EE319K Fall 2007 Quiz 1A Page 1. (5) Question 2. What will be the value of the carry (C) bit after executing the following? ldab #210 subb #60

Exam 2 E2-1 Fall Name: Exam 2

ME 6405 Introduction to Mechatronics

538 Lecture Notes Week 5

Motorola HC11. Fun with Microcontrollers and Embedded Systems

EE 3170 Microcontroller Applications

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

Exam 1 Feb. 23, 25, 27?

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

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

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

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Xuan Guo. Lecture XIX: Subroutines (2) CSC 3210 Computer Organization and Programming Georgia State University. March 31, 2015.

ECE 331: PC Lab 3 Stack and Subroutines

68HC11 PROGRAMMER'S MODEL

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

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

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

Department of Computer Science and Engineering

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Lab 7: Asynchronous Serial I/O

ECE 3120: Computer Systems Chapter 8: ECE-3120-A Musical

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions

538 Lecture Notes Week 5

CMPEN 472 Sample EXAM II

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

Chapter 2 HCS12 Assembly Language

An ability to program a microcontroller to perform various tasks

Wed. Sept 6 Announcements

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000.

EE4390 Microprocessors

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

EE319K Fall 2006 Quiz 1 Page 1

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

EE 3170 Microcontroller Applications

ECE 471 Embedded Systems Lecture 8

EE319K Fall 2003 Quiz 1 Page 1

Cross Assembly and Program Development

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

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

HC11 Instruction Set Architecture

COSC345 Software Engineering. Basic Computer Architecture and The Stack

HC11 Instruction Set Architecture

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

The 6502 Instruction Set

Quick Guide to Using Code Warrior

Assembly Language Development Process. ECE/CS 5780/6780: Embedded System Design. Assembly Language Listing. Assembly Language Syntax

CET335 Microprocessor Interfacing Lab 5: LCD Interface (Bus Attached Peripheral)

Fri. Aug 25 Announcements

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

ECE/CS 5780/6780: Embedded System Design

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1

EE319K Fall 2005 Quiz 1A Page 1

ECET Chapter 2, Part 2 of 3

Transcription:

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. BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0 Branch if A is HIgher than operand. BMI, BVC, BNE Check the result if it is Minus/signed overflow/not Equal to zero CMPA: A (M) TSTA: A 0 V bit (signed overflow) N + N P P + P N N P P P N N

Midterm Review cont d 2. BRA and LBRA Write a line of assembly code that begins in memory location $2450. BRA <8-bit signed offset value> LBRA <16-bit signed offset value> When the effective (destination) address is calculated in relative addressing mode, a value that you need to add to an offset is PC. We have to use PC which is the next address of the line of assembly code of (L)BRA

Midterm Review 3. Mostly this is about calculating l postbyte(s) t -20: You cannot use 5-bit offset. You have to use 9-bit one.

Lecture 16: Parameter Passing

Today s Goals Parameter passing Understand how to pass parameters using the stack

Call by Value vs. Call by Reference Value Subroutine Main Program Memory Address Subroutine Look for values

Passing Parameters in Registers Use registers to pass parameters The simplest type of parameter passing Pros vs. Cons Data is immediately available to the subroutine No extra preparations are needed. Often fastest execution and smallest code size Only a limited number of registers are available. We can use pass-by-reference to point a list of input/output values.

Example (Parameter Passing in Registers) Requirements A subroutine that adds an array of two-byte numbers and a sample main program that calls it. The array is passed by reference in X. The length is passed by value in D. The sum should be returned by value in D. Do not worry about indicating signed or unsigned overflow.

Example (Parameter Passing in Registers) ORG $3000 Array dc.w $1234,$5678,$ABCD Length dc.w 3 ORG $2000 LDS #$3600 LDX #Array ; load X with address of list LDD Length ; Load D with actual length JSR sumword SWI sumword TFR D,Y LDDD #0 CPY #0 Loop BEQ endsum ADDD 0,X INX INX DEY BRA loop endsum RTS

Preserving Registers In the previous example, the subroutine uses Y. The value in Y is destroyed. If Y was in use by the main program, the main program would continue after the subroutine with an incorrect value in Y. To avoid this, registers used by a subroutine may be saved to the stack before a subroutine uses them. The saved registers are restored after the subroutine. We have two options The caller (main program) does this. The callee (subroutine) does this.

Preserving Registers Responsibility of the Caller: The calling main program assumes all registers are destroyed by the subroutine If the registers used by the subroutine are unknown (i.e. using a sub. provided by someone else), may save registers that the subroutine wouldn t affect Code to save/restore registers duplicated with every subroutine call. Responsibility of the Callee: Saves only the registers that will be used by the subroutine Save/restore code only occurs once

Example Caller Responsible ORG $3000 Array dc.w $1234,$5678,$ABCD Length dc.w 3 JSR ORG $2000 LDS #$3600 LDX #Array ; load X with address of list LDD Length ; Load D with actual length PSHX sumword PULX SWI sumword TFR D,Y LDDD #0 CPY #0 loop BEQ endsum RAH ADDD 0,X INX RAL INX XH DEY BRA loop XL endsum RTS Stack Frame

Example Callee Responsible ORG $3000 Array dc.w $1234,$5678,$ABCD$5678 $ABCD Length dc.w 3 ORG $2000 LDS #$3600 LDX #Array ; load X with address of list LDD Length ; Load D with actual length JSR sumword SWI sumword PSHX PSHY TFR D,Y LDDD #0 CPY #0 loop BEQ endsum ADDD 0,X INX INX DEY BRA loop endsum PULY PULX RTS LDDD #0 Stack Frame Why not D? It is used to return the answer! YH YL XH XL RAH RAL

Passing Parameters in the Stack Pros and Cons The stack pointer is already in use for the return address Indexed addressing can easily access data stored on the stack The amount of data passed is not limited by the register set The data passed on the stack must be removed, and this is usually the responsibility of the caller (although this can be done by the callee) Note: If the caller will save registers on the stack, it should be done before passing parameters. Why? Those parameters are supposed to be used in the subroutine.