-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.s
More file actions
156 lines (143 loc) · 2.38 KB
/
Copy pathgraph.s
File metadata and controls
156 lines (143 loc) · 2.38 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
.include "sys_call-inl.s"
.include "consts-inl.s"
.extern putchar
.global draw_col_line
.global draw_row_line
.global draw_rect
.global draw_elem
.text
#=======================
#-----------------------
# func draw_col_line
# char_to_draw: %dl
# start : row/y1(%ax), col/x1=%bx
# count : %ecx (y1 + i, x1)
.type draw_col_line, @function
draw_col_line:
1:
pushl %ecx
pushw %ax
pushw %bx
pushw %dx
movb %dl, %cl
call putchar
popw %dx
popw %bx
popw %ax
popl %ecx
incw %ax
loop 1b
ret
#-----------------------
# func draw_row_line
# char_to_draw: %dl
# start: row/y1(%ax), col/x1=%bx
# count: %cx (y1, x1 + i)
.type draw_row_line, @function
draw_row_line:
1:
pushl %ecx
pushw %ax
pushw %bx
pushw %dx
movb %dl, %cl
call putchar
popw %dx
popw %bx
popw %ax
popl %ecx
incw %bx
loop 1b
ret
#-----------------------
# func draw_rect
# start : row(%ax), col(%bx)
# width : %cl
# height : %ch
# row char: %dl
# col char: %dh
.type draw_rect, @function
draw_rect:
# top
pushw %ax
pushw %bx
pushw %cx
pushw %dx
movzbl %cl, %ecx
call draw_row_line
popw %dx
popw %cx
popw %bx
popw %ax
# bottom
pushw %ax
pushw %bx
pushw %cx
pushw %dx
movzbw %ch, %si
addw %si, %ax
dec %ax
movzbl %cl, %ecx
call draw_row_line
popw %dx
popw %cx
popw %bx
popw %ax
# left
pushw %ax
pushw %bx
pushw %cx
pushw %dx
movzbl %ch, %ecx
movb %dh, %dl
call draw_col_line
popw %dx
popw %cx
popw %bx
popw %ax
# right
pushw %ax
pushw %bx
pushw %cx
pushw %dx
movzbw %cl, %si
addw %si, %bx
dec %bx
movzbl %ch, %ecx
movb %dh, %dl
call draw_col_line
popw %dx
popw %cx
popw %bx
popw %ax
ret
#-----------------------
# func draw_elem
# elem char: cl
# elem pointer: esi
.type draw_elem, @function
draw_elem:
movw ELEM_OFFSET_ROW(%esi), %ax
movw ELEM_OFFSET_COL(%esi), %bx
movw ELEM_OFFSET_COUNT(%esi), %di
# skip to item
addl $ELEM_OFFSET_ITEM, %esi
draw_elem_again:
push %ax
push %bx
push %cx
push %esi
push %di
addw (%esi), %ax
addw 2(%esi), %bx
call putchar
pop %di
pop %esi
pop %cx
pop %bx
pop %ax
# skip row/col offset
addl $4, %esi
dec %di
jnle draw_elem_again
ret