Files
rgbds/test/asm/label-diff.asm
Rangi a70ecba06f Implement PRINT and PRINTLN (#672)
Fixes #669
Closes #368
Closes #624

Deprecate PRINTT, PRINTV, PRINTI, and PRINTF

Default STRFMT("%f") to 5 fractional digits like "{f:}"
Any use of string formatting will share this default
2021-01-02 02:37:32 +01:00

70 lines
1.7 KiB
NASM

PUSHS
SECTION "floating", ROM0
Known: ; This symbol is known to be a label, but its value is not known yet
ds 4
Known2: ; This symbol isn't known either, but the difference is known (4)
SECTION "fixed", ROM0[42]
Constant: ; This label's value is known to be 42
SECTION "fixed 2", ROM0[69]
Constant2: ; Same as above
print_diff: MACRO
PRINTLN (\1) - (\2)
PRINTLN (\2) - (\1)
ENDM
POPS ; Ensure we are in neither section
; TODO: uncomment all that can be, there is seriously room for improvement here
; Diffing two constants should work
print_diff Constant, Constant2
; Diffing two labels in the same SECTION as well
print_diff Known2, Known
; Diffing a constant and a "floating" label cannot work
print_diff Constant, Known
; Diffing a constant and a ref cannot work
print_diff Constant, Unknown
; Diffing a floating label and a ref cannot work
print_diff Known, Unknown
; Diffing two refs cannot work
print_diff Unknown, Unknown2
; Now let's fiddle with PC
SECTION "fixed PC", ROM0[420]
; Diffing a constant and PC should work
print_diff Constant, @
; Diffing a floating label and PC cannot work
print_diff Known, @
; Diffinf a ref and PC cannot work
print_diff Unknown, @
; Diffing PC and PC should work
print_diff @, @
; Diffing PC and a label from here should work
LocalFixed:
print_diff LocalFixed, @
ds 69
print_diff LocalFixed, @
SECTION "Floating PC", ROM0
; Diffing a constant and PC cannot work
print_diff Constant, @
; Diffing a floating label and PC cannot work
print_diff Known, @
; Diffinf a ref and PC cannot work
print_diff Unknown, @
; Diffing PC and PC should work
print_diff @, @
; Diffing PC and a label from here should work
LocalFloating:
print_diff LocalFloating, @
ds 42
print_diff LocalFloating, @