SYS_EXIT equ 1 SYS_READ equ 3 SYS_WRITE equ 4 STDIN equ 0 STDOUT equ 1 SYS_IOCTL equ 54 section .bss sz RESB 4 ; 4 byte for window size num resb 4 ;4 byte for ascii numbers srow resb 1; scol resb 1; section .data ha db 0 ;hundreds ta db 0 ;tens rcount db 0; lb db 0xa; linebrak tof db 0; ; top offset lof db 0; ; left offset gh db 42; ; game height gw db 102; ; game width scrst db 'Score: 000' ; score string scrstln equ $ - scrst ; sore string length scrlof equ 5 ;score lfet offset scrfll equ 85 ;score lfet offset pls db 0x2b ;plus for corner hl db 0x2d ;horizontal line | vl db 0x7c ;vertical line - section .text global _start _start: ; get windwo size mov eax, SYS_IOCTL ; syscall ioctl mov ebx, STDOUT ; stdout for something? mov ecx, 0x5413 ; get windowsize command TIOCGWINSZ mov edx, sz ; target struct int 0x80 ; call kernel ;print fullscreen ;save window size mov al, [sz] mov [srow], al mov al, [sz+2] mov [scol], al call print jmp exit ;calc offset ;top mov ax, [srow] sub ax, [gh] mov cl, [0x2] div cl mov [tof], al ;left mov ax, [scol] sub ax, [gw] mov bl, 0x2 div bl mov [lof], al ;print terminal print: topoffset: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, lb mov edx, 1 int 0x80 inc byte [rcount] mov al, [rcount] cmp al, [tof] jl topoffset toprow: tlcorner: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, pls mov edx, 1 int 0x80 tr_start: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, hl mov edx, 1 int 0x80 inc byte [rcount] mov al, [rcount] cmp al, scrlof jl tr_start mov al, 0 mov [rcount], al tr_score: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, scrst mov edx, scrstln int 0x80 tr_fill: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, hl mov edx, 1 int 0x80 inc byte [rcount] mov al, [rcount] cmp al, scrfll jl tr_fill trcorner: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, pls mov edx, 1 int 0x80 linebreak: mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, lb mov edx, 1 int 0x80 exit: ;exit mov eax, 1 mov ebx, 0 int 0x80 ; print rows mov ecx, 0 mov cl, [sz] ;rows in ecx hundreds: mov ebx, 100 cmp ecx, ebx ;check if above 100 js bla jae inchundred ;jump to increment hundreds if needed bla: mov eax,[ha] ;hundred count to eax add eax, '0' ;convert to ascii mov [num+0], eax ;move to first byte of num string tens: cmp ecx, 0xa ;check if above 10 jge inctens ;jump to increment tens if needed mov eax,[ta] add eax, '0' mov [num+1], eax mov eax, ecx add eax, '0' mov [num+2], eax mov [num+3], byte 0xa ;linebreak mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, num mov edx, 4 int 0x80 ;print hundreds ;mov eax, [ha] ;add eax, '0' ;mov[ha], eax ;mov eax, SYS_WRITE ;mov ebx, STDOUT ;mov ecx, ha ;mov edx, 1 ;int 0x80 ; print cols ;mov eax, SYS_WRITE ;mov ebx, STDOUT ;mov ecx, sz+2 ;mov edx, 3 ;int 0x80 inchundred: inc byte [ha] ;increment hundreds sub ecx, 0x64 jmp hundreds inctens: inc byte [ta] ;increment tens sub ecx, 0xa jmp tens