Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equ directive does not handle forward references or unknown references, printing no warnings, and returning a success status code (0) #82

Open
bxparks opened this issue Jun 22, 2024 · 0 comments

Comments

@bxparks
Copy link

bxparks commented Jun 22, 2024

Problem

If the equ directive contains a forward reference to another equ symbol, the assembler generates invalid machine code. But worse, the assembler does not print any warning messages, and returns a 0 status code (at least on the Linux version) which incorrectly tells the OS that the command succeeded.

Similarly, an equate that contains a reference to an undefined symbol (caused by a simple typo) produces the same result. This can result in many hours of debugging fun.

Example

The helloflash.asm flash app below will generate an invalid machine code for ld hl, helloRowCol because the helloRowCol equate contains a forward reference to helloRow and helloCol.

   21 00:4083 21 80 40 -      ld hl, helloRowCol

instead of the correct:

   21 00:4083 21 01 00 -      ld hl, helloRowCol

The lack of any warnings and the return of the (incorrect) success status code (0) is similar to #70.

Expectation

  • A reference to an unknown symbol (caused by a typo for example) should print an error message.
  • A forward reference to another equ symbol should resolve as expected.
  • Any error should return a non-zero status code (at least on Linux) to indicate to the OS that the assembler failed. (Created a separate fatal error conditions should return a non-zero status code (Linux, maybe MacOS) #84 for this, because it's a pervasive problem.)

helloflash.asm

.nolist
#include "ti83plus.inc"
#include "app.inc"
.list

defpage(0, "hellofla")

helloRowCol equ helloRow + ($100*helloCol)
helloRow equ 1
helloCol equ 0

main:
    bcall(_ClrLCDFull)
    ld hl, helloRowCol
    ld (curRow), hl
    ld hl, txtHello
    call myPutS
    bcall(_GetKey)
    bjump(_JForceCmdNoChar)

myPutS:
    ld a, (hl)
    or a
    ret z
    bcall(_PutC)
    inc hl
    jr myPutS

txtHello:
    .db "Hello world!", 0

validate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant