From 779f32937a181bbaff678232edab4381a550867d Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 23 Jan 2025 12:16:41 -0700 Subject: Update assembly code --- 3431709-assignment-3.pdf | Bin 199340 -> 199448 bytes Makefile | 2 +- assignments/3-solution.md | 2 +- assignments/3/max_min.s | 15 ++++++++++----- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/3431709-assignment-3.pdf b/3431709-assignment-3.pdf index 473a3e3..206b79c 100644 Binary files a/3431709-assignment-3.pdf and b/3431709-assignment-3.pdf differ diff --git a/Makefile b/Makefile index 1284fc0..896b7af 100644 --- a/Makefile +++ b/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 diff --git a/assignments/3-solution.md b/assignments/3-solution.md index 3ac8b91..d886473 100644 --- a/assignments/3-solution.md +++ b/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 diff --git a/assignments/3/max_min.s b/assignments/3/max_min.s index cad40ac..abf66f7 100644 --- a/assignments/3/max_min.s +++ b/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) -- cgit v1.2.3