ECE 447 - Lecture 21 Typical Assembly Language Program Bugs.

Slides:



Advertisements
Similar presentations
Chapter 5 Tutorial 5a. Editing and Assembling From Valvano.
Advertisements

Ch. 7 Local Variables and Parameter Passing From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Chapter 3 Introduction to the 68000
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Addressing Modes & Instruction Set By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41 URL:
Assembler Programming Chapter 6. EEL-4746 Best Practices.
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
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.
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.
© 2010 Kettering University, All rights reserved..
CEG411/611 Microprocessor Based System Design What is this course about? Computer : Processor, Memory, I/O Microprocessor versus microcontroller Embedded.
Basic Microcontroller System
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.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
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.
ELN5622 Embedded Systems Class 2 Spring, 2003 Kent Orthner
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
ECE Lecture 13 Motorola 68HC11. Resources 68HC11 E-series Reference Guide and if necessary 68HC11 E-series Technical Data 68HC11 Reference Manual.
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..
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
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.
Machine Language ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
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
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
© 2010 Kettering University, All rights reserved..
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
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?
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
ECE 447: Lecture 13 Assembler Directives. ECE 447: Defining a Constant #define PORTB 0x1004PORTB EQU $1004 #define DELAY 100 ………. #undef DELAY #define.
5-1 EE 319K Introduction to Microcontrollers Lecture 5: Conditionals, Loops, Modular Programming, Sub- routines, Parameter passing.
Programmable System on Chip
ECE 3430 – Intro to Microcomputer Systems
Addressing Modes in Microprocessors
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Wed. Sept 6 Announcements
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Graded Quiz #3 Sept. 15, 2017 Clicker [AB]
Registers in the CPU Inside the CPU.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 447: Lecture 15 Stack Operations.
Lecture 3 - Instruction Set - Al
ECE511: Digital System & Microprocessor
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

ECE Lecture 21 Typical Assembly Language Program Bugs

Typical Assembly Language Program Bugs (1) 1. Improper transfer to subroutines Correct: JSR, BSR Incorrect: JMP, BRA 2. Forgetting to initialize stack pointer section.text lds #stack_end-1 done by default by the startup code section.bss rmb 128 stack_end

Typical Assembly Language Program Bugs (2) 3. Not allocating enough memory for the stack 4. Unbalanced stack operations immediately after JSR just before RTS RTN SP data stack data stack program execution variables

Typical Assembly Language Program Bugs (3) 5. Using subroutines that change registers LDX #ADDRESS JSR changer LDAA 0,X Example: 6. Transposed registers TBA vs. TAB PSHA PSHB PULX Examples: instead of PSHB PSHA PULX

Typical Assembly Language Program Bugs (4) 7. Not initializing pointer register 8. Not initializing registers and data areas section.bss var1 rmb 2 LDAA 0,X section.text LDD var1 Example:

Typical Assembly Language Program Bugs (5) 9. Inadvertent modification of the condition code register CPX #end_address LDD result BNE start Examples: CLC start LDAA 0,X ADCA 0,Y STAA 0,X INX CPX #end BNE start modifies Z flag modifies C flag

Typical Assembly Language Program Bugs (6) 10. Using the wrong conditional branch instruction BHI, BHS BLO, BLS for unsigned numbers Correct: BGT, BGE BLT, BLE for signed numbers 11. Using the wrong addressing mode Examples: LDD INIT INIT EQU 1var1 fdb 5 LDD #var1 instead of LDD #INIT instead of LDD var1

Typical Assembly Language Program Bugs (7) 12. Using a 16-bit counter in memory counter fdb 0, 0 inc counter Example: increments only the more significant byte of a 16-bit counter