core: remove cpHLDE

It wasn't used much, so I replaced its use in the kernel with direct code
and moved the routine in apps/ed, the only other place where it was used.
这个提交包含在:
Virgil Dupras 2019-12-12 15:53:14 -05:00
父节点 c002c69208
当前提交 4f7a05e3b7
共有 7 个文件被更改,包括 65 次插入42 次删除

查看文件

@ -33,6 +33,7 @@
.inc "core.asm"
.inc "lib/util.asm"
.inc "lib/parse.asm"
.inc "ed/util.asm"
.equ IO_RAMSTART USER_RAMSTART
.inc "ed/io.asm"
.equ BUF_RAMSTART IO_RAMEND

8
apps/ed/util.asm 普通文件
查看文件

@ -0,0 +1,8 @@
; Compare HL with DE and sets Z and C in the same way as a regular cp X where
; HL is A and DE is X.
cpHLDE:
push hl
or a ;reset carry flag
sbc hl, de ;There is no 'sub hl, de', so we must use sbc
pop hl
ret

查看文件

@ -57,15 +57,6 @@ intoIX:
pop ix
ret
; Compare HL with DE and sets Z and C in the same way as a regular cp X where
; HL is A and DE is X.
cpHLDE:
push hl
or a ;reset carry flag
sbc hl, de ;There is no 'sub hl, de', so we must use sbc
pop hl
ret
; Write the contents of HL in (DE)
; de and hl are preserved, so no pushing/popping necessary
writeHLinDE:

查看文件

@ -413,17 +413,17 @@ fsPlaceH:
; Sets Z according to whether HL is within bounds for file handle at (IX), that
; is, if it is smaller than file size.
fsWithinBounds:
push de
; file size
ld e, (ix+4)
ld d, (ix+5)
call cpHLDE
pop de
jr nc, .outOfBounds ; HL >= DE
ld a, h
cp (ix+5)
jr c, .within ; H < (IX+5)
jp nz, unsetZ ; H > (IX+5)
; H == (IX+5)
ld a, l
cp (ix+4)
jp nc, unsetZ ; L >= (IX+4)
.within:
cp a ; ensure Z
ret
.outOfBounds:
jp unsetZ ; returns
; Set size of file handle (IX) to value in HL.
; This writes directly in handle's metadata.

查看文件

@ -13,8 +13,10 @@
_mmapAddr:
push de
ld de, MMAP_LEN
call cpHLDE
or a ; reset carry flag
sbc hl, de
jr nc, .outOfBounds ; HL >= DE
add hl, de ; old HL value
ld de, MMAP_START
add hl, de
cp a ; ensure Z

查看文件

@ -5,8 +5,6 @@
jp test
.inc "core.asm"
dummyLabel:
testNum: .db 1
@ -48,30 +46,11 @@ test:
; test that "@" is updated by a .org directive
ld hl, AFTER_ORG
ld de, 0x1234
call cpHLDE
or a ; clear carry
sbc hl, de
jp nz, fail
call nexttest
; *** cpHLDE ***
ld hl, 0x42
ld de, 0x42
call cpHLDE
jp nz, fail
jp c, fail
call nexttest
ld de, 0x4242
call cpHLDE
jp z, fail
jp nc, fail
call nexttest
ld hl, 0x4243
call cpHLDE
jp z, fail
jp c, fail
call nexttest
; success
xor a
halt

查看文件

@ -0,0 +1,42 @@
jp test
.inc "ed/util.asm"
test:
ld sp, 0xffff
; *** cpHLDE ***
ld hl, 0x42
ld de, 0x42
call cpHLDE
jp nz, fail
jp c, fail
call nexttest
ld de, 0x4242
call cpHLDE
jp z, fail
jp nc, fail
call nexttest
ld hl, 0x4243
call cpHLDE
jp z, fail
jp c, fail
call nexttest
; success
xor a
halt
testNum: .db 1
nexttest:
ld a, (testNum)
inc a
ld (testNum), a
ret
fail:
ld a, (testNum)
halt