GreenMamba GreenMamba - 5 months ago 55
Linux Question

read data from file in assembly AT&T

I want to read data from a file in assembly AT&T but I don't really know where to start.
I haven't found a useful resource on internet.

My working environment info:

OS: Ubuntu 14 - 64 bit
CPU: Intel
GAS compiler
Assembly Sintax: AT&T
I'll assemble with: as -o hello.o hello.s
I'll link with: ld -o test hello.o

Answer

Look up how to do systems programming on POSIX in C (open/read/write/etc.), then use the same system calls in your asm. There's nothing special about asm for this, compared to just doing it in C. (except that in C you'd be using the glibc wrappers instead of the syscall instruction directly.)

See the tag wiki for links documenting how to make system calls from asm.