0
SEGMENT .data ; nothing here
SEGMENT .text ; sauce
global _start
_start:
            pop ECX ; get ARGC value
            mov EAX, 4 ; sys_write()
            mov EBX, 1 ; /dev/stdout
           ;^^^^^^^^^^^
            mov EDX, 1 ; a single byte
            int 0x80
            mov EAX, 1 ; sys_exit()
                    mov EBX, 0 ; return 0
            int 0x80
SEGMENT .bss ; nothing here

why mov EBX, ""1"" ; /dev/stdout ? where document I can find "1" ?

Y. HSUN LU
  • 31
  • 1
  • 5
  • ("In C, stdin, **stdout**, and stderr are FILE*, which in UNIX respectively map to file descriptors 0, **1** and 2." - [from this answer](https://stackoverflow.com/a/5257718)) – user202729 Mar 04 '18 at 14:28
  • Here is a good survey of the history: [Standard streams](https://en.wikipedia.org/wiki/Standard_streams) from wikipedia. The article goes back to the 1950's and discusses Unix design, and explains why the streams were standardized and their values. – jww Mar 04 '18 at 14:44

1 Answers1

-1

On unix systems, a process normally have 3 common I/O channels connected to it, called stdin/stdout/stderr. These have the corresponding file descriptor values 0, 1 and 2.

This is documented at: http://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html (See also the wikipedia page )

nos
  • 223,662
  • 58
  • 417
  • 506