Commit be0232e

mo khan <mo@mokhan.ca>
2025-01-23 19:02:24
try to print something
1 parent 99c88ec
Changed files (1)
assignments
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