summaryrefslogtreecommitdiff
path: root/assignments/3
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-01-23 12:02:24 -0700
committermo khan <mo@mokhan.ca>2025-01-23 12:02:24 -0700
commitbe0232e94c981284c5cd8f2c6013c252ebeb98d0 (patch)
treefe4a4c5b550f9307eaacc3c897d90f894916db18 /assignments/3
parent99c88ec429f73b614ece45b45ee482c8f9f8e059 (diff)
try to print something
Diffstat (limited to 'assignments/3')
-rw-r--r--assignments/3/max_min.s44
1 files changed, 30 insertions, 14 deletions
diff --git a/assignments/3/max_min.s b/assignments/3/max_min.s
index 7e7895c..1c0e84a 100644
--- a/assignments/3/max_min.s
+++ b/assignments/3/max_min.s
@@ -1,17 +1,33 @@
- .global _start
+ .global _start
- .text
+ .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
+ # 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"
+ # read(0, input, 3)
+ mov $0, %rax # system call 0 is read
+ mov $0, %rdi # file handle 0 is stdin
+ mov $input, %rsi # address of var to input
+ mov $4, %rdx # number of bytes
+ syscall # invoke operating system to do the write
+
+ # write(1, input, 4)
+ mov $1, %rax # system call 1 is write
+ mov $1, %rdi # file handle 1 is stdout
+ mov $input, %rsi # address of string to output
+ mov $4, %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
+
+ .data
+message: .ascii "Hello, world\n"
+input: .word 0