12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- global _start
- section .data
- getchar:
- mov eax,0x03
- mov ebx,0 ;stdin fd
- mov ecx,buf
- mov edx,1 ;count
- int 0x80
-
- cmp eax,1
- jne .getchar_fail
-
- mov eax,[buf]
- ret
- .getchar_fail:
- mov eax,-1
- ret
- putchar:
- mov [buf],eax
- mov eax,0x04
- mov ebx,1 ;stdout fd
- mov ecx,buf
- mov edx,1
- int 0x80
- ret
- _start:
- call getchar
- cmp eax,-1
- je .done
- call putchar
- jmp _start
-
- .done:
- mov ebx,eax
- mov eax,0x01
- int 0x80
- buf:
- db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|