瀏覽代碼

zasm: don't upcase char literals

pull/10/head
Virgil Dupras 5 年之前
父節點
當前提交
67803f6cb5
共有 4 個檔案被更改,包括 41 行新增4 行删除
  1. +1
    -1
      apps/zasm/instr.asm
  2. +1
    -0
      apps/zasm/tests/test4.asm
  3. +0
    -1
      apps/zasm/tok.asm
  4. +39
    -2
      apps/zasm/util.asm

+ 1
- 1
apps/zasm/instr.asm 查看文件

@@ -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


+ 1
- 0
apps/zasm/tests/test4.asm 查看文件

@@ -5,3 +5,4 @@ ld a, 0x42
ld hl, 0x4234
ld hl, (0x4234)
ld a, 'X'
ld a, 'a' ; don't upcase!

+ 0
- 1
apps/zasm/tok.asm 查看文件

@@ -75,7 +75,6 @@ readWord:
ld a, (hl)
call isSepOrLineEnd
jr z, .success
call JUMP_UPCASE
ld (de), a
inc hl
inc de


+ 39
- 2
apps/zasm/util.asm 查看文件

@@ -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…
取消
儲存