Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Leopold von Niebelschuetz-Godlewski
- #Homework for "Programming from the Ground Up - Chapter 5"
- #Purpose: Creates a file that's called "heynow.txt" with the string "Hey diddle diddle!\n".
- .section .data
- #system call numbers
- .equ SYS_OPEN, 5
- .equ SYS_WRITE, 4
- .equ SYS_CLOSE, 6
- .equ SYS_EXIT, 1
- #options for SYS_OPEN call
- .equ O_RDONLY, 0
- .equ O_CREAT_WRONLY_TRUNC, 03101
- .equ PERMISSIONS, 0666
- #strings to be used
- diddle_string:
- .ascii "Hey diddle diddle!\n\0"
- file_name:
- .ascii "heynow.txt\0"
- .section .text
- .globl _start
- #okay, game time >.<
- _start:
- #no code required here... hi =)....
- get_fd_write:
- movl $SYS_OPEN, %eax
- movl $file_name, %ebx
- movl $O_CREAT_WRONLY_TRUNC, %ecx
- movl $PERMISSIONS, %edx
- int $0x80 #fd now stored in %eax
- pushl %eax
- write_file:
- movl $20, %edx #size of our string
- movl %eax, %ebx # %eax contains the fd
- movl $SYS_WRITE, %eax
- movl $diddle_string, %ecx
- int $0x80
- close_files:
- movl $SYS_CLOSE, %eax
- popl %ebx
- int $0x80
- exit:
- movl $SYS_EXIT, %eax
- movl $0, %ebx
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement