Created
May 5, 2014 09:01
-
-
Save vittorioromeo/468d222b218cf0c0bf25 to your computer and use it in GitHub Desktop.
x86 print/write tests
This file contains hidden or 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
section .data | |
str: db 100 | |
section .bss | |
section .text | |
global _start | |
_start: | |
mov eax, 3 ; Read user input into str | |
mov ebx, 0 ; | <- read source (0=stdin) | |
mov ecx, str ; | <- destination | |
mov edx, 100 ; | <- length | |
int 80h ; \___ | |
mov eax, 4 ; Print 100 bytes starting from str | |
mov ebx, 1 ; | <- print target (1=stdout) | |
mov ecx, str ; | <- source | |
mov edx, 100 ; | <- length | |
int 80h ; \___ | |
mov eax, 1 ; Return | |
mov ebx, 0 ; | <- return code | |
int 80h ; \___ | |
; mov eax, 5 ; Open file | |
; mov ebx, filename ; | | |
; mov ecx, 1 ; | <- method (0=RDONLY, 1=WRONLY, 2=RDWR, ...) | |
; mov edx, 400h ; | <- permissions? | |
; int 80h ; \___ | |
; mov eax, 4 ; Printing | |
; mov ebx, eax ; | <- print target | |
; mov ecx, text ; | <- source (what to print) | |
; mov edx, length ; | <- length | |
; int 80h ; \___ | |
; mov eax, 6 ; Close file | |
; int 80h ; \___ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment