|
@@ -95,37 +95,29 @@ print_time:
|
95
|
95
|
add dl, 0x30
|
96
|
96
|
mov byte [timestr + 5], dl
|
97
|
97
|
|
98
|
|
- pop rax
|
99
|
98
|
xor rdx, rdx
|
100
|
99
|
mov rcx, 6
|
101
|
100
|
div rcx
|
102
|
101
|
push rax
|
103
|
|
- mov rax, rdx
|
104
|
|
- add al, 0x30
|
105
|
|
- mov byte [timestr + 4], al
|
|
102
|
+ add dl, 0x30
|
|
103
|
+ mov byte [timestr + 4], dl
|
106
|
104
|
|
107
|
|
- pop rax
|
108
|
105
|
xor rdx, rdx
|
109
|
106
|
mov rcx, 10
|
110
|
107
|
div rcx
|
111
|
|
- push rax
|
112
|
|
- mov rax, rdx
|
113
|
|
- add al, 0x30
|
114
|
|
- mov byte [timestr + 2], al
|
|
108
|
+ add dl, 0x30
|
|
109
|
+ mov byte [timestr + 2], dl
|
115
|
110
|
|
116
|
111
|
pop rax
|
117
|
112
|
xor rdx, rdx
|
118
|
113
|
mov rcx, 6
|
119
|
114
|
div rcx
|
120
|
|
- push rax
|
121
|
|
- mov rax, rdx
|
122
|
|
- add al, 0x30
|
123
|
|
- mov byte[timestr + 1], al
|
|
115
|
+ add dl, 0x30
|
|
116
|
+ mov byte[timestr + 1], dl
|
124
|
117
|
|
125
|
118
|
; filling the hours buffer
|
126
|
119
|
; r8 will contain our digits counter : max is 8
|
127
|
120
|
mov r8, 8
|
128
|
|
- pop rax
|
129
|
121
|
print_time_hours_loop:
|
130
|
122
|
mov rcx, 10
|
131
|
123
|
xor rdx, rdx
|
|
@@ -151,18 +143,18 @@ print_time:
|
151
|
143
|
add r8, 1
|
152
|
144
|
cmp r8, 7
|
153
|
145
|
jle print_time_hours_cont
|
154
|
|
- mov r8, 7
|
|
146
|
+ mov r8, 7 ; maximum value for r8
|
155
|
147
|
print_time_hours_cont:
|
156
|
148
|
mov r9, hours
|
157
|
149
|
add r9, r8
|
158
|
150
|
mov rcx, 9
|
159
|
|
- sub rcx, r8
|
160
|
|
- add rcx, timestrlen
|
|
151
|
+ sub rcx, r8 ; rcx is hours size
|
|
152
|
+ add rcx, timestrlen ; add to timestrlen
|
161
|
153
|
|
162
|
154
|
mov rax, 1 ; write
|
163
|
155
|
mov rdi, 1 ; stdout
|
164
|
|
- mov rsi, r9
|
165
|
|
- mov rdx, rcx
|
|
156
|
+ mov rsi, r9 ; start hours pointer
|
|
157
|
+ mov rdx, rcx ; size to timestr end
|
166
|
158
|
syscall
|
167
|
159
|
|
168
|
160
|
; Attempt to read from stdin
|
|
@@ -189,7 +181,7 @@ flush_stdin:
|
189
|
181
|
mov rdx, 1
|
190
|
182
|
syscall
|
191
|
183
|
cmp rax, 0
|
192
|
|
- je newline
|
|
184
|
+ je newline_exit
|
193
|
185
|
jg flush_stdin
|
194
|
186
|
|
195
|
187
|
exit:
|
|
@@ -211,7 +203,7 @@ fault:
|
211
|
203
|
mov rdi, 1 ; failure
|
212
|
204
|
syscall
|
213
|
205
|
|
214
|
|
-newline:
|
|
206
|
+newline_exit:
|
215
|
207
|
mov rax, 1
|
216
|
208
|
mov rdi, 1
|
217
|
209
|
mov rsi, nl
|