-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread.asm
More file actions
97 lines (90 loc) · 1.85 KB
/
Copy pathread.asm
File metadata and controls
97 lines (90 loc) · 1.85 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;; Copyright (C) 2025 Florian Marrero Liestmann
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;; Author: Florian Marrero Liestmann <f.m.liestmann@fx-ttr.de>
;; File: read.asm
[BITS 16]
_advance: ; __la <- next key, echoed; CR also echoes LF
mov ah, 0x00
int 0x16 ; wait for key -> AL
call _print_char
cmp al, 0x0D
jne .store
mov al, 0x0A
call _print_char
.store:
mov [__la], al
ret
_skip_ws: ; -> AL = first lookahead above ' '
mov al, [__la]
cmp al, ' '
ja .ret
call _advance
jmp _skip_ws
.ret:
ret
parse_expr:
call _skip_ws
cmp al, '('
je .list
.atom:
mov di, [__names_ptr]
.copy:
stosb
call _advance
mov al, [__la]
cmp al, ')'
ja .copy
xor al, al
stosb
mov bx, __names
.scan:
mov si, bx
mov di, [__names_ptr]
.cmp:
lodsb
scasb
jne .next
or al, al
jnz .cmp
mov ax, bx ; match; commit if it is the new copy
cmp bx, [__names_ptr]
jne .ret
mov [__names_ptr], di
.ret:
ret
.next:
lodsb ; skip SI to the start of the next name
or al, al
jnz .next
mov bx, si
jmp .scan
.list:
call _advance ; consume the (
.tail:
call _skip_ws
cmp al, ')'
jne .item
call _advance ; consume the )
xor ax, ax
ret
.item:
call parse_expr
push ax
call .tail ; parse the rest of the list
mov dx, ax
pop ax
jmp cons
__la: db ' '