1 / 8

Common Assembly Language Program Bugs to Avoid

Learn about typical assembly language program bugs such as improper subroutine transfers, stack pointer initialization, register handling errors, and more to enhance program reliability.

thad
Download Presentation

Common Assembly Language Program Bugs to Avoid

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 447 - Lecture 21 Typical Assembly Language Program Bugs

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

More Related