Revised: Aug 1, 20031 EE4390 Microprocessors Lessons 11, 12 Advanced Assembly Programming.

Slides:



Advertisements
Similar presentations
Ch. 7 Local Variables and Parameter Passing From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Advertisements

EET 2261 Unit 6 The Stack; Subroutines
May 12 th, 2002 Microprocessors. Introduction Motorola controls roughly 40% of the 32-bit embedded processor market ColdFire is the next generation 68K.
Chapter 9 TRAP Routines and Subroutines. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9-2 Subroutines.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Utilizing the GDB debugger to analyze programs Background and application.
EECC250 - Shaaban #1 Lec # 5 Winter Stacks A stack is a First In Last Out (FILO) buffer containing a number of data items usually implemented.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
EECC250 - Shaaban #1 lec #7 Winter Local workspace of a subroutine: A number of temporary memory locations required by the subroutine for temporary.
8051 ASSEMBLY LANGUAGE PROGRAMMING
Design of Embedded Systems Using 68HC12(11) Microcontrollers - R. E. Haskell Subroutine and Stacks Chapter 2.
Revised: Aug 1, ECE 263 Embedded System Design Lesson 1 68HC12 Overview.
Stacks and Subroutines ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
© 2010 Kettering University, All rights reserved..
Subroutines and Stacks 1. Subroutines Separate, independent module of program, performs a specific task shortens code, provide reusable “tools” High-level.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
Stacks and Subroutines. Some example stacks Stacks and subroutine usage The stack is a special area of the random access memory in the overall memory.
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Physics 413 Chapter 4 A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.
Objective At the conclusion of this chapter you will be able to:
Revised: Aug 1, ECE263 Embedded System Design Lesson 4 Programming Model, Assembly Language, Instruction Execution Cycle.
Passing Parameters using Stack Calling program pushes parameters on the stack one element at a time before calling subroutine. Subroutine Call (jsr, bsr)
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Computer Architecture Lecture 13 – part 1 by Engineer A. Lecturer Aymen Hasan AlAwady 31/3/2014 University of Kufa - Information Technology Research and.
© Mike Stacey 2008 Single Chip Microcontrollers 7765J Mount Druitt College of TAFE Lesson 3 Arrays in ASM, Bubble Sort algorithm.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
1 Stacks, Subroutines, I/O Routines Today: First Hour: Stacks, Subroutines –Section 3.9,3.10 of Huang’s Textbook –In-class Activity #1 Second Hour: I/O.
Addressing Modes MTT CPU08 Core Motorola CPU08 ADDRESSING MODES.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
Functions. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9-2 JSR Instruction Jumps to a location (like.
Advanced Assembly Language Programming
Subroutines and Stacks. Stack The stack is a special area in memory used by the CPU to store register information or general data information during program.
CPS 4150 Computer Organization Chapter 2-2 Fall 2006 Ching-Song Don Wei.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Lec. 10 Assembly Programming Dr. Tamer Samy Gaafar Microprocessors.
Physics 413 Chapter 4: Advanced Assembly Programming.
1 Subroutines Advanced Programming. 2 Top-Down approach to problem solving Algorithm step by step description of how to solve a problem Divide and Conquer.
1 Stack Advanced Programming. 2 The Stack It is a special area of memory used as temporary storage A stack is a LIFO data structure Putting data into.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
EE345 Chapter 2 Lecture 3 April 4. Quiz every Wednesday 1 quiz = 1% extra credit five quizzes before midterm  5% for midterm. five quizzes before final.
ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional.
Stacks and Subroutines May 23. Stacks and subroutine usage The stack is a special area of the random access memory in the overall memory system The stack.
5-1 EE 319K Introduction to Microcontrollers Lecture 5: Conditionals, Loops, Modular Programming, Sub- routines, Parameter passing.
CPEN 231: Microcomputer Architecture and Assembly Programming Lecture 10: Stack and Subroutines John Tadrous, Ph.D. ECE Rice University
EET 2261 Unit 6 The Stack; Subroutines
Storage Classes There are three places in memory where data may be placed: In Data section declared with .data in assembly language in C - Static) On the.
ECE 3430 – Intro to Microcomputer Systems
Part of the Assembler Language Programmers Toolbox
Introduction of microprocessor
Microprocessor and Assembly Language
Microcomputer Programming
Arithmetic using a stack
The University of Adelaide, School of Computer Science
Morgan Kaufmann Publishers Computer Organization and Assembly Language
EE6502/MPMC/UNIT II/STACK AND SUBROUTINE/T.THARANKUMAR
Subroutines … passing data
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
8051 ASSEMBLY LANGUAGE PROGRAMMING
EET 2261 Unit 6 The Stack; Subroutines
Lecture 3 - Instruction Set - Al
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Lecture 3 - Instruction Set - Al
Presentation transcript:

