News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Assembly in linux ??

Started by Hjortur, November 28, 2006, 06:27:19 AM

Previous topic - Next topic

Hjortur

I was wondering if anyone here has some experience making linux 32-bit applications in assembly ??
I am talking about stuff like windows and shiny colors, not "just" console programs.
If you can post links to some sites/forums that are like this one but just for linux, 
And just for the record it doesnt matter wether it is in GAS or NASM.

I already have googled and found numerous results, but I am asking for a recomandation from the infallible all   :bg  .
And also what are your thougts regarding 32-bit linux assembly with windows and stuff.  Is it as easy as windows progtaming ??
And I am using KDE.

LechooY

Hey

This is very good paper about Asm in Linux http://rudy.mif.pg.gda.pl/~bogdro/asm_pdf_linux.pdf.gz of course if You know polish language :P


Synfire

To do graphical applications on Linux, I would suggest learning to use GTK. Then you can use you're prefered assembler to call the GTK exports. This is generally how linux assembly programmers work. One thing to look out for though, GTK and LibC both use the C calling convention so you will need to clean up the stack after you have made a call to a routine. Make use of libraries like LibC, it'll make your programs easy to read (easier than looking through the syscall table) and easier to develop (in many cases your programs won't be much harder to design than doing so in C or C++). The last version of NASM32 (not the current though) has an example of using the LibC.mac file to make working with LibC much easier. The most popular assembler for Linux programming is GAS, if you decide to use it, it has the advantage of letting you program your applications in C using GCC then exporting the code to GAS source for optimization (as well as learning how to do things you do in C in assembly). The FASM userbase are also quickly gaining ground and I'm sure they have at least a few examples of Linux programming in FASM.

QuoteIs it as easy as windows progtaming ??
And I am using KDE.

IMHO it's not. And it's going to be a little harder if you are working with KDE since any information you find will be in regards to Qt where it's heavily object oriented (C++) which, although it can be done, always complicates things. GTK is definately the way to go, it's what apps like XChat are developed in. As well, you can develop source code using GTK and LibC that will work on Linux, Windows, and BSD without modification, even in assembly (kinda kills that whole portability argument huh :p).

Truth is, once you learn assembly, it's not that difficult to move from one OS to the other, you're just going to have to spend some time to get used to the APIs, luckily in the case of Linux, the API is mearly the standard C library (aka libc) so you just work with C language calls. Windows, on the other hand, has it's own set of API's which are supposed to make things easier (although at times just overcomplicates things). My suggestion would be to just learn assembly on whatever system you have available, make sure you learn about the calling conventions and don't get stuck using things like INVOKE, and you will end up seeing that there really isn't too much difference as far as you will be conserned. The thing that usually messes people up from moving between linux and windows is the calling convention change, and program initialization (handling command line arguments and such).

Hjortur

Thank you all for your replys, I am not currently familiar with the polish language, so that article wont help me much.
Synfire I am have used GAS for a year or two, so that is no problem.  But recently I have been fiddling with NASM  and
thank you very much for the NASM32 package, did help me a lot when i was trying to figure NASM out.
I just had nasmw.exe and link.exe and was trying to make my own import library, that was a pain and took like a month.  Until I tested Alink,  and whoila  peace of cake.
I think i will use nasm for my linux projects from here on.

drhowarddrfine

I pretty much agree with Synfire but I find assembly in FreeBSD, essentially the same thing, easier than Windows but I'm not doing anything graphical  yet.  The ability to use GCC and seamlessly combine C with assembly is a huge advantage.  Right now, I'm trying to get a little project off the ground.  There's one piece of example C code I don't understand but, to get things rolling, I just included it in the compile along with the asm code and it pieced it together.