Skip to content

Commit e2e8f3c

Browse files
committed
group3: print_lines working
1 parent f106ec6 commit e2e8f3c

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

group3/group3.s

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,25 +165,21 @@ print_lines:
165165
print_lines_loop:
166166

167167
push %rbx
168-
log %rbx
169168
call read_line
170169

171170
add %rax, %rbx
172171

173-
174-
push linebuf(%rip)
175-
plop
172+
write linebuf(%rip), %rax
173+
writeln
176174
plop
177175

178176

179177
inc %rbx
180178

181-
cmp $30, %rbx
179+
cmp file_size(%rip), %rbx
182180

183181
jl print_lines_loop
184182
print_lines_done:
185-
push $0x31
186-
call write_char_debug
187183
pop_all
188184
return
189185

print_int/print_int.s

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,33 @@
1313
add $8, %rsp
1414
.endm
1515

16+
.macro plopp
17+
add $16, %rsp
18+
.endm
19+
1620
.macro log ex
1721
push \ex
1822
call print_int
1923
add $8, %rsp
2024
.endm
2125

26+
.macro debug char
27+
push \char
28+
call write_char_debug
29+
add $8, %rsp
30+
.endm
31+
32+
.macro write address size
33+
push \address
34+
push \size
35+
call write_string
36+
add $16, %rsp
37+
.endm
38+
39+
.macro writeln
40+
call write_newline
41+
.endm
42+
2243
.macro return
2344
mov %rbp, %rsp
2445
pop %rbp
@@ -86,7 +107,7 @@ write_newline:
86107
push_all
87108
push $0xa
88109
call write_char
89-
pop %rax
110+
plop
90111
pop_all
91112
return
92113

0 commit comments

Comments
 (0)