Playing with assembly

Created: 2013/12/10 21:05:28+0000

I've been playing with assembly code recently. It isn't something I have looked at since my undergraduate degree. It's very slow going but fun in a perverse way. I had forgotten a lot.

I'm using the NASM assembler for the x86_64 instruction set. They were not what I was using in my degree so some of the things are new and that makes it unclear what I have forgotten.

Macros are new, at least for assembly. I've been putting together some obvious, generic macros for the syscalls.

Dereferencing memory addresses is nothing like I remember. Though I'm not clear on how I did it in the past.

Branching is a little different. I started off trying to pass a register and a location to the branching opcodes. I didn't realise that it worked with the bits set in the status register.

I've implemented a simple echo program. Reading an any length line from the standard input and writing it out to the standard output. Using syscalls to read in a small buffer, write it out and repeat until the entire line is consumed.