As a result of a alternate method deliniated by Edward, overhead has been reduced from 168 bytes to 56 a 300% saving.
~$ nasm -felf64 appname.asm -oappname.o
~$ ld appname.o -oappname
USE64 TIOCGWINSZ equ 0x5413 STDOUT_FILENO equ 1 sys_ioctl equ 16 sys_exit equ 60 global _start section .text; ============================================================================= _start: %define argc [rbp+ 8] %define args [rbp+16] push rbp ; So argc & **args can easily be. mov rbp, rsp ; addressed via base pointer. xor eax, eax mov edx, winsize ; Point to structure. mov esi, TIOCGWINSZ ; Read structure. mov edi, eax mov di, STDOUT_FILENO mov al, sys_ioctl syscall test ax, ax ; If there is an error just bail. jnz Exit ; because the likelihood slim to none. ; ws_xpixel & ws_ypixel are of no conseqence, so they will be overwritten ; with condition bits. Semicolon denotes bit position ; ws_xpixel:0 != 1 Windows has fewer than 43 rows. ; wx_xpixel:1 != 1 132 cols. cld ; Just to be sure of auto increment. mov esi, edx ; Move to source index for LODSW. mov edx, eax ; Applications status bits (flags). lodsw ; Read rows from ws_row. sub ax, 43 ; Minimum rows expected. jns $ + 5 ; Skips over next instruction. or dl, 1 ; Set bit zero (rows below minimum). lodsw ; Read columns from ws_col sub ax, 132 ; Minimum columns expected. jns $ + 5 ; Skips over next instruction. or dl, 2 ; Set bit columns below minimum. ; Save new data where ws_xpixel was and erase any extraneous ; data @ ws_ypixel mov [rsi], edx ; Overwrite ws_xpixel & ws_ypixel. Exit: leave ; Kill empty procedure frame. xor edi, edi ; Set return code EXIT_SUCCESS. mov eax, sys_exit syscall ; Terminate application section .bss; ============================================================================= winsize: .ws_row resw 1 .ws_col resw 1 .ws_xpixel resw 1 .ws_ypixel resw 1