1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-10 02:18:04 +11:00
collapseos/kernel/mmap.asm

47 lines
736 B
NASM
Raw Normal View History

; mmap
;
; Block device that maps to memory.
;
; *** DEFINES ***
; MMAP_START: Memory address where the mmap begins
2019-07-24 13:00:32 +10:00
; Memory address where the mmap stops, exclusively (we aren't allowed to access
; that address).
.equ MMAP_LEN 0xffff-MMAP_START
2019-07-24 13:00:32 +10:00
; 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
2019-07-24 13:00:32 +10:00
ld de, MMAP_LEN
call cpHLDE
jr nc, .outOfBounds ; HL >= DE
ld de, MMAP_START
add hl, de
2019-07-24 13:00:32 +10:00
cp a ; ensure Z
pop de
ret
2019-07-24 13:00:32 +10:00
.outOfBounds:
pop de
jp unsetZ
mmapGetB:
push hl
call _mmapAddr
2019-07-24 13:00:32 +10:00
jr nz, .end
ld a, (hl)
2019-07-24 13:00:32 +10:00
; Z already set
.end:
pop hl
ret
2019-07-24 13:00:32 +10:00
mmapPutB:
push hl
call _mmapAddr
2019-07-24 13:00:32 +10:00
jr nz, .end
ld (hl), a
2019-07-24 13:00:32 +10:00
; Z already set
.end:
pop hl
ret