Oct 262011

i’ve been having an itch to try out assembly for quite some time. after poking around i found some linux x86 assembly tutorials. i didn’t get far because, to be honest, assembly is a lot of work. the only two programs i came up with (lol):


section .text
    global _start

    mov eax,1   ;syscall for exit
    mov ebx,2   ;exit code 2
    int 80h     ;poke the kernel


section .data
    hello:      db 'Hello world!',10
    helloLen:   equ $-hello

section .text
    global _start

    mov eax,4           ;syscall for write
    mov ebx,1           ;fd 1- stdout
    mov ecx,hello       ;move hello into ecx - to be outputted
    mov edx,helloLen    ;length to write
    int 80h             ;poke the kernel

    mov eax,1           ;syscall for exit
    mov ebx,0           ;exitcode 0 (no err)
    int 80h             ;poke the kernel

you can compile them with nasm and ld:
nasm -f elf display.asm
ld -f -o display display.o

and then run it like any other executable: ./display

i used mostly this tutorial and a little bit of the info on this site.

things i can take away from this:
1) interrupts and syscalls are cool
2) asm is pretty simple at its core, if you’re a computer
3) it takes a million lines to do anything

maybe i’ll mess with it a bit more later.