-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUB.s
51 lines (37 loc) · 998 Bytes
/
SUB.s
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
41
42
43
44
45
46
47
48
49
50
51
ROM EQU 0000H
RAM EQU 8000H
ORG RAM
X: DS 2
Y: DS 2
Z: DS 2
; MAIN
ORG ROM
LD SP, RAM+0FFFH
CALL SUB_XY
HALT
; SUB_XY
SUB_XY:
PUSH AF
PUSH DE
PUSH HL
; AND命令が呼ばれるとCフラグはリセットされる
LD A, 00H
AND A
LD HL, (X)
LD DE, (Y)
SBC HL, DE
LD (X),HL
; オーバーフロー処理
JP M, SUB_OVERFLOW
LD A, H
CP 28H
JP P, SUB_OVERFLOW
POP HL
POP DE
POP AF
RET
SUB_OVERFLOW:
LD HL, 0FFFFH
LD (X), HL
HALT
END