segunda-feira, 14 de dezembro de 2009

cat in assembly

section .bss
char resb 1 ; unbeffered


section .text
 global _start:

_start:

 mov  ecx, char

while:
 call  read
 cmp eax, 0
 jle end_while
 
 call write
 jmp  while

end_while:
 mov  ebx, eax
 mov  eax, 1
 int  0x80  
 
read:
 mov  eax, 3
 mov  ebx, 0
 mov  ecx, char
 mov  edx, 1
 int  0x80
 
 ret

write:
 mov  ebx, eax
 mov  eax, 1
 mov  ecx, char
 mov edx, 1
 int  0x80
 
 ret 

this is almost equa of "minicat.c", it
can return 0 (end of file) or -1 (error)
usage: catasm < file

Nenhum comentário:

Postar um comentário