-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_adv.inc
120 lines (91 loc) · 2.27 KB
/
print_adv.inc
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
;Old, doesn't work as GUI
;sequent, indent
indent equ r13
fbound
print_seq:
save r12,r13
mov sequent, arg1
mov indent, arg2
do_indent
cinvoke printf, s_seq, sequent
inc indent
do_indent
cinvoke printf, s_side_t
ccall print_side, tside, tlen, indent
do_indent
cinvoke printf, s_side_f
ccall print_side, fside, flen, indent
do_indent
cmp child1, NULL
je .no_childs
cinvoke puts, s_seq_childs
inc indent
ccall print_seq, child1, indent
cmp [sequent+SEQUENT.child2], NULL
je .one_child
ccall print_seq, child2, indent
restX
ret
.no_childs:
movzx arg2, state
cinvoke printf, s_seq_state
.one_child:
restX
ret
restore indent
;side, len, indent
side equ r12
len equ r13
indent equ r14
fbound
print_side:
save r12,r13,r14,r15
mov side, arg1
mov len, arg2
mov indent, arg3
do_indent
cinvoke printf, s_side, side
cinvoke printf, s_side_terms, len
inc indent
xor r15,r15
align 16
@@:
cmp r15, len
je @f
ccall print_term, qword[side+r15*8], indent
inc r15
jmp @b
@@:
restX
ret
restore side,len,indent
;term, indent
term equ r12
indent equ r13
fbound
print_term:
save r12,r13,r15
mov term, arg1
mov indent, arg2
do_indent
cinvoke printf, s_term, term
movzx arg2, [term+TERM.type]
cinvoke printf, s_term_type
inc indent
cmp [term+TERM.type], TERM_VAR
jne @f
;if TERM_VAR
do_indent
lea r15, [term+TERM.t1] ;var name
cinvoke puts, r15
jmp .ret
@@: ;if not TERM_VAR
ccall print_term, [term+TERM.t1], indent ;print t1
cmp byte[term+TERM.type], TERM_NOT
jbe .ret
;if has t2
ccall print_term, [term+TERM.t2], indent ;print t2
.ret:
restX
ret
restore term,indent