-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMenu.asm
More file actions
77 lines (73 loc) · 1001 Bytes
/
testMenu.asm
File metadata and controls
77 lines (73 loc) · 1001 Bytes
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "constants.asm"
.org 8000h
ld hl, testMenu
call callFromMenu
ret
; hl - pointer to menu struct
callFromMenu:
push af
push bc
push de
push hl
ld de, menu_prompt
call BLOCKING_SEND
call GET_CHAR
ld c, a ; c - entered char
cfm_loop:
ld b, (hl)
ld a, 0
cp b
jr z, cfm_syntaxError
ld a, c
cp b
inc hl
jr z, cfm_found
inc hl
inc hl
jr cfm_loop
cfm_found:
ld de, cfm_return
push de
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl
jp (hl)
cfm_syntaxError:
ld de, syntaxError_string
call BLOCKING_SEND
cfm_return:
pop hl
pop de
pop bc
pop af
ret
call1:
ld de, call1_string
call BLOCKING_SEND
ret
callA:
ld de, callA_string
call BLOCKING_SEND
ret
syntaxError_string:
.string "Invalid entry\n"
.int8 0
menu_prompt:
.string "---> "
.int8 0
found_string:
.string "found!\n"
.int8 0
call1_string:
.string "Entered 1\n"
.int8 0
callA_string:
.string "Entered a\n"
.int8 0
testMenu:
.int8 '1'
.int16 call1
.int8 'a'
.int16 callA
.int8 0 ; 0 terminated