1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-17 08:28:06 +11:00
collapseos/tools/tests/unit/test_core.asm
Virgil Dupras ae028e3a86 blockdev: make implementors "random access"
This huge refactoring remove the Seek and Tell routine from blockdev
implementation requirements and change GetC and PutC's API so that they
take an address to read and write (through HL/DE) at each call.

The "PTR" approach in blockdev implementation was very redundant from
device to device and it made more sense to generalize. It's possible
that future device aren't "random access", but we'll be able to add more
device types later.

Another important change in this commit is that the "blockdev handle" is
now opaque. Previously, consumers of the API would happily call routines
directly from one of the 4 offsets. We can't do that any more. This
makes the API more solid for future improvements.

This change forced me to change a lot of things in fs, but overall,
things are now simpler. No more `FS_PTR`: the "device handle" now holds
the active pointer.

Lots, lots of changes, but it also feels a lot cleaner and solid.
2019-06-04 15:36:20 -04:00

100 lines
1.1 KiB
NASM

jp test
#include "core.asm"
testNum: .db 1
test:
ld hl, 0xffff
ld sp, hl
; *** Just little z80 flags memo.
and a ; clear carry
ld hl, 100
ld de, 101
sbc hl, de
jp nc, fail ; carry is set
call nexttest
and a ; clear carry
ld hl, 101
ld de, 100
sbc hl, de
jp c, fail ; carry is reset
call nexttest
ld a, 1
dec a
jp m, fail ; positive
dec a
jp p, fail ; negative
call nexttest
; *** subHL ***
ld hl, 0x123
ld a, 0x25
call subHL
ld a, h
cp 0
jp nz, fail
ld a, l
cp 0xfe
jp nz, fail
call nexttest
ld hl, 0x125
ld a, 0x23
call subHL
ld a, h
cp 1
jp nz, fail
ld a, l
cp 0x02
jp nz, fail
call nexttest
ld hl, 0x125
ld a, 0x25
call subHL
ld a, h
cp 1
jp nz, fail
ld a, l
cp 0
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
nexttest:
ld a, (testNum)
inc a
ld (testNum), a
ret
fail:
ld a, (testNum)
halt