I am trying to learn the x86 build on Linux. The most useful tutorial I can find is Writing a Useful Program with NASM . The task I'm setting up is simple: read the file and write it to standard output.
This is what I have:
section .text ; declaring our .text segment global _start ; telling where program execution should start _start: ; this is where code starts getting exec'ed ; get the filename in ebx pop ebx ; argc pop ebx ; argv[0] pop ebx ; the first real arg, a filename ; open the file mov eax, 5 ; open( mov ecx, 0 ; read-only mode int 80h ; ); ; read the file mov eax, 3 ; read( mov ebx, eax ; file_descriptor, mov ecx, buf ; *buf, mov edx, bufsize ; *bufsize int 80h ; ); ; write to STDOUT mov eax, 4 ; write( mov ebx, 1 ; STDOUT, ; mov ecx, buf ; *buf int 80h ; ); ; exit mov eax, 1 ; exit( mov ebx, 0 ; 0 int 80h ; );
The most important problem here is that the tutorial never mentions how to create a buffer, a bufsize variable bufsize or variables in general.
How to do it?
(Aside: after at least an hour of searching, I am vaguely shocked by the low quality of resources for training in collecting. How, in fact, does any computer work when the only documentation is rumors that are traded on the network?)
source share