From 84446fea813a0981571da42b00b3587fdb7818bd Mon Sep 17 00:00:00 2001 From: Gentoo Date: Thu, 2 Jul 2020 10:11:47 +1000 Subject: minor improvements --- nextchar.asm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'nextchar.asm') diff --git a/nextchar.asm b/nextchar.asm index 9db34d5..689f168 100644 --- a/nextchar.asm +++ b/nextchar.asm @@ -1,22 +1,23 @@ -; Version : 1.0 -; Updated : 17/6/2020 +; 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 ;; static memory is nicer to use than the stack section .bss - Buff resb 52 ; space for 26 characters + 25 spaces + newline + buff resb 257 ;space for 128 characters + 128 spaces + newline + bufflen equ $-buff section .text global _start _start: -mov eax,'a' ;start character -mov ecx,26 ;number of times to print +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 +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 @@ -25,12 +26,12 @@ 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 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,52 ;num of bytes to print -mov rsi,Buff ;where the characters are located +mov edx,bufflen ;num of bytes to print +mov rsi,buff ;where the characters are located syscall Exit: -- cgit v1.2.3