1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-08 09:58:06 +11:00
collapseos/kernel/mmap.asm
Virgil Dupras 4f7a05e3b7 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.
2019-12-12 15:53:14 -05:00

49 lines
791 B
NASM

; mmap
;
; Block device that maps to memory.
;
; *** DEFINES ***
; MMAP_START: Memory address where the mmap begins
; Memory address where the mmap stops, exclusively (we aren't allowed to access
; that address).
.equ MMAP_LEN 0xffff-MMAP_START
; Returns absolute addr of memory pointer in HL if HL is within bounds.
; Sets Z on success, unset when out of bounds.
_mmapAddr:
push de
ld de, MMAP_LEN
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
pop de
ret
.outOfBounds:
pop de
jp unsetZ
mmapGetB:
push hl
call _mmapAddr
jr nz, .end
ld a, (hl)
; Z already set
.end:
pop hl
ret
mmapPutB:
push hl
call _mmapAddr
jr nz, .end
ld (hl), a
; Z already set
.end:
pop hl
ret