diff --git a/bin/main b/bin/main index 5830395..a2cec38 100755 Binary files a/bin/main and b/bin/main differ diff --git a/src/main.asm b/src/main.asm index cd1f7c0..56b0039 100644 --- a/src/main.asm +++ b/src/main.asm @@ -1,19 +1,60 @@ section .data + tile db "[ ]", 0 + tile_len equ $ - tile + newline db 0xA, 0 + newline_len equ $ - newline section .bss + board resb 100 section .text global _main _main: + xor r10, r10 ; Clear r10 for use as a counter + mov rbx, 10 ; Set divisor to 10 - ; Lets create a 2D array of 10x10 - ; 0 = empty - ; 1 = bomb - ; 2 > number of bombs around + lea r8, [rel tile] ; Buffer address + mov r9, tile_len ; Length of the string +loop_start: + cmp r10, 100 + jae loop_end + + inc r10 ; Increment the counter + + call print_String + + mov rax, r10 + xor rdx, rdx ; Clear rdx for division + div rbx ; Divide rax by rbx (unsigned division) + + cmp r10, 0 + je no_newline + + cmp rdx, 0 + jne no_newline + lea r8, [rel newline] ; Newline character + mov r9, newline_len ; Length of the newline + call print_String + lea r8, [rel tile] ; Buffer address + mov r9, tile_len ; Length of the string +no_newline: + jmp loop_start +loop_end: mov rax, 0x2000001 ; syscall: exit xor rdi, rdi ; status: 0 syscall +; Function to print a string +; Arguments: +; r8 - pointer to the string +; r9 - length of the string +print_String: + mov rax, 0x2000004 ; syscall: write + mov rdi, 1 ; file descriptor: stdout + mov rsi, r8 ; pointer to the string + mov rdx, r9 ; length of the string + syscall + ret \ No newline at end of file