-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
brianrhall
committed
May 15, 2020
1 parent
88ff5bd
commit 1103470
Showing
21 changed files
with
166 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,6 @@ myLoop: | |
loop myLoop | ||
|
||
movq $0x2000001, %rax | ||
movq $0, %rdi | ||
xorq %rdi, %rdi | ||
syscall | ||
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ outer: | |
jne outer | ||
|
||
movq $0x2000001, %rax | ||
movq $0, %rdi | ||
xorq %rdi, %rdi | ||
syscall | ||
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,6 @@ while_loop: | |
done: | ||
|
||
movq $0x2000001, %rax | ||
movq $0, %rdi | ||
xorq %rdi, %rdi | ||
syscall | ||
.end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Program 6.1 | ||
# Sum Program - GAS, Clang/LLVM on Linux (64-bit) | ||
# Copyright (c) 2020 Hall & Slonka | ||
|
||
.data | ||
num1: .long 2 | ||
num2: .long 4 | ||
|
||
.text | ||
.global _main, _sum | ||
_main: | ||
|
||
movq $10, %rax | ||
decq %rax | ||
movq $5, %rbx | ||
|
||
movslq num1(%rip), %rdi | ||
movslq num2(%rip), %rsi | ||
callq _sum | ||
|
||
addq %rbx, %rax | ||
decq %rax | ||
|
||
movq $60, %rax | ||
xorq %rdi, %rdi | ||
syscall | ||
|
||
_sum: | ||
pushq %rbp | ||
movq %rsp, %rbp | ||
pushq %rbx | ||
movq %rdi, %rax | ||
addq %rsi, %rax | ||
popq %rbx | ||
popq %rbp | ||
retq | ||
|
||
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Program 6.1 | ||
# Sum Program - GAS, Clang/LLVM on macOS (64-bit) | ||
# Copyright (c) 2020 Hall & Slonka | ||
|
||
.data | ||
num1: .long 2 | ||
num2: .long 4 | ||
|
||
.text | ||
.global _main, _sum | ||
_main: | ||
|
||
movq $10, %rax | ||
decq %rax | ||
movq $5, %rbx | ||
|
||
movslq num1(%rip), %rdi | ||
movslq num2(%rip), %rsi | ||
callq _sum | ||
|
||
addq %rbx, %rax | ||
decq %rax | ||
|
||
movq $0x2000001, %rax | ||
movq $0, %rdi | ||
syscall | ||
|
||
_sum: | ||
pushq %rbp | ||
movq %rsp, %rbp | ||
pushq %rbx | ||
movq %rdi, %rax | ||
addq %rsi, %rax | ||
popq %rbx | ||
popq %rbp | ||
retq | ||
|
||
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; Program 6.1 | ||
; Sum Program - MASM (64-bit) | ||
; Copyright (c) 2020 Hall & Slonka | ||
|
||
extrn ExitProcess : proc | ||
|
||
.data | ||
num1 DWORD 2 | ||
num2 DWORD 4 | ||
|
||
.code | ||
_main PROC | ||
|
||
mov rax, 10 | ||
dec rax | ||
mov rbx, 5 | ||
|
||
movsxd rcx, num1 | ||
movsxd rdx, num2 | ||
call _sum | ||
|
||
add rax, rbx | ||
dec rax | ||
|
||
mov rcx, 0 | ||
call ExitProcess | ||
_main ENDP | ||
|
||
_sum PROC | ||
push rbp | ||
push rbx | ||
sub rsp, 20h | ||
lea rbp, [rsp + 20h] | ||
mov rax, rcx | ||
add rax, rdx | ||
lea rsp, [rbp] | ||
pop rbx | ||
pop rbp | ||
ret | ||
_sum ENDP | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; Program 6.1 | ||
; Sum Program - NASM (64-bit) | ||
; Copyright (c) 2020 Hall & Slonka | ||
|
||
section .data | ||
num1: dd 2 | ||
num2: dd 4 | ||
|
||
section .text | ||
global _main, _sum | ||
_main: | ||
|
||
mov rax, 10 | ||
dec rax | ||
mov rbx, 5 | ||
|
||
movsx rdi, DWORD [rel num1] | ||
movsx rsi, DWORD [rel num2] | ||
call _sum | ||
|
||
add rax, rbx | ||
dec rax | ||
|
||
mov rax, 60 | ||
xor rdi, rdi | ||
syscall | ||
|
||
_sum: | ||
push rbp | ||
mov rbp, rsp | ||
push rbx | ||
mov rax, rdi | ||
add rax, rsi | ||
pop rbx | ||
pop rbp | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters