-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.asm
40 lines (35 loc) · 862 Bytes
/
util.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#local
;--------
; Compare memory at (HL) to (DE) for B bytes
; Set's Z flag to results
; Pointers left on first byte not to match
MEMCMP::
LD A, (DE)
CP (HL)
RET NZ ; If bytes don't match return with Z flag clear
INC HL
INC DE
DJNZ MEMCMP
RET ; Z flag still set from CP
;-----------------------------------------------------------------------
; Normalize far address C:HL to be in the low bank
; with C only being in the low 4 bits
;-----------------------------------------------------------------------
NORMAL_ADDR::
#local
LD A, H
AND 80h
JR Z, LOWBANK
SRL C \ SRL C
SRL C \ SRL C ; High bank to low bank
LD A, H
AND 7Fh ; Convert address to be for low bank
LD H, A
LOWBANK:
LD A, C
AND 0Fh ; Make sure only low bank listed
LD C, A
RET
#endlocal
;-----------------------------------------------------------------------
#endlocal