flat assembler
Message board for the users of flat assembler.
Index
> Linux > FASM Tutorial for Linux? |
Author |
|
rCX 06 Aug 2009, 22:51
I'm sort of a newbie at linux asm as well. I don't know if any fasm tutorials for linux exist I found a nasm tutorial which was fairly helpful.
|
|||
06 Aug 2009, 22:51 |
|
Octal 07 Aug 2009, 02:08
Thanks. Although I'd hate to betray FASM, I'll try it out.
Thanks again. -Brandon |
|||
07 Aug 2009, 02:08 |
|
Madis731 07 Aug 2009, 06:48
Don't consider it deserting FASM, but more like helping
TASM, NASM are closely related to FASM so you won't lose that much. |
|||
07 Aug 2009, 06:48 |
|
rCX 07 Aug 2009, 19:28
It wouldn't be impossible for someone (with Tomasz's permission, of course) to rewrite the DOS tutorial for linux. Wouldn't it be a matter of replacing int 21h examples with int 80h ones?
|
|||
07 Aug 2009, 19:28 |
|
asmcoder 07 Aug 2009, 19:36
[content deleted]
|
|||
07 Aug 2009, 19:36 |
|
kohlrak 17 Aug 2009, 23:45
if the same functions are mounted to the same numbers, it shouldn't be a problem. However, though i have never programmed for DOS, i don't see that as very likely. It's very difficult to start out with anything other than windows with fasm unless you're willing to use ld by command line and learn the order of params before you seriously code. Lots of amd64 examples, though that are readily assemblable in the examples section to help with using them. =) Just a matter of assembling your hello world then using man. If you've used fasm for anything else, not a problem. but, if you're new to fasm, i would recommend taking to programming for windows using wine until you get used to the fasm syntax if you're used to programming for windows as using a different assembler (why learn 2 new things at once if you can learn 2 things seperately?).
|
|||
17 Aug 2009, 23:45 |
|
cod3b453 20 Aug 2009, 14:50
There are some good examples in the FreeBSD developer's handbook:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/x86.html Hope that helps |
|||
20 Aug 2009, 14:50 |
|
Endre 22 Aug 2009, 20:11
By the way kohlrak is right. Fasm is not as great success on Linux (on other non windows systems even less) as it is on windows. It's really a pain to debug your code (even 64-bit) generated by fasm (absolutely no debug info). Its preprocessor capabilities have been designed with windows in mind. On Unix systems you mostly don't need to use as sophisticated macros (except if you want something fasm doesn't provide by default) as on windows. On Unices however there are infinite header files with infinite times infinite constants that you'd like to use without the necessity of tracking them down to their bare values that then you'd have to hard-code in your program (just look at the Linux examples, hard coded magic values everywhere, terrible). The other assemblers (nasm, yasm, etc.) may be better choice (even when it's about debugging), but I don't use them either. I simply use the gnu assembler (gas, as). It's part of the gnu compiler infrastructure that is defacto standard on the most popular Unix systems (Linux, BSDs, Mac), but it can also be found on the others (Windows, Solaris, AIX, etc.) as well. And it works with the c-preprocessor automatically and seamlessly. So if you are once used to it then you won't have any problems with other systems. You don't need to invoke gnu-ld or gnu-as directly, but of course you have to know some options, but it should not be a problem. As an example here the little hello world linux example for powerpc (I just compile it with the gnu powerpc cross-compiler and run it with qemu-ppc on my intel machine .
Code: /** * Compile it with command: * powerpc-pc-linux-gnu-gcc -s -nostdlib -mregnames hello.S -o hello * * On non PowerPC run it with qemu in user mode: * qemu-ppc ./hello */ .if 0 #include <asm/unistd.h> #include <unistd.h> .endif .line __LINE__ .globl _start .text _start: li r0, __NR_write li r3, STDOUT_FILENO li r4, msg@l oris r4, r4, msg@h li r5, msg_len sc li r0, __NR_exit li r3, 0 sc msg: .ascii "Hello 32-bit PowerPC world!\n" msg_len = . - msg Code: db 0x7F, 0x45, 0x4C, 0x46, 0x01, 0x02, 0x01, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01 db 0x10, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x34 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x34, 0x00, 0x20, 0x00, 0x02, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 db 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 db 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAD db 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00, 0x00, 0x05 db 0x00, 0x01, 0x00, 0x00, 0x65, 0x04, 0x15, 0x80 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00 db 0x00, 0x00, 0x00, 0x04, 0x38, 0x00, 0x00, 0x04 db 0x38, 0x60, 0x00, 0x01, 0x38, 0x80, 0x00, 0x98 db 0x3C, 0x84, 0x10, 0x00, 0x38, 0xA0, 0x00, 0x15 db 0x44, 0x00, 0x00, 0x02, 0x38, 0x00, 0x00, 0x01 db 0x38, 0x60, 0x00, 0x00, 0x44, 0x00, 0x00, 0x02 db 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x50, 0x6F db 0x77, 0x65, 0x72, 0x50, 0x43, 0x20, 0x77, 0x6F db 0x72, 0x6C, 0x64, 0x21, 0x0A It's maybe a little bit OFF and seems a gnu advocacy, but I just wanted to demonstrate you that on Unix systems you mostly need constants from headers but not macros overwhelming everything. And if you are used to an assembler (actually to a compiler infrastructure) then you're not lost on other systems/platforms (e.g. if you want to write some complicated calculations to your super computer consisted of some PS3s, or just want to learn another assembly. Qemu can emulate quite a few processors ). |
|||
22 Aug 2009, 20:11 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.