diff options
| author | mo khan <mo@mokhan.ca> | 2025-01-23 12:16:41 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-01-23 12:16:41 -0700 |
| commit | 779f32937a181bbaff678232edab4381a550867d (patch) | |
| tree | 51c016d258da0ddab563e5e785a53a15aee46277 | |
| parent | c8ac898c9ec045d0de769886e5306dc177914527 (diff) | |
Update assembly code
| -rw-r--r-- | 3431709-assignment-3.pdf | bin | 199340 -> 199448 bytes | |||
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | assignments/3-solution.md | 2 | ||||
| -rw-r--r-- | 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 Binary files differindex 473a3e3..206b79c 100644 --- a/3431709-assignment-3.pdf +++ b/3431709-assignment-3.pdf @@ -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) |
