-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinter.s
More file actions
91 lines (69 loc) · 1.9 KB
/
printer.s
File metadata and controls
91 lines (69 loc) · 1.9 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
; drone co-rotine, resumed each time and performs one drone step
section .rodata
target_str_format: db "%.2f,%.2f",10,0 ;
drone_str_format : db "%d,%.2f,%.2f,%.2f,%d",10,0;
drone_str : db " drone state : " ,10,0;
format_print_f: db "%.2f",10,0 ; print floating
format_print_s: db "%s",10,0 ; for print string
format_print_d: db "%d",10,0 ;
section .bss
tar_X_offset equ 0
tar_Y_offset equ 8
extern CORS_PTR_ARR
extern DRONES_ARR
extern TARGET_POS
extern NUMCO
DRONE_STRUC_SIZE equ 28
section .data
%macro printTarget_Macro 0
pushad
push dword [TARGET_POS+tar_Y_offset+4]
push dword [TARGET_POS+tar_Y_offset]
push dword [TARGET_POS+tar_X_offset+4]
push dword [TARGET_POS+tar_X_offset]
push target_str_format
call printf
add esp,16
popad
%endmacro
%macro printDrone_Macro 1
pushad
mov esi, %1
mov eax,DRONE_STRUC_SIZE
mov ebx,%1
sub ebx,1
mul ebx ;eax holda offset
mov ebx,[DRONES_ARR]
add ebx,eax ; ebx holds struct pointer
push dword [ebx+24]
push dword [ebx+20]
push dword [ebx+16]
push dword [ebx+12]
push dword [ebx+8]
push dword [ebx+4]
push dword [ebx]
push dword esi
push drone_str_format
call printf
add esp,36
popad
%endmacro
; ------- MACROS: END -------
section .text
extern startCo.resume
global printGameBoard
extern printf
printGameBoard:
printTarget_Macro
mov ecx,[NUMCO] ;ecx holds the num of drones (for loop)
.print_drone_state:
mov esi,[NUMCO]
sub esi,ecx ; esi = current drone position in drones arr (offset)
mov ebx,esi
add ebx,1 ; ebx = current loop iteration, start from 1 (first parameter for macro)
printDrone_Macro ebx
loop .print_drone_state,ecx
mov edi,[CORS_PTR_ARR]
mov ebx,[edi+4] ; moving to ebx the id of the scheduler co-routine
push printGameBoard
jmp startCo.resume