How do I start learning Assembly
assembly
Solution
My suggestion is to act with the best assembler producer out there: gcc.
Write simple programs in C and then compile them with the -S switch. you will get a file.s containing the assembler code. Tinker with it and you will learn it. The best part is that if you want to learn a different assembler, you can just compile gcc as cross compiler, and produce assembler for any supported platform.
Remember to disable optimizations with -O0, otherwise you could find strange tricks.
This is hello world in assembler
.cstring
LC0:
.ascii "hello world!\0"
.text
.globl _main
_main:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $20, %esp
call L3
"L00000000001$pb":
L3:
popl %ebx
leal LC0-"L00000000001$pb"(%ebx), %eax
movl %eax, (%esp)
call L_puts$stub
movl $0, %eax
addl $20, %esp
popl %ebx
leave
ret
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
L_puts$stub:
.indirect_symbol _puts
hlt ; hlt ; hlt ; hlt ; hlt
.subsections_via_symbols
Problem
I'd like to play with writing some assembly on my Mac, ideally native, but I'd understand if it's easier to learn in QEMU or something. I see that there are different dialects of assembly depending on the processor - what dialect is the "best" to learn? I don't really have any idea of where to start, any pointers as to how to even run a program in assembly?