flat assembler
Message board for the users of flat assembler.

Index > Linux > How to loop?

Author
Thread Post new topic Reply to topic
Rock24



Joined: 13 Feb 2015
Posts: 5
Rock24 20 Feb 2015, 00:15
Hello.
I would like to display 10 times text on the screen

Code:
format ELF64 executable  
entry _start 
segment readable executable
_start:
        mov rcx,1
loo:
        cmp rcx, 10
        jae endd
        
        mov rax,1
        mov rdi,1
        mov rsi,abc
        mov rdx,[dlg]
        syscall
        add rcx,1
        jmp loo
endd:

mov rax,60
syscall


segment writeable executable
abc db "abc", 0ah
dlg dq $ - abc
    


This code displays txt only once. What am I doing wrong?
Post 20 Feb 2015, 00:15
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 20 Feb 2015, 00:17
loopnz
Post 20 Feb 2015, 00:17
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Feb 2015, 00:22
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 17:54; edited 1 time in total
Post 20 Feb 2015, 00:22
View user's profile Send private message Reply with quote
Rock24



Joined: 13 Feb 2015
Posts: 5
Rock24 20 Feb 2015, 00:29
Thank you HaHaAnonymous, typedef.
I was sure that 'syscall' destroy only rax Smile
Post 20 Feb 2015, 00:29
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Feb 2015, 00:34
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 17:54; edited 1 time in total
Post 20 Feb 2015, 00:34
View user's profile Send private message Reply with quote
Rock24



Joined: 13 Feb 2015
Posts: 5
Rock24 20 Feb 2015, 00:52
I have one question yet.
What if i use cx register instead rcx? This will change something in the loop / code?
Post 20 Feb 2015, 00:52
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Feb 2015, 01:00
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 17:54; edited 1 time in total
Post 20 Feb 2015, 01:00
View user's profile Send private message Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 215
Location: %x
badc0de02 20 Feb 2015, 01:57
so CX are the first 16 bits of the ecx Register and ecx the first 32 of the rax register
if rcx gets destroyed the other will get too
Post 20 Feb 2015, 01:57
View user's profile Send private message Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens 20 Feb 2015, 02:06
http://www.logix.cz/michal/devel/amd64-regs/
good table

@badc0de02
"first 32 bits of rcx register"* Smile
Post 20 Feb 2015, 02:06
View user's profile Send private message Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 28 May 2015, 20:59
Was being an idiot. As such, this post has been removed.

_________________
It may look hard, but it won't take long if you take it one byte at a time.

NOS: www.github.com/nkeck720/nos
Post 28 May 2015, 20:59
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.