103 lines
1.4 KiB
NASM
103 lines
1.4 KiB
NASM
;;; fshvarset [Bytes]
|
|
;; Sets a Word in FshVars.
|
|
;; Inputs:
|
|
;; HL: 16b
|
|
;; DE: Destination Word Relitive to FshVars
|
|
fshvarset:
|
|
push bc
|
|
push de
|
|
push hl
|
|
ld bc, FshVarsSize / 2 + 1
|
|
call cpBCDE
|
|
jr nc, fshvarsetOOBException
|
|
ld bc, FshVars
|
|
ex de, hl
|
|
add hl, hl
|
|
add hl, bc
|
|
ld (hl), e
|
|
inc hl
|
|
ld (hl), d
|
|
fshvarsetOOBException:
|
|
pop hl
|
|
pop de
|
|
pop bc
|
|
ret
|
|
|
|
;;; fshvarget [Words]
|
|
;; Gets a Word in FshVars.
|
|
;; Inputs:
|
|
;; DE: Destination Word Relitive to FshVars
|
|
;; Outputs:
|
|
;; HL: Word in (DE)
|
|
fshvarget:
|
|
push bc
|
|
push de
|
|
ld hl, 0
|
|
ld bc, FshVarsSize / 2 + 1
|
|
call cpBCDE
|
|
jr nc, fshvargetOOBException
|
|
ld bc, FshVars
|
|
ex de, hl
|
|
add hl, hl
|
|
add hl, bc
|
|
ld e, (hl)
|
|
inc hl
|
|
ld d, (hl)
|
|
ex de, hl
|
|
fshvargetOOBException:
|
|
pop de
|
|
pop bc
|
|
ret
|
|
|
|
; fshvarcpy [Bytes]
|
|
;; Copies a word.
|
|
;; Inputs:
|
|
;; HL: Byte pointer
|
|
;; DE: Destination
|
|
fshvarcpy:
|
|
push bc
|
|
push de
|
|
push hl
|
|
ld bc, FshVarsSize / 2 + 1
|
|
call cpBCDE
|
|
jr nc, fshvarcpyOOBException
|
|
ld bc, FshVars
|
|
add hl, hl
|
|
add hl, bc
|
|
ex de, hl
|
|
add hl, hl
|
|
add hl, bc
|
|
ld a, (de)
|
|
ld (hl), a
|
|
inc de
|
|
inc hl
|
|
ld a, (de)
|
|
ld (hl), a
|
|
fshvarcpyOOBException:
|
|
pop hl
|
|
pop de
|
|
pop bc
|
|
ret
|
|
|
|
; fshvarfill
|
|
;; fills fshvars with word
|
|
;; Inputs:
|
|
;; HL: 16b
|
|
fshvarfill:
|
|
push hl
|
|
push bc
|
|
push de
|
|
ld b, 0
|
|
ld de, 0
|
|
fshvarfillLoop:
|
|
call fshvarset
|
|
inc b
|
|
inc de
|
|
ld a, b
|
|
cp FshVarsSize / 2
|
|
jr c, fshvarfillLoop
|
|
pop de
|
|
pop bc
|
|
pop hl
|
|
ret
|