Choosing the right and training assembler to write a compiler

I am writing a compiler, and I went through all the steps (tokenization, parsing, syntax tree structures, etc.) that they show you in all compiler books. (Please do not comment on the link to "Resources for writing a compiler"!).

I decided to use NASM along with alink as my backend.

Now my problem is: I just can't find good resources to learn about NASM and builds in general.

Wikibook (german) on the x86 build is horrible . They don’t even explain the code that they write there, at present I can’t even get simple things, for example, adding 1 to 2 and outputting the result.

  • Where can I find out the NASM x86 build?
+5
source share
2 answers

It’s good if you take the book as a link. My favorite author ever since I recognized Pascal in 80 was Jeff Dantemman. His latest compilation book covers NASM. http://www.duntemann.com/assembly.htm

Not sure which OS you are targeting, but the fact that the above book is targeting Linux should not be a problem, the assemblies that interest you.

Honestly, the actual assembly for code generation is not the hardest part, IMHO I believe registry management is where the real training is.

Good luck!

+1
source

If you have not noted this, the NASM guide is a good resource for learning NASM: http://www.nasm.us/doc/

NASM GAS : http://www.ibm.com/developerworks/linux/library/l-gas-nasm.html

irc #asm Freenode se (r) ver :

:

bits 32
section .data
    greeting db "hello world", 10
section .text
global _start
_start:
    mov eax, 4 ; sys_write
    mov ebx, 1 ; stdout
    mov ecx, greeting
    mov edx, 12 ; greeting.length
    int 0x80 ; system call interrupt

    mov eax, 1 ; sys_exit
    mov ebx, 0
    int 0x80

:

nasm -f elf -o example.o example.asm
ld -o example example.o -melf_i386

python. , . , , . .. , , : x86

, , http://bitbucket.org/cheery/g386/, .

+1

All Articles