I haven’t worked with FASM, Linux, and system functions for a while.
Here is an extremely simple example for beginners with output on my nickname: mythcat.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | format ELF executable 3 entry start segment readable executable BYTES = 255 ;number of byte 255 start: ;read a char from input char_read: mov eax,3 mov ebx,0 ;0 stdin, 1 stdout, 2 stderr mov ecx,char_Buffer mov edx,BYTES int 0x80 ;write byte read to output char_write: mov eax,4 mov ebx,1 mov ecx,char_Buffer mov dl,[CharRead] int 0x80 jmp char_read ;exit from program exit: mov eax,1 ; System call 'exit' xor ebx,ebx ; 'xor ebx,ebx' int 0x80 segment readable writeable char_Buffer db BYTES dup(0) CharRead db 1 |
The result is … as follows:
1 2 3 4 5 6 7 8 9 10 11 12 | [mythcat@desk fasm]$ ./fasm char_write.asm flat assembler version 1.73.24 (16384 kilobytes memory) 3 passes, 428 bytes. [mythcat@desk fasm]$ ./char_write m my yt th hc ca at t^C |