Revised: Aug 1, EE4390 Microprocessors Lessons 11, 12 Advanced Assembly Programming

Revised: Aug 1, Overview Assembly Process Loops Stack Subroutines 68HC12 D-BUG12 Utility Subroutines Programming Modules - Unified Modeling Language Programming Techniques

Revised: Aug 1, Assembly Process Assembler converts assembly language source file (*.asm) to machine language (1’s and 0’s) Motorola machine language file is an *.S19 As part of the assembly process one can generate a list file (*.lst) –contains address for each instruction –provides contents of each address

Revised: Aug 1, Assembly Process (cont)

Revised: Aug 1, Loops Software construct to perform code iterations –HOL: for(i=0;i<=10;i++){do something;} Loop construct - 5 step process –initialize loop counter –perform specified operation, increment (or decrement) loop counter –compare counter with limit –exit if the value of the loop counter is greater (less) than the upper (lower) limit

Revised: Aug 1, Loops (cont) LabelOp-CodeOperand(s) Comment ;Average midterm score of 10 students LDAB#$00;clear B LDX#$1000;initialize index X LDABSUM;load sum to B LDAA#$00;initialize loop ctr CHECK:CMPA#$0A;10 scores yet? BEQSTOP;if so, exit loop ADDB0,X;add to sum INX;inc index X INCA;inc loop counter BRACHECK;start loop again STOP:STABSUM;save the result

Revised: Aug 1, Stack Portion of RAM set aside for temporary data storage “Top of Stack” refers to address of last element loaded on stack Stack Pointer (SP) keeps track of stack top SP-> RAM $ $7FFF

Revised: Aug 1, Stack (cont) Programmer dictates initial contents of stack –Declare as last location in largest RAM space plus 1 –For the “A4”, this is $8000 (user RAM: $ $7FFF) First-in-last-out data structure Temporary storage during program execution –PUSH: place register contents on stack –PULL: place stack location contents in register EX] PSHA, PSHX, PULB, PULY Need to PSH and PUL in opposite order to retain original register values

Revised: Aug 1, Stack (cont) Stack Initialization ;directives STACKTOP = $8000 ;code LDS#STACKTOP

Revised: Aug 1, Subroutines Separate, independent module of program, performs a specific task –shortens code, provide reusable “tools” Good subroutine: –independence: does not depend on other code –registers: stores/restores key registers upon entrance/exit using PSH and PUL commands –data and code independent: local variables, do not use direct and extended addressing modes

Revised: Aug 1, Subroutines (cont) BSR vs JSR RTS Return address automatically PSH and PUL to stack Key registers must be PSH and PUL by programmer

Revised: Aug 1, Subroutines (cont) STACKTOP = $8000 _main:: LDS#STACKTOP;initialize SP JSRDOIT;jump to subroutine HEREBRAHERE DOIT:PSHA;store key registers on stack PSHB :;subroutine actions PULB;restore key register values PULA RTS;return from subroutine

Revised: Aug 1, D-BUG12 Utility Routines "Copyright of Motorola, Used by Permission"

Revised: Aug 1, D-BUG12 Utility Routines (cont) For D-BUG12 routines, the 68HC12 insists on using stack to transfer parameter variables –treat parameters as 16-bit values Parameters must be pushed onto the stack starting with parameter n to 1 Load vector address of the subroutine in index register X

Revised: Aug 1, D-BUG12 Utility Routines (cont) EX] Use out2hex() utility subroutine to display $45 on the computer screen –store $0045 to stack before calling subroutine LDD#$0045;value for display PSHD LDX#$FE16;16-bit addr of subr JSR0,X;call the subroutine PULX;clean up the stack