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 section .data ha dw 0 ;hundreds ta dw 0 ;tens 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 ;mov [ha], dword 0x0 ;mov [ta], dword 0x0 ; print rows hundreds: mov ecx, [sz+0] ;rows in ecx cmp ecx, 100 ;check if above 100 jge inchundred ;jump to increment hundreds if needed 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, 10 ;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], dword 0xa ;linebreak mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, num mov edx, 4 int 0x80 ; print cols ;add [sz+2],'0' mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, sz+2 mov edx, 3 int 0x80 exit: ;exit mov eax, 1 mov ebx, 0 int 0x80 inchundred: inc dword [ha] ;increment hundreds sub ecx, 100 jmp hundreds inctens: inc dword [ta] ;increment hundreds sub ecx, 10 jmp tens