; Version : 1.1 ; Updated : 2/7/2020 ; Description : NextChar program. Quite slowly fills up a buff in static memory with a char, a space and then the next char etc ; License : GPLv3+ ;; static memory is nicer to use than the stack section .bss buff resb 257 ;space for 128 characters + 128 spaces + newline bufflen equ $-buff section .text global _start _start: mov eax,0x0 ;start character mov ecx,128 ;number of times to print xor ebx,ebx ;counter register for position in Buff loop: mov byte[buff+ebx],al ;The character in eax is copied to Buff (very slow) mov byte[buff+ebx+1],' ';A space is copied after the character inc eax ;go to next ASCII character add ebx,2 ;Add 2 to ebx, so it now points to after the space dec ecx ;deincrement ecx since we just copied a character test ecx,ecx ;test if ecx is zero jnz loop ;jump to loop to copy the next character if ecx is not zero mov byte[buff+ebx-1],0xA ;add the newline (-1 overwrites the last space) mov eax,1 ;sys_write mov edi,1 ;fd = STDOUT_FILENO mov edx,bufflen ;num of bytes to print mov rsi,buff ;where the characters are located syscall Exit: mov eax,60 ;code for sys_exit xor edi,edi ;Return value of 0 syscall ;Do sys_exit