summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGentoo <installgentoo@endianness.com>2020-07-02 10:11:47 +1000
committerGentoo <installgentoo@endianness.com>2020-07-02 10:11:47 +1000
commit84446fea813a0981571da42b00b3587fdb7818bd (patch)
tree71364c9409925d1dadab346a78b6c9cc91457724
parentb0b70829186861c8fe29f95ccd3aa8f0b76c7eb0 (diff)
downloadnextchar-asm-84446fea813a0981571da42b00b3587fdb7818bd.tar.gz
nextchar-asm-84446fea813a0981571da42b00b3587fdb7818bd.tar.bz2
nextchar-asm-84446fea813a0981571da42b00b3587fdb7818bd.zip
minor improvements
-rw-r--r--nextchar.asm21
1 files changed, 11 insertions, 10 deletions
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: