Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions asmtest/jordan_shashank_alli/GCD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
addi $a0, $zero, 16
addi $a1, $zero, 24

add $t1, $zero, $a0
add $t2, $zero, $a1

Main:
blt $t1, $t2 ALTB
blt $t2, $t1 BLTA
beq $t1, $t2 END
ALTB:
sub $t2,$t2,$t1
j Main
BLTA:
sub $t1,$t1,$t2
j Main
END:
add $v0, $zero, $t1
14 changes: 14 additions & 0 deletions asmtest/jordan_shashank_alli/GCDtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
2004001e
20050018
00044820
00055020
012a082a
14200003
0149082a
14200003
112a0004
01495022
08000004
012a4822
08000004
00091020
26 changes: 26 additions & 0 deletions asmtest/jordan_shashank_alli/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Greatest Common Denominator in Assembly

This test calculates the greatest common divisor of the two values stored at `$a0` and `a1` and stores it in `$v0`.

A definition of greatest common divisor [from Wikipedia](https://en.wikipedia.org/wiki/Greatest_common_divisor):
> In mathematics, the greatest common divisor (gcd) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers.:

Additionally, **`$a0`and $a1 should be any integer**.

## Example Expected Results:
| `$a0` | `$a1` | `$v0` |
|-------|-------|-------|
| `d20` | `d34` | `d2` |
| `d10` | `d12` | `d2` |
| `d20` | `d15` | `d5` |
| `d24` | `d16` | `d8` |
| `d36` | `d12` | `d12` |
## Instructions Used
No additional instructions beyond the lab requirements need to be implemented. Specifically, the following instructions are used by this test case:

- `sub`
- `add`
- `addi`
- `j``
- `beq`
- `blt`