Linux asm coding *without* C? 
Author Message
 Linux asm coding *without* C?

Hi all,

I have a book on assembly coding, which has a chapter on coding for
Linux. The book makes a point at saying that while Linux does have a
whole bunch of functions you can call with int 80, that (unlike DOS)
these guys aren't written in stone, and the preferred method is to make
calls to C runtime functions.

That to a useful (though inaccurate) treatment of stack frames, which I
never took the time to understood before, so I'm happy. But it occurs to
me that sticking to the C runtime means 1) everything's going to be
slower, because I'm doing all my argument passing via the stack rather
than in regs, and 2) I'm forced to link in the C runtime. The book uses
gcc as the linker, by the way, but nasm rather than gas as the assembler

Now, isn't it possible that for reasons of speed and/or code size I'd want
to code assembler *without* the C stuff? If so, I'm guessing that I'd
make two changes: start using int 80, and find another linker (or another
option for gcc maybe).

Does this all sound right? This is mostly a mental exercise -- I'll
probably never have to do this -- but I'd be ever so happy to learn I'm
thinking about this correctly.

Thank you Thank you,
CC



Wed, 07 Jul 2004 00:55:52 GMT  
 Linux asm coding *without* C?

Quote:
> Hi all,

Hi

Quote:
> I have a book on assembly coding, which has a chapter on coding for
> Linux. The book makes a point at saying that while Linux does have a
> whole bunch of functions you can call with int 80, that (unlike DOS)
> these guys aren't written in stone, and the preferred method is to make
> calls to C runtime functions.

That's probably right. But int 80 isn't that bad though.

Quote:
> That to a useful (though inaccurate) treatment of stack frames, which I
> never took the time to understood before, so I'm happy. But it occurs to
> me that sticking to the C runtime means 1) everything's going to be
> slower, because I'm doing all my argument passing via the stack rather
> than in regs, and 2) I'm forced to link in the C runtime. The book uses
> gcc as the linker, by the way, but nasm rather than gas as the assembler

I see.

Quote:
> Now, isn't it possible that for reasons of speed and/or code size I'd want
> to code assembler *without* the C stuff? If so, I'm guessing that I'd
> make two changes: start using int 80, and find another linker (or another
> option for gcc maybe).

I think you're right.
You can use 'ld' as linker.

Quote:
> Does this all sound right? This is mostly a mental exercise -- I'll
> probably never have to do this -- but I'd be ever so happy to learn I'm
> thinking about this correctly.

It sounds right for me!
Good luck ;)


Wed, 07 Jul 2004 15:55:52 GMT  
 Linux asm coding *without* C?

Quote:

> Now, isn't it possible that for reasons of speed and/or code size I'd want
> to code assembler *without* the C stuff? If so, I'm guessing that I'd

certainly, re:
        http://linuxassembly.org
        http://home.snafu.de/phpr/lhpsyscal.html
        http://home.snafu.de/phpr/lhpf8.html   (a dll in asm)

regrads,
        hp

(reply to addr, below)
--

Linux,Assembly,Forth: http://home.snafu.de/phpr/index-lx.shtml (en,de)
Verwendung zu kommerziellen Zwecken gem. Par.28 Abs.3 BDSG untersagt.



Wed, 07 Jul 2004 15:55:53 GMT  
 Linux asm coding *without* C?


Quote:
>Hi all,

>I have a book on assembly coding, which has a chapter on coding for
>Linux. The book makes a point at saying that while Linux does have a
>whole bunch of functions you can call with int 80, that (unlike DOS)
>these guys aren't written in stone, and the preferred method is to make
>calls to C runtime functions.

Well, the author is write, the INT 80H functions are not
immutable.  *However* the likelihood that they will change
is probably quite low.  Unless all C standard library functions
invoke the OS through Linux's shared library facilities (possible,
but I don't think this is universally the case), changing the INT 80H
functions would break a heck of a lot of C code.
In any case, I'm sure there are many huge political problems
with changing the INT 80h interface at this date.
It's quite possible that a different (better) interface will
come along in the future, but you can bet that Linux will
continue to support INT 80H for about as long as Microsoft
continues to support INT 21H in the DOS emulation system.
Randy Hyde


Fri, 09 Jul 2004 05:55:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Making std asm code into Turbo Asm code?

2. asm code: Win95->ok but crashes on Linux

3. asm code:Win95->Ok but crashes on Linux

4. Convert DOS asm code to Linux

5. assume cs:code,ds:code

6. Win32 asm/Linux asm newsgroups?

7. Win32 asm/Linux asm newsgroups?

8. ASM compiler in asm-code

9. to CS: or not to CS: in F-PC assembler

10. Initializing DX to Code Segment(CS) Memory Address...?!?

11. Linking asm code to C++ code

12. Initializing DX to Code Segment(CS) Memory Address…?!?

 

 
Powered by phpBB® Forum Software