-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.s
67 lines (62 loc) · 1.67 KB
/
printer.s
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
global printer
extern resume,WorldWidth,WorldLength,state,printf, CORS
section .rodata
print_odd: db "%c ", 0, 0
print_even: db " %c", 0, 0
print_line: db "", 10, 0
print_test: db "%c", 10, 0
section .data
counter: dd 0
counter_width: dd 0
counter_length: dd 0
section .text
printer:
mov esi,0
odd:
mov dword ebx,[counter_width]
mov dword ecx, [WorldLength]
cmp ebx,ecx
je finish_print
push dword [state+esi]
push dword print_odd
call printf
add ESP, 8
add esi,4
inc dword [counter_length]
mov dword ebx,[counter_length]
mov dword ecx, [WorldWidth]
cmp ebx,ecx
jne odd
push dword print_line
call printf
add ESP, 4
mov dword [counter_length],0
inc dword [counter_width]
even:
mov dword ebx,[counter_width]
mov dword ecx, [WorldLength]
cmp ebx,ecx
je finish_print
push dword [state+esi]
push dword print_even
call printf
add ESP, 8
add esi,4
inc dword [counter_length]
mov dword ebx,[counter_length]
mov dword ecx, [WorldWidth]
cmp ebx,ecx
jne even
push dword print_line
call printf
add ESP, 4
mov dword [counter_length],0
inc dword [counter_width]
jmp odd
finish_print:
mov ebx, [CORS]
call resume ; resume scheduler
mov dword [counter],0
mov dword [counter_length],0
mov dword [counter_width], 0
jmp printer