Physics 413 Chapter 4: Advanced Assembly Programming.

Slides:



Advertisements
Similar presentations
Floyd, Digital Fundamentals, 10 th ed EET 2261 Unit 7 Indexed Addressing Mode Read Mazidi, Chapter 6. Homework #7 and Lab #7 due next week. Quiz next week.
Advertisements

EET 2261 Unit 6 The Stack; Subroutines
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
Assembler Programming Chapter 6. EEL-4746 Best Practices.
68HC11 Polling and Interrupts
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
Subroutines and Stacks Lecture L3.1. Subroutine and Stacks The System Stack Subroutines A Data Stack.
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
Design of Embedded Systems Using 68HC12(11) Microcontrollers - R. E. Haskell Subroutine and Stacks Chapter 2.
Dr. Hoganson CSIS Segment Display and Count by 16 This is our third lab using the 68HC11 microcontroller. We will write a program that counts by.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
CEG411/611 Microprocessor Based System Design What is this course about? Computer : Processor, Memory, I/O Microprocessor versus microcontroller Embedded.
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
© 2010 Kettering University, All rights reserved..
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
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.
© 2010 Kettering University, All rights reserved..
9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter.
Passing Parameters using Stack Calling program pushes parameters on the stack one element at a time before calling subroutine. Subroutine Call (jsr, bsr)
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
1 Segments and Pseudo Operations Program Development.
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.
Motorola MC68HC811E2 Microcontrollers
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
8-1 EE 319K Introduction to Microcontrollers Lecture 8:Fixed Point Numbers, Local Variables, Binding, Allocation, Access, Deallocation.
Ch.2 Intro. To Assembly Language Programming
ECE Lecture 21 Typical Assembly Language Program Bugs.
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
ECE 447: Lecture 16 Common Errors & Good Programming Style.
Advanced Assembly Language Programming
University of Macau Faculty of Science and Technology Programming Languages Architecture SFTW 241 spring 2004 Class B Group 3.
© 2010 Kettering University, All rights reserved..
Embedded Systems Lecture 5 January 25 th, 2016.
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.
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
Revised: Aug 1, EE4390 Microprocessors Lessons 11, 12 Advanced Assembly Programming.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
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.
COP3502: Introduction to Computer Science Yashas Shankar Program Translation.
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
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
Mon Sept. 11 Announcements
ECE 3430 – Intro to Microcomputer Systems
Control Structure Applications
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
ECE 3430 – Intro to Microcomputer Systems
Wed. Sept 6 Announcements
Branching and Looping Lecture L3.2.
Control Structure Applications
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
The CPU12 Microprocessor Core
Branching and Loops.
; main program ; main move Param2, -(sp) move Param1, -(sp) Call Sub1
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 447: Lecture 15 Stack Operations.
EET 2261 Unit 6 The Stack; Subroutines
Some Assembly (Part 2) set.html.
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
ECE511: Digital System & Microprocessor
Presentation transcript:

Physics 413 Chapter 4: Advanced Assembly Programming

My First Assembly Program Program adds two 16-bit numbers stored at $ $1001 and $ $1003 and stores the sum at $ $1011 org $2000 ldd $1000 addd $1002 std $1010 end

Assembler Directives and more … org end equ db fcc Examples alpha equ 1.7 string fcc “hello!” array db $3, $8, $23, $11, $57, $12, $47

Delay Loop DELAY: LDX # $ FFFF AGAIN : DEX BNE AGAIN SWI

Delay Loop Subroutine here:JSR DELAY LDAA # $ E3 CMPA $ 50 BNE here SWI. DELAY: LDX # $ FFFF AGAIN : DEX BNE AGAIN RTS

Stack  Stack is the area of RAM pointed to by the 16-bit Stack Pointer (SP)  LDS functions like LDX  LDS #$ 5C42 The number 5C42 is loaded into SP  LDS $ 5C42 Numbers from 5C43 and 5C42 loaded  LDS $ 5C Numbers from 005D and 005C loaded

Push and Pull PSHA A M SP SP - 1 SP PULA SP + 1 SPM SP A

Predict the Outcome! PSHA PSHB PULA PULB

Solution Congratulations, if you said the contents of A and B will be swapped and, perhaps more importantly, the value of the stack pointer will be restored to its original value before this program segment was run. 00D6 00D5 00D4 00D3

Detailed Explanation Suppose that SP was pointing at 00D6 (stack). PUSHA stores A into 00D6. Then PUSHB stores B into 00D5. At this point SP = 00D4. Then PULA pulls 00D5 (which contains B) and stores it into A. Finally, PULB pulls 00D6 (which contains A) and stores it into B. We end up swapping A and B. At this point SP = 00D6, its original value. 00D6 00D5 00D4 00D3

Research Project Ideas Follow...

D-Bug12 Built-in Subroutines Table 4.2 (Huang)

I/O Ports Table 4.5 (Huang)

LED Circuit in the Dragon12-Plus Board (Huang)

Look for more research project ideas in the book and on the internet...