C style character translation in ca65

This commit is contained in:
Gorilla Sapiens
2025-05-06 03:02:18 +00:00
parent 75d43ef88e
commit 1b85ab6985
2 changed files with 104 additions and 44 deletions

View File

@@ -90,22 +90,7 @@ read_loop:
bne :+
inc ptr4+1
; The next code line:
;
; .byte $c9, "\n"
;
; corresponds to a CMP #imm with the target-specific newline value as its operand.
; This works because (with the 'string_escapes' feature enabled), the "\n" string
; assembles to the target-specific value for the newline character.
;
; It would be better if we could just write:
;
; cmp #'\n'
;
; Unfortunately, ca65 doesn't currently handle escape characters in character
; constants. In the longer term, fixing that would be the preferred solution.
: .byte $c9, "\n" ; cmp #'\n'
: cmp #'\n' ; #'\n' should get translated properly
beq done
bne read_loop