Commit 779f329

mo khan <mo@mokhan.ca>
2025-01-23 19:16:41
Update assembly code
1 parent c8ac898
assignments/3/max_min.s
@@ -2,32 +2,37 @@
 
 	.text
 _start:
+	movq $0, max  # initialize max to 0
+	movq $0, min  # initialize min to 0
+
 	# write(1, greeting, 16)
 	mov     $1, %rax                # system call 1 is write
 	mov     $1, %rdi                # file handle 1 is stdout
-	mov     $greeting, %rsi          # address of string to output
-	mov     $16, %rdx               # number of bytes
+	mov     $greeting, %rsi         # address of variable to pring
+	mov     $16, %rdx               # number of bytes to write
 	syscall                         # invoke operating system to do the write
 
+read_input:
 	# 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
+	mov     $4, %rdx                # number of bytes to read
 	syscall                         # invoke operating system to do the write
 
+print_results:
 	# write(1, max_message, 4)
 	mov     $1, %rax                # system call 1 is write
 	mov     $1, %rdi                # file handle 1 is stdout
 	mov     $max_message, %rsi      # address of string to output
-	mov     $5, %rdx                # number of bytes
+	mov     $5, %rdx                # number of bytes to write
 	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
+	mov     $4, %rdx                # number of bytes read
 	syscall                         # invoke operating system to do the write
 
 	# write(1, min_message, 4)
assignments/3-solution.md
@@ -142,5 +142,5 @@ $ ruby caesar.rb
 References:
 
 * https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/
-* https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html
 * https://cs.lmu.edu/~ray/notes/gasexamples/
+* https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html
3431709-assignment-3.pdf
Binary file
Makefile
@@ -8,7 +8,7 @@ default: 3431709-assignment-1.pdf 3431709-assignment-2.pdf 3431709-assignment-3.
 3431709-assignment-2.pdf: assignments/2-solution.md
 	pandoc -f markdown -t pdf -o 3431709-assignment-2.pdf assignments/2-solution.md
 
-3431709-assignment-3.pdf: assignments/3-solution.md assignments/3/caesar.rb assignments/3/main.c assignments/3/main.s
+3431709-assignment-3.pdf: assignments/3-solution.md assignments/3/caesar.rb assignments/3/main.c assignments/3/main.s assignments/3/max_min.s
 	pandoc -f markdown -t pdf --filter pandoc-include -o 3431709-assignment-3.pdf assignments/3-solution.md
 
 3431709-assignment-4.pdf: assignments/4-solution.md assignments/4/main.py