Skip to content

Commit

Permalink
Add register usage to stub file
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Nov 9, 2023
1 parent 3783f25 commit 4e4eca1
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 128 deletions.
10 changes: 5 additions & 5 deletions exercises/practice/atbash-cipher/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# atbash_cipher must:
# - read input string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write a null-terminated string representing the return value to address given in a1
# | Register | Usage | Type | Description |
# | -------- | ------------ | ------- | ----------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$a1` | input/output | address | null-terminated output string |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl atbash_cipher

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/binary/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# binary_convert must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | -------------------------------------- |
# | `$a0` | input | address | null-terminated string of binary chars |
# | `$v0` | output | integer | decimal value of input string |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl binary_convert

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/difference-of-squares/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# difference_of_squares must:
# - read input integer from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it wants to use s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Purpose |
# | -------- | --------- | ------- | -------------------------- |
# | `$a0` | input | integer | given value |
# | `$v0` | output | integer | difference of squares |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl difference_of_squares

Expand Down
12 changes: 6 additions & 6 deletions exercises/practice/grains/impl.mips
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# square must:
# - read input integer from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it wants to use s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write low word of integer result to v0
# - write high word of integer result to v1
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | -------------------------------- |
# | `$a0` | input | integer | square number in the range 1..64 |
# | `$v0` | output | integer | low 32 bits of output |
# | `$10` | output | integer | high 32 bits of output |
# | `$t0-9` | temporary | any | for temporary storage |

.globl square

Expand Down
12 changes: 6 additions & 6 deletions exercises/practice/hamming/impl.mips
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# hamming_distance must:
# - read input address of first string from a0
# - read input address of second string from a1
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------ |
# | `$a0` | input | address | first, null-terminated, string |
# | `$a1` | input | address | first, null-terminated, string |
# | `$v0` | output | integer | hamming distance |
# | `$t0-9` | temporary | any | for temporary storage |

.globl hamming_distance

Expand Down
7 changes: 4 additions & 3 deletions exercises/practice/hello-world/impl.mips
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Implement the 'hello' function, which must:
# - write address of string result to v0
# | Register | Usage | Type | Description |
# | -------- | ------ | ------- | ---------------------- |
# | `$v0` | output | address | null-terminated string |

.globl hello

Expand All @@ -11,4 +12,4 @@ msg: .asciiz "Goodbye, Mars!"

hello:
la $v0, msg
jr $ra
jr $ra
10 changes: 5 additions & 5 deletions exercises/practice/hexadecimal/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# hex_convert must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------------- |
# | `$a0` | input | address | null-terminated string of hexadecimal chars |
# | `$v0` | output | integer | decimal value of input string |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl hex_convert

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/isbn-verifier/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# is_valid must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write boolean result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ---------------------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$v0` | output | boolean | valid isbn (`0` = `false`, `1` = `true`) |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl is_valid

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/isogram/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# is_isogram must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write boolean result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$v0` | output | boolean | input is an isogram (`0` = `false`, `1` = `true`) |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl is_isogram

Expand Down
12 changes: 7 additions & 5 deletions exercises/practice/leap/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# is_leap_year must:
# - read input integer from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it wants to use s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write boolean result to v0
## Registers

# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------------------ |
# | `$a0` | input | integer | year to check |
# | `$v0` | output | boolean | input is leap year (`0` = `false`, `1` = `true`) |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl is_leap_year

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/luhn/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# valid must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write boolean result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------------------------ |
# | `$a0` | input | address | null-terminated input string |
# | `$v0` | output | boolean | validity of input string (`0` = `false`, `1` = `true`) |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl valid

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/nth-prime/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# nth_prime must:
# - read prime index from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | -------------------------- |
# | `$a0` | input | integer | prime index |
# | `$v0` | output | integer | nth prime value |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl nth_prime

Expand Down
11 changes: 5 additions & 6 deletions exercises/practice/nucleotide-count/impl.mips
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# nucleotide_counts must:
# - read input string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write counts for A,C,G,T to the word array with address given in a1
# - write -1 values to the array if the input is invalid
# | Register | Usage | Type | Description |
# | -------- | ------------ | ------- | --------------------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$a1` | input/output | address | null-terminated result string (4 words) |
# | `$t0-9` | temporary | any | for temporary storage |

