zasm: don't upcase char literals
This commit is contained in:
parent
72d2a8f073
commit
67803f6cb5
@ -143,7 +143,7 @@ parseArg:
|
||||
ld b, ARGSPEC_TBL_CNT
|
||||
.loop1:
|
||||
ld a, 4
|
||||
call JUMP_STRNCMP
|
||||
call strncmpI
|
||||
jr z, .found ; got it!
|
||||
ld a, 5
|
||||
call JUMP_ADDDE
|
||||
|
@ -5,3 +5,4 @@ ld a, 0x42
|
||||
ld hl, 0x4234
|
||||
ld hl, (0x4234)
|
||||
ld a, 'X'
|
||||
ld a, 'a' ; don't upcase!
|
||||
|
@ -75,7 +75,6 @@ readWord:
|
||||
ld a, (hl)
|
||||
call isSepOrLineEnd
|
||||
jr z, .success
|
||||
call JUMP_UPCASE
|
||||
ld (de), a
|
||||
inc hl
|
||||
inc de
|
||||
|
@ -55,6 +55,42 @@ strlen:
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; Compares strings pointed to by HL and DE up to A count of characters in a
|
||||
; case-insensitive manner.
|
||||
; If equal, Z is set. If not equal, Z is reset.
|
||||
strncmpI:
|
||||
push bc
|
||||
push hl
|
||||
push de
|
||||
|
||||
ld b, a
|
||||
.loop:
|
||||
ld a, (de)
|
||||
call JUMP_UPCASE
|
||||
ld c, a
|
||||
ld a, (hl)
|
||||
call JUMP_UPCASE
|
||||
cp c
|
||||
jr nz, .end ; not equal? break early. NZ is carried out
|
||||
; to the called
|
||||
or a ; cp 0. If our chars are null, stop the cmp
|
||||
jr z, .end ; The positive result will be carried to the
|
||||
; caller
|
||||
inc hl
|
||||
inc de
|
||||
djnz .loop
|
||||
; Success
|
||||
; We went through all chars with success. Ensure Z
|
||||
cp a
|
||||
.end:
|
||||
pop de
|
||||
pop hl
|
||||
pop bc
|
||||
; Because we don't call anything else than CP that modify the Z flag,
|
||||
; our Z value will be that of the last cp (reset if we broke the loop
|
||||
; early, set otherwise)
|
||||
ret
|
||||
|
||||
; If string at (HL) starts with ( and ends with ), "enter" into the parens
|
||||
; (advance HL and put a null char at the end of the string) and set Z.
|
||||
; Otherwise, do nothing and reset Z.
|
||||
@ -87,14 +123,15 @@ enterParens:
|
||||
call JUMP_UNSETZ
|
||||
ret
|
||||
|
||||
; Find string (HL) in string list (DE) of size B. Each string is C bytes wide.
|
||||
; Find string (HL) in string list (DE) of size B, in a case-insensitive manner.
|
||||
; Each string is C bytes wide.
|
||||
; Returns the index of the found string. Sets Z if found, unsets Z if not found.
|
||||
findStringInList:
|
||||
push de
|
||||
push bc
|
||||
.loop:
|
||||
ld a, c
|
||||
call JUMP_STRNCMP
|
||||
call strncmpI
|
||||
ld a, c
|
||||
call JUMP_ADDDE
|
||||
jr z, .match
|
||||
|
Loading…
Reference in New Issue
Block a user