flat assembler
Message board for the users of flat assembler.
Index
> Linux > Array |
Author |
|
alkap 16 Mar 2015, 11:05
I could be wrong, but perhaps the code below might do the trick. I'm not familiar with the x86-64 syscall calling convention, nor do I have access to an x86-64 machine, so I haven't been able to test my suggestion:
Code: ... mov rax,1 mov rdi,1 mov rsi, byte [table+1] mov rdx, 1 syscall ... Can you please give this a try and let us know how you go. |
|||
16 Mar 2015, 11:05 |
|
HaHaAnonymous 16 Mar 2015, 16:19
Quote:
If it is a table, then you may want an aligned table of strings... Because strings can have varying lengths. Code: format ELF64 executable ;wersja pliku entry _start segment readable executable _start: mov rcx,table mov rax,1 mov rdi,1 ; writes the 2nd item lea rsi,[rcx+32+8] mov rdx,[rcx+32] syscall mov rax,60 syscall segment readable writeable x = 32 align x ; alignment 32 is enough in this case because no item exceeds 32 bytes, in case one of your strings does, align to higher boundaries table: dq $0000000000000002 db ":D" align x dq $0000000000000004 db "woof" align x dq $000000000000000A db "woof woof!" align x dq $0000000000000003 db "o_O" or alternatively this method: Code: format ELF64 executable ;wersja pliku entry _start segment readable executable _start: mov rcx,table mov rax,1 mov rdi,1 ; writes the 2nd item mov rsi,[rcx+8*1] mov rdx,[rsi-8] syscall mov rax,60 syscall segment readable writeable x = 8 align x table: dq data0+x dq data1+x dq data2+x dq data3+x align x data0: dq $02 db ":D" align x data1: dq $04 db "woof" align x data2: dq $0A db "woof woof!" align x data3: dq $03 db "o_O" Not sure. |
|||
16 Mar 2015, 16:19 |
|
Endre 22 Mar 2015, 11:55
I guess the OP wants something like this
Code: format ELF64 executable ;wersja pliku entry _start segment readable executable _start: mov rax,1 mov rdi,1 mov rsi,table+1 mov rdx,1 syscall mov rax,60 syscall segment readable writeable table db "1","2","3","4" dlugosc dq $ - table |
|||
22 Mar 2015, 11:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.