flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Linux > [ncurses] How to call a c function from fasm? | 
| Author | 
 | 
| ManOfSteel 18 Mar 2011, 22:58 Something like
 Code: format ELF public main public stdscr extrn exit extrn initscr extrn wrefresh extrn wprintw extrn wgetch extrn endwin section '.data' writeable msg db 'Hello World !!!',0 stdscr dd ? section '.text' executable main: call initscr ccall wprintw,[stdscr],msg ccall wrefresh,[stdscr] ccall wgetch,[stdscr] call endwin ccall exit,0 ? ccall is available somewhere in the examples directory and in the Windows' include directory, /include/macro/proc32.inc. Or you might want to do it without macros altogether if you like so. | |||
|  18 Mar 2011, 22:58 | 
 | 
| int3h 18 Mar 2011, 23:36 Thanks for the quick reply.
 I'm getting an error while assembling. Code: ccall wprintw, [stdscr], msg ./INCLUDE/MACRO/PROC32.INC [31] ccall [8]: call proc error: undefined symbol 'wprintw'. Shouldn't we specify where the ncurse lib is or something? | |||
|  18 Mar 2011, 23:36 | 
 | 
| ManOfSteel 19 Mar 2011, 00:11 When you link it. | |||
|  19 Mar 2011, 00:11 | 
 | 
| int3h 19 Mar 2011, 01:14 I have no luck getting fasm to assemble the program. Could you please help?
 wprintw is extrn, but why is fasm keep complaining that it's undefined? Btw I'm a noob  | |||
|  19 Mar 2011, 01:14 | 
 | 
| ProphetOfDoom 19 Mar 2011, 03:34 Hi, this works for me (Ubuntu)
 Code: format ELF public _start extrn initscr extrn printw extrn refresh extrn getch extrn endwin extrn exit section '.data' hello db "Hello World !!!",0 section '.text' executable _start: call initscr push dword hello call printw add esp, 4 call refresh call getch call endwin push 0 call exit assemble with: Code: fasm filename.asm link with: Code: ld filename.o -dynamic-linker /lib/ld-linux.so.2 -lc -lcurses run with: Code: 
./a.out
    I don't know why the -dynamic-linker option is necessary btw... another user on this board told me to use it... | |||
|  19 Mar 2011, 03:34 | 
 | 
| int3h 19 Mar 2011, 20:52 Thanks. | |||
|  19 Mar 2011, 20:52 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.