diff --git a/asmtest/jordan_shashank_alli/GCD b/asmtest/jordan_shashank_alli/GCD new file mode 100644 index 0000000..044b850 --- /dev/null +++ b/asmtest/jordan_shashank_alli/GCD @@ -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 diff --git a/asmtest/jordan_shashank_alli/GCDtest b/asmtest/jordan_shashank_alli/GCDtest new file mode 100644 index 0000000..4da3c6f --- /dev/null +++ b/asmtest/jordan_shashank_alli/GCDtest @@ -0,0 +1,14 @@ +2004001e +20050018 +00044820 +00055020 +012a082a +14200003 +0149082a +14200003 +112a0004 +01495022 +08000004 +012a4822 +08000004 +00091020 diff --git a/asmtest/jordan_shashank_alli/README.MD b/asmtest/jordan_shashank_alli/README.MD new file mode 100644 index 0000000..115be2e --- /dev/null +++ b/asmtest/jordan_shashank_alli/README.MD @@ -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`