ソースを参照

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.
pull/85/head
Virgil Dupras 4年前
コミット
4f7a05e3b7
7個のファイルの変更65行の追加42行の削除
  1. +1
    -0
      apps/ed/glue.asm
  2. +8
    -0
      apps/ed/util.asm
  3. +0
    -9
      kernel/core.asm
  4. +9
    -9
      kernel/fs.asm
  5. +3
    -1
      kernel/mmap.asm
  6. +2
    -23
      tools/tests/unit/test_core.asm
  7. +42
    -0
      tools/tests/unit/test_ed_util.asm

+ 1
- 0
apps/ed/glue.asm ファイルの表示

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

+ 0
- 9
kernel/core.asm ファイルの表示

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


+ 9
- 9
kernel/fs.asm ファイルの表示

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


+ 3
- 1
kernel/mmap.asm ファイルの表示

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


+ 2
- 23
tools/tests/unit/test_core.asm ファイルの表示

@@ -5,8 +5,6 @@

jp test

.inc "core.asm"

dummyLabel:
testNum: .db 1

@@ -48,28 +46,9 @@ test:
; test that "@" is updated by a .org directive
ld hl, AFTER_ORG
ld de, 0x1234
call cpHLDE
jp nz, fail
call nexttest

; *** cpHLDE ***
ld hl, 0x42
ld de, 0x42
call cpHLDE
or a ; clear carry
sbc hl, de
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


+ 42
- 0
tools/tests/unit/test_ed_util.asm ファイルの表示

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

読み込み中…
キャンセル
保存