I'm starting to learn assembler, and in fasm's documentation there are two commands for input&output - in
&out
. As I know, the stdin is port #0, and stdout - #1, so I try to run this code:
in eax,0
but the program crashes. The same result after running
out 1,eax
I tried to search smth about this, but no luck.
So, what is the right usage of in&out commands, and is there a simpler way to do input/output?
These are hardware ports. A special x86 hardware method of reading and writing to the peripheral devices. in
and out
instructions, form special signals to the CPU buses, that the peripherals can understand.
In order to read and write to STDIN and STDOUT you must use the standard file functions on your OS, passing STDIN, respectively STDOUT as a file handle.
For Linux these are sys_read and sys_write system functions. You can read an extensive, assembly-centric system calls reference here.