ECE 331: PC Lab 3 Stack and Subroutines

Similar documents
Exam I Review February 2017

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

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

Lab 7: Change Calculation Engine

Lab 8: Debugging Embedded Devices and Software

ECE3120: Computer Systems Hardware & Software Development Tools

Using the stack and the stack pointer

Getting Started with the HCS12 IDE

Subroutine. Chapter 8

538 Lecture Notes Week 5

Outline. 2.8 Stack. 2.9 Subroutines

538 Lecture Notes Week 5

Introduction to Microcontrollers

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

Cross Assembly and Program Development

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

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

Introduction to Microcontrollers III

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

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

Assembly Language programming (1)

Sample Problem Set #1

EE 308 LAB 1 ASSEMBLER, SIMULATOR, AND MONITOR. Introduction and Objectives

538 Lecture Notes Week 1

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

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

1. Memory Mapped Systems 2. Adding Unsigned Numbers

EE 3170 Microcontroller Applications

Coe538 Final Study Guide 2016 (Questions & Answers)

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

Introduction to Microcontrollers III

538 Lecture Notes Week 3

COSC345 Software Engineering. Basic Computer Architecture and The Stack

EMCH 367 Fundamentals of Microcontrollers Example7 EXAMPLE 7

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Lecture 9 Subroutines

68HC12 Training Lab Student Exercise Book

ME 6405 Introduction to Mechatronics

538 Lecture Notes Week 2

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

CHAPTER 8. Solutions for Exercises

CMPEN 472 Sample EXAM II

Programming the Motorola MC68HC11 Microcontroller

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

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

Programming Book for 6809 Microprocessor Kit

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

CE-320 Microcomputers I Winter 2010 LAB 1: MINIIDE GROUP #: NAME: PARTNER: Lab 1 Page 1

Homework 12 Solutions

Introduction to Microcontrollers II

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003

68HC11 PROGRAMMER'S MODEL

Exam 1 Feb. 23, 25, 27?

Chapter 3. Z80 Instructions & Assembly Language. Von Neumann Architecture. Memory. instructions. program. data

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

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

Interrupt and Timer ISRs. Student's name & ID: Partner's name(s) & ID(s): Your Section number & TA's name

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

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

Total: EEL 3701 Digital Logic & Computer Systems Final Exam Fall Semester 2007 COVER SHEET: Re-Grade Information: 1 (10) 2 (10) 3 (10) 4 (14) 5 (14)

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

Chapter 3: HCS12 Hardware and Software Development Tools. The HCS12 Microcontroller. Han-Way Huang. Minnesota State University, Mankato

Introduction to Microcontrollers II

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

What is an Addressing Mode?

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3

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

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

ECET Chapter 2, Part 2 of 3

Computer Systems Lecture 9

Today s objective: introduction to really simple subroutines to simplify program structure for I/O

COMP2121 Introductory Experiment

Lab 9: On-Board Time Generation and Interrupts

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

Computer Hardware Engineering

Wed. Sept 6 Announcements

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?)

Linking Assembly Subroutine with a C Program

Assembly Language programming (3)

PUSH BUTTON. Revision Class. Instructor / Professor LICENSE

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

SHEET-2 ANSWERS. [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte.

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

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

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

Quick Guide to Using Code Warrior

HC12 Microprocessor. D-Bug12 Functions: Stepping Through Programs & Performing I/O. Dr. Bradley J. Bazuin

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

Introduction to Embedded Systems. Some Nagging

1/30/2018. Conventions Provide Implicit Information. ECE 220: Computer Systems & Programming. Arithmetic with Trees is Unambiguous

NEW CEIBO DEBUGGER. Menus and Commands

Tutorial 1: Programming Model 1

MIPS Assembly Programming

Microcontrollers and the Freescale/Motorola HC11

Microcontrollers. Microcontroller

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

An ability to program a microcontroller to perform various tasks

HC11 Instruction Set Architecture

Transcription:

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 data to the stack Pulling data from the stack Calling subroutines Simple subroutine program p.2

Using WinIDE Dev. Environment Launch application START > All Programs > P&E > WinIDE Development Environment Use editor: File > New File type code save file (e.g., ece331/ex1.asm) Assemble click on Assemble/Compile File icon Check for errors look for error message at bottom of window view.lst file for info on errors Simulate click on Simulator (EXE2) icon set Program Counter (PC) to program starting address left-click on PC in CPU12 Window or type PC 4000 in command line view source code disassembled simulate: click on Go! icon p.3

Exercise 1: Push it Print the check-off sheet on slide 8 1. Create this program 2. Add lines to the program to push acca, accb, ix, & iy to the stack, in that order 3. Compile & remove syntax errors 4. Start simulator set PC = 4000 display code at 4000 observe memory at 5FF0-6010 5. Trace through program and observe stack being filled 6. Fill in the check-off sheet when program stops executing ;PClab3_ex1 ORG $4000 LDS #$6000 LDAA #$AA LDAB #$BB LDX #$0F0F LDY #$5533 SWI END p.4

Exercise 2: Pull it Do not begin until Exercise 1 is complete 1. Save a copy of the Exercise 1 program as Exercise 2 (e.g., PClab3_ex2) 2. At the end of the program add instructions to pull acca, accb, ix, & iy from the stack, in that order 3. Compile & remove syntax errors 4. Start simulator set PC = 4000 display code at 4000 observe memory at 5FF0-6010 5. Test program to ensure it is working as expected use trace and break-points as necessary 6. Fill in the check-off sheet when program stops executing p.5

Exercise 3: Pull it in subroutine Do not begin until Exercise 2 is complete 1. Save a copy of the Exercise 2 program as Exercise 3 2. Modify the program so that: the pull instructions are in a subroutine beginning at $4400 the main program calls the subroutine before the SWI 3. Compile & remove syntax errors 4. Start simulator set PC = 4000 - display code at 4000 observe memory at 5FF0-6010 5. Test program to see if it is working as expected use trace and break-points as necessary if you have entered the program as instructed, it should not work 6. Track down the problem and fix it! also modify the pulls so they properly restore registers 7. Complete the check-off sheet for Exercise 3 ;program structure 4000 Main program - - JSR SWI 4400 Subroutine - RTS END p.6

Exercise 4: Subroutine 1. Write a program that will load $DDDD into ix and $4444 into iy load $05 into acca and $50 into accb jump to a subroutine sum that saves contents of ix and iy on stack & restores at end of subroutine load $0101 into ix and $2020 into iy adds the values in acca and accb and stores the sum in acca sets accb = FF if the sum has carry overflow; otherwise accb = 00 loads $8E into acca and $E8 into accb jumps to subroutine sum end (SWI, END) 2. Compile & remove syntax errors 3. Simulate program to ensure it is working correctly 4. Complete the check-off sheet for Exercise 4 p.7

PC Lab 3 Check-off Sheet Student Name: Exercise 1 Record the register values observed from program simulation at the end of Exercise 1. Addr. Value Acc A Acc B Index X Index Y Stack Pointer Record the stack contents observed from program simulation at the end of Exercise 1. Exercise 2 Record the register values observed from program simulation at the end of Exercise 2. Acc A Acc B Index X Index Y Stack Pointer Is this what you expect? If not, explain. Exercise 3 What changes were necessary for the program to work correctly? Record the register values observed from program simulation at the end of Exercise 3. Acc A Acc B Index X Index Y Stack Pointer Exercise 4 Record the register values observed from program simulation at the end of Exercise 4. Acc A Acc B Index X Index Y Stack Pointer p.8