flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > Linux 64 FASM coding

Author
Thread Post new topic Reply to topic
Feryno



Joined: 23 Mar 2005
Posts: 444
Location: Czech republic, Slovak republic
Hello, hot and necessary package for every Linux64 Flat Assembler coder.
One big please to Tomasz Grysztar - would you update Hello64 sample, please?
The way of asm coding in memory over old 32-bit limit is by syscall, but not int80 because int80 isn't able to access memory over 32-bit (maybe truncate 64-bit reg to 32-bit ?)
Of course int80 works perfectly up to 32-bit memory limit.

Code:
; fasm demonstration of writing 64-bit ELF executable

; syscall numbers: /usr/src/linux/include/asm-x86_64/unistd.h
; parameters order:
; r9    ; 6th param
; r8    ; 5th param
; r10   ; 4th param
; rdx   ; 3rd param
; rsi   ; 2nd param
; rdi   ; 1st param
; eax   ; syscall_number
; syscall

format ELF64 executable at 0000000100000000h    ; put image over 32-bit limit

segment readable executable

entry $

        mov     edx,msg_size    ; CPU zero extends 32-bit operation to 64-bit
                                ; we can use less bytes than in case mov rdx,...
        lea     rsi,[msg]
        mov     edi,1           ; STDOUT
        mov     eax,1           ; sys_write
        syscall

        xor     edi,edi         ; exit code 0
        mov     eax,60          ; sys_exit
        syscall

segment readable writeable

msg db 'Hello 64-bit world!',0xA
msg_size = $-msg
    


Description: FASM Linux64 samples
Download
Filename: fasm_amd64_linux64_p000.tar.gz
Filesize: 107.67 KB
Downloaded: 93 Time(s)

Post 23 Apr 2006, 09:54
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 444
Location: Czech republic, Slovak republic
and here debugger for fasm coding under Linux64
http://board.flatassembler.net/topic.php?p=38108#38108
Post 28 Apr 2006, 11:21
View user's profile Send private message Visit poster's website ICQ Number 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-2018, Tomasz Grysztar.

Powered by rwasa.