-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_user.asm
62 lines (59 loc) · 1.44 KB
/
hello_user.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
vector: word: interrupt
message_pointer: word: message
message: word: 'What is your name?'
greeting_pointer: word: greeting
greeting: word: 'Hello, '
exclamation_pointer: word: exclamation
exclamation: word: '!'
in_port: word: 0
out_port: word: 1
flag: word: 0
line_feed: word: 10
start: nop
message_loop: ld (message_pointer)
jz message_loop_end
out out_port
ld message_pointer
inc
st message_pointer
jmp message_loop
; ожидание ввода
message_loop_end: ld line_feed
out out_port
ei
spin_loop: ld flag
jz spin_loop
; вывод приветствия
di
greeting_loop: ld (greeting_pointer)
jz name_loop
out out_port
ld greeting_pointer
inc
st greeting_pointer
jmp greeting_loop
name_loop: ld (buffer_start_pointer)
jz exclamation_printing
out out_port
ld buffer_start_pointer
inc
st buffer_start_pointer
jmp name_loop
exclamation_printing: ld (exclamation_pointer)
out out_port
hlt
interrupt: in in_port ; получение слова из порта ввода
cmp line_feed
jnz continue
ld flag
inc
st flag
jmp returning
continue: st (buffer_pointer)
ld buffer_pointer
inc
st buffer_pointer
returning: iret
buffer_start_pointer: word: buffer
buffer_pointer: word: buffer
buffer: word: 0