Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _start:
- xor eax, eax
- xor ebx, ebx
- xor ecx, ecx
- xor edx, edx
- jmp two
- # open file 'filename', then call read
- one:
- pop ebx
- movb al, 0x5 # sys_open
- int 0x80 #sys_open('filename', 0), 0 for RD_ONLY, 1 for WR_ONLY, 2 for RD_WR
- mov esi, eax
- read:
- movb al, 0x3 # sys_read
- mov ebx, esi # move fd to ebx
- lea ecx, [esp]
- movb dl, 0x1 #read 1 byte
- int 0x80
- # If (read null byte (\x00) or error)
- # exit
- xor ebx, ebx
- cmp eax, ebx
- jle exit
- # else
- # write this byte (character)
- write:
- movb al, 0x4 # sys_write
- movb bl, 0x1 # write 1 byte
- movb dl, 0x1
- int 0x80 #now, ecx is still [esp], no need to assign 1 more time => save memory
- jmp read # This instruction causes loop until we read null byte
- exit:
- movb al, 0x1 # sys_exit
- xor ebx, ebx # sys_exit(0)
- int 0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement