Commit 99c88ec
Changed files (3)
assignments
assignments/3/.gitignore
@@ -0,0 +1,2 @@
+*.o
+*.exe
assignments/3/Makefile
@@ -11,3 +11,8 @@ numbers.txt:
run: main.exe numbers.txt
./main.exe < numbers.txt
+
+manual: max_min.s
+ as --64 -o max_min.o max_min.s
+ ld -o max_min.exe max_min.o
+ ./max_min.exe
assignments/3/max_min.s
@@ -0,0 +1,17 @@
+ .global _start
+
+ .text
+_start:
+ # write(1, message, 13)
+ mov $1, %rax # system call 1 is write
+ mov $1, %rdi # file handle 1 is stdout
+ mov $message, %rsi # address of string to output
+ mov $13, %rdx # number of bytes
+ syscall # invoke operating system to do the write
+
+ # exit(0)
+ mov $60, %rax # system call 60 is exit
+ xor %rdi, %rdi # we want return code 0
+ syscall # invoke operating system to exit
+message:
+ .ascii "Hello, world\n"