.globl nucleotide_counts

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/octal/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# octal_convert must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------- |
# | `$a0` | input | address | null-terminated string of octal chars |
# | `$v0` | output | integer | decimal value of input string |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl octal_convert

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/pop-count/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# egg_count must:
# - read input integer from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it wants to use s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | -------------------------- |
# | `$a0` | input | integer | input number |
# | `$v0` | output | integer | number of eggs |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl egg_count

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/raindrops/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# raindrops must:
# - read input value from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write a null-terminated string representing the return value to address given in a1
# | Register | Usage | Type | Description |
# | -------- | ------------ | ------- | ----------------------------- |
# | `$a0` | input | integer | given number |
# | `$a1` | input/output | address | null-terminated result string |
# | `$t0-9` | temporary | any | for temporary storage |

.globl raindrops

Expand Down
14 changes: 7 additions & 7 deletions exercises/practice/resistor-color-duo/impl.mips
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# value must:
# - read address of first input string from a0
# - read address of second input string from a1
# - read address of (possibly empty) third input string from a2
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------------------------------ |
# | `$a0` | input | address | first color as null-terminated string |
# | `$a1` | input | address | second color as null-terminated string |
# | `$a2` | input | address | third color as null-terminated string (possibly empty) |
# | `$v0` | input | integer | resistor value |
# | `$t0-9` | temporary | any | for temporary storage |

.globl value
.globl color_code
Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/resistor-color/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# color_code must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ------------------------------- |
# | `$a0` | input | address | color as null-terminated string |
# | `$v0` | input | integer | resistor value |
# | `$t0-9` | temporary | any | for temporary storage |

.globl color_code

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/rna-transcription/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# transcribe_rna must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write a null-terminated string representing the return value to address given in a1# Perform RNA transcription with the rules:
# | Register | Usage | Type | Description |
# | -------- | ------------ | ------- | ----------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$a1` | input/output | address | null-terminated result string |
# | `$t0-9` | temporary | any | for temporary storage |

.globl transcribe_rna

Expand Down
12 changes: 6 additions & 6 deletions exercises/practice/rotational-cipher/impl.mips
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# rotate must:
# - read input string from a0
# - read shift key from a1
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write a null-terminated string representing the return value to address given in a2
# | Register | Usage | Type | Description |
# | -------- | ------------ | ------- | ----------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$a1` | input | integer | shift key |
# | `$a2` | input/output | address | null-terminated result string |
# | `$t0-9` | temporary | any | for temporary storage |

.globl rotate

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/scrabble-score/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# scrabble_score must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ---------------------------- |
# | `$a0` | input | address | null-terminated input string |
# | `$v0` | input | integer | scrabble score |
# | `$t0-9` | temporary | any | for temporary storage |

.globl scrabble_score

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/square-root/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# square_root must:
# - read radicand from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | -------------------------- |
# | `$a0` | input | integer | radicand |
# | `$v0` | output | integer | square root |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl square_root

Expand Down
16 changes: 7 additions & 9 deletions exercises/practice/triangle/impl.mips
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# triangle must:
# - read input integers from a0, a1 and a2
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it wants to use s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write result to v0 as:
# 0 - scalene
# 1 - isoceles
# 2 - equilateral
# 3 - invalid triangle
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | ---------------------------------------------------------------------------------- |
# | `$a0` | input | integer | side a |
# | `$a1` | input | integer | side b |
# | `$a2` | input | integer | side c |
# | `$v0` | output | integer | type of triangle (`0` = scalene, `1` = isoceles, `2` = equilateral, `3` = invalid) |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl triangle

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/trinary/impl.mips
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# trinary_convert must:
# - read input address of string from a0
# - follow the convention of using the t0-9 registers for temporary storage
# - (if it uses s0-7 then it is responsible for pushing existing values to the stack then popping them back off before returning)
# - write integer result to v0
# | Register | Usage | Type | Description |
# | -------- | --------- | ------- | --------------------------------------- |
# | `$a0` | input | address | null-terminated string of trinary chars |
# | `$v0` | output | integer | decimal value of input string |
# | `$t0-9` | temporary | any | used for temporary storage |

.globl trinary_convert

Expand Down

0 comments on commit 4e4eca1

Please sign in to comment.