flat assembler
Message board for the users of flat assembler.

Index > Linux > linux and the c library

Author
Thread Post new topic Reply to topic
ackit



Joined: 08 Sep 2008
Posts: 3
ackit 08 Sep 2008, 10:07
i was hoping if someone could show me a simple example of using printf with fasm on linux.
Post 08 Sep 2008, 10:07
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 08 Sep 2008, 10:11
The libcdemo example in the fasm download shows how to use printf.
Code:
; fasm example of using the C library in linux

; compile the source with commands like:
;   fasm libcdemo.asm libcdemo.o
;   gcc libcdemo.o -o libcdemo
;   strip libcdemo

format ELF

include 'cdecl.inc'

section '.text' executable

 public main
 extrn printf
 extrn getpid

 main:
  call    getpid
      ccall   printf, msg,eax
     ret

section '.data' writeable

 msg db "Current process ID is %d.",0xA,0    
Post 08 Sep 2008, 10:11
View user's profile Send private message Visit poster's website Reply with quote
ackit



Joined: 08 Sep 2008
Posts: 3
ackit 08 Sep 2008, 19:22
ahh yes, thank you very much, got it working.
Post 08 Sep 2008, 19:22
View user's profile Send private message MSN Messenger 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.