flat assembler
Message board for the users of flat assembler.
Index
> Main > what are some good FASM tutorials...for beginner? |
Author |
|
Trinitek 09 Aug 2015, 20:06
NASM syntax will assemble in FASM, but the %directives are not compatible. Swap them for the FASM equivalents and most files will work fine.
|
|||
09 Aug 2015, 20:06 |
|
yj1214 09 Aug 2015, 20:18
This is Hello World assembly code from NASM tutorial.
Code: section .text global _start ;must be declared for linker (ld) _start: ;tells linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!', 0xa ;our dear string len equ $ - msg ;length of our dear string When I compile this code using FASM, it gives me an error that says, Code:
section .text
error: illegal instruction.
|
|||
09 Aug 2015, 20:18 |
|
system error 09 Aug 2015, 21:03
Welcome to fasm
1) you don't need a linker in your particular case. Just compile it using ./fasm yourfile.asm and execute it just like that. Since you don't need a linker, you dont need global or _start or section 2) Hence.. Code: format elf executable segment readable executable;section .text mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel segment readable writeable msg db 'Hello, world!', 0xa ;our dear string len = $ - msg ;length of our dear string |
|||
09 Aug 2015, 21:03 |
|
yj1214 09 Aug 2015, 21:13
Thanks for the answer but now i'm getting an "error: undefined symbol 'len'." error...
|
|||
09 Aug 2015, 21:13 |
|
system error 09 Aug 2015, 21:15
Look carefully...
|
|||
09 Aug 2015, 21:15 |
|
revolution 10 Aug 2015, 02:57
The fasm download already has example "hello world" programs. Look in the folder named "examples".
|
|||
10 Aug 2015, 02:57 |
|
shutdownall 10 Aug 2015, 12:06
yj1214 wrote: Thanks for the answer but now i'm getting an "error: undefined symbol 'len'." error... Code: len=... vs len EQU Code: msg db 'Hello, world!', 0xa ;our dear string .len =$ - msg ;length of our dear string msg2 db 'What ?', 0xa ;our dear string .len =$ - msg2 ;length of our dear string msg3 db 'Aha, aha, aha !', 0xa ;our dear string .len =$ - msg3 ;length of our dear string This way you can always get the size with msgx.len and don't need to take new variable names. |
|||
10 Aug 2015, 12:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.