-
Notifications
You must be signed in to change notification settings - Fork 31
Description
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
equsymbol 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()