flat assembler
Message board for the users of flat assembler.

Index > Linux > How to convert some .c source code into .asm?

Author
Thread Post new topic Reply to topic
maeha



Joined: 14 Feb 2004
Posts: 6
Location: Japan
maeha
Hello,

My program needs no echo when reading keyinput.
The following .c program works for that purpose.

#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <string.h>

static struct termios stored_settings;

int main()
{
struct termios new_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ECHO);
tcsetattr(0,TCSANOW,&new_settings);
return 0;
}

But gcc translates:
tcgetattr(0,&stored_settings);
and
tcsetattr(0,TCSANOW,&new_settings);
into
pushl $stored_settings
pushl $0
call tcgetattr
and
pushl %eax
pushl $0
pushl $0
call tcsetattr
respectively.

How can I include them in my fasm source file?
Is it possible to replace them with direct system calls by means of int 0x80?

Thank you in advance.
maeha
Post 24 Mar 2004, 23:11
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
As far as I know (which might be wrong), termios is more than just syscalls, but a whole bunch of library stuff. You could use fasm to assemble to elf, the use the GNU ld linker to link with the proper libraries...

Then again, I might be confusion termios stuff with some of the more fancy terminal stuff.

Under any circumstance I would advice against using syscalls directly - wrap them up in macros or (my personal preferance), create some small wrapper functions for the syscalls. It makes code a lot clearer, and even if you use wrapper functions, the overhead of a bunch of pushes and a call will be entirely lost compared to r3->r0->r3 switching.

I think bazik posted some linux syscall macros, either here or on the win32asm board.
Post 24 Mar 2004, 23:41
View user's profile Send private message Visit poster's website Reply with quote
gorshing



Joined: 27 Jul 2003
Posts: 72
Location: Okla, US
gorshing
f0dder wrote:
I think bazik posted some linux syscall macros, either here or on the win32asm board.


Yes he did, but aaro and jInuQ are making a standard library for fasm, which will work on linux or windows. http://board.flatassembler.net/topic.php?t=1107

_________________
gorshing
Post 26 Mar 2004, 22:10
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Sounds like a good initiative...
Post 27 Mar 2004, 09:27
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.