ECE 447 - Lecture 21
Download
1 / 8

ECE 447 - Lecture 21 - PowerPoint PPT Presentation


  • 59 Views
  • Uploaded on

ECE 447 - 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 .bss rmb 128 stack_end.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' ECE 447 - Lecture 21' - thad


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

ECE 447 - 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 .bss

rmb 128

stack_end

done by default by the startup code

section .text

lds #stack_end-1


Typical Assembly Language Program Bugs (2)

3. Not allocating enough memory for the stack

program

execution

data

data

stack

stack

4. Unbalanced stack operations

just before RTS

immediately after JSR

SP

variables

RTN

SP

RTN


Typical Assembly Language Program Bugs (3)

5. Using subroutines that change registers

Example:

LDX #ADDRESS

JSR changer

LDAA 0,X

6. Transposed registers

Examples:

TBA vs. TAB

PSHA

PSHB

PULX

PSHB

PSHA

PULX

instead of


Typical Assembly Language Program Bugs (4)

7. Not initializing pointer register

Example:

LDAA 0,X

8. Not initializing registers and data areas

section .bss

var1 rmb 2

Example:

section .text

LDD var1


Typical Assembly Language Program Bugs (5)

9. Inadvertent modification of the condition code register

CLC

start LDAA 0,X

ADCA 0,Y

STAA 0,X

INX

CPX #end

BNE start

Examples:

CPX #end_address

LDD result

BNE start

modifies Z flag

modifies C flag


Typical Assembly Language Program Bugs (6)

10. Using the wrong conditional branch instruction

Correct:

for unsigned numbers

for signed numbers

BHI, BHS

BLO, BLS

BGT, BGE

BLT, BLE

11. Using the wrong addressing mode

Examples:

INIT EQU 1

var1 fdb 5

LDD #var1

LDD INIT

instead of

LDD var1

instead of

LDD #INIT


Typical Assembly Language Program Bugs (7)

12. Using a 16-bit counter in memory

Example:

counter fdb 0, 0

inc counter

increments only the more significant

byte of a 16-bit counter


ad