From 4e4eca10b3a825c9c694ed1b62ed209d0ecd569b Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 9 Nov 2023 10:49:15 +0100 Subject: [PATCH] Add register usage to stub file --- exercises/practice/atbash-cipher/impl.mips | 10 +++++----- exercises/practice/binary/impl.mips | 10 +++++----- .../practice/difference-of-squares/impl.mips | 10 +++++----- exercises/practice/grains/impl.mips | 12 ++++++------ exercises/practice/hamming/impl.mips | 12 ++++++------ exercises/practice/hello-world/impl.mips | 7 ++++--- exercises/practice/hexadecimal/impl.mips | 10 +++++----- exercises/practice/isbn-verifier/impl.mips | 10 +++++----- exercises/practice/isogram/impl.mips | 10 +++++----- exercises/practice/leap/impl.mips | 12 +++++++----- exercises/practice/luhn/impl.mips | 10 +++++----- exercises/practice/nth-prime/impl.mips | 10 +++++----- exercises/practice/nucleotide-count/impl.mips | 11 +++++------ exercises/practice/octal/impl.mips | 10 +++++----- exercises/practice/pop-count/impl.mips | 10 +++++----- exercises/practice/raindrops/impl.mips | 10 +++++----- exercises/practice/resistor-color-duo/impl.mips | 14 +++++++------- exercises/practice/resistor-color/impl.mips | 10 +++++----- exercises/practice/rna-transcription/impl.mips | 10 +++++----- exercises/practice/rotational-cipher/impl.mips | 12 ++++++------ exercises/practice/scrabble-score/impl.mips | 10 +++++----- exercises/practice/square-root/impl.mips | 10 +++++----- exercises/practice/triangle/impl.mips | 16 +++++++--------- exercises/practice/trinary/impl.mips | 10 +++++----- 24 files changed, 128 insertions(+), 128 deletions(-) diff --git a/exercises/practice/atbash-cipher/impl.mips b/exercises/practice/atbash-cipher/impl.mips index d7d28c4..e8d5694 100644 --- a/exercises/practice/atbash-cipher/impl.mips +++ b/exercises/practice/atbash-cipher/impl.mips @@ -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 diff --git a/exercises/practice/binary/impl.mips b/exercises/practice/binary/impl.mips index a378eac..8614b7d 100644 --- a/exercises/practice/binary/impl.mips +++ b/exercises/practice/binary/impl.mips @@ -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 diff --git a/exercises/practice/difference-of-squares/impl.mips b/exercises/practice/difference-of-squares/impl.mips index d4e29ca..8154579 100644 --- a/exercises/practice/difference-of-squares/impl.mips +++ b/exercises/practice/difference-of-squares/impl.mips @@ -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 diff --git a/exercises/practice/grains/impl.mips b/exercises/practice/grains/impl.mips index bd8dd99..2831c10 100644 --- a/exercises/practice/grains/impl.mips +++ b/exercises/practice/grains/impl.mips @@ -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 diff --git a/exercises/practice/hamming/impl.mips b/exercises/practice/hamming/impl.mips index 12a5a67..4346027 100644 --- a/exercises/practice/hamming/impl.mips +++ b/exercises/practice/hamming/impl.mips @@ -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 diff --git a/exercises/practice/hello-world/impl.mips b/exercises/practice/hello-world/impl.mips index eb1e0b3..7a8e8ca 100644 --- a/exercises/practice/hello-world/impl.mips +++ b/exercises/practice/hello-world/impl.mips @@ -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 @@ -11,4 +12,4 @@ msg: .asciiz "Goodbye, Mars!" hello: la $v0, msg - jr $ra \ No newline at end of file + jr $ra diff --git a/exercises/practice/hexadecimal/impl.mips b/exercises/practice/hexadecimal/impl.mips index 4e6117d..8e90b27 100644 --- a/exercises/practice/hexadecimal/impl.mips +++ b/exercises/practice/hexadecimal/impl.mips @@ -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 diff --git a/exercises/practice/isbn-verifier/impl.mips b/exercises/practice/isbn-verifier/impl.mips index 0dcd8c4..95cacf7 100644 --- a/exercises/practice/isbn-verifier/impl.mips +++ b/exercises/practice/isbn-verifier/impl.mips @@ -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 diff --git a/exercises/practice/isogram/impl.mips b/exercises/practice/isogram/impl.mips index 16ebd29..6d7d3fe 100644 --- a/exercises/practice/isogram/impl.mips +++ b/exercises/practice/isogram/impl.mips @@ -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 diff --git a/exercises/practice/leap/impl.mips b/exercises/practice/leap/impl.mips index 2b7bdd6..9117005 100644 --- a/exercises/practice/leap/impl.mips +++ b/exercises/practice/leap/impl.mips @@ -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 diff --git a/exercises/practice/luhn/impl.mips b/exercises/practice/luhn/impl.mips index 6667cdb..427f8e8 100644 --- a/exercises/practice/luhn/impl.mips +++ b/exercises/practice/luhn/impl.mips @@ -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 diff --git a/exercises/practice/nth-prime/impl.mips b/exercises/practice/nth-prime/impl.mips index 9a90949..bf9b830 100644 --- a/exercises/practice/nth-prime/impl.mips +++ b/exercises/practice/nth-prime/impl.mips @@ -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 diff --git a/exercises/practice/nucleotide-count/impl.mips b/exercises/practice/nucleotide-count/impl.mips index dbec074..74aacfd 100644 --- a/exercises/practice/nucleotide-count/impl.mips +++ b/exercises/practice/nucleotide-count/impl.mips @@ -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 diff --git a/exercises/practice/octal/impl.mips b/exercises/practice/octal/impl.mips index 178b87e..1886ad2 100644 --- a/exercises/practice/octal/impl.mips +++ b/exercises/practice/octal/impl.mips @@ -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 diff --git a/exercises/practice/pop-count/impl.mips b/exercises/practice/pop-count/impl.mips index d2971df..29774b1 100644 --- a/exercises/practice/pop-count/impl.mips +++ b/exercises/practice/pop-count/impl.mips @@ -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 diff --git a/exercises/practice/raindrops/impl.mips b/exercises/practice/raindrops/impl.mips index 222412a..97f3054 100644 --- a/exercises/practice/raindrops/impl.mips +++ b/exercises/practice/raindrops/impl.mips @@ -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 diff --git a/exercises/practice/resistor-color-duo/impl.mips b/exercises/practice/resistor-color-duo/impl.mips index 935570e..48f5c5e 100644 --- a/exercises/practice/resistor-color-duo/impl.mips +++ b/exercises/practice/resistor-color-duo/impl.mips @@ -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 diff --git a/exercises/practice/resistor-color/impl.mips b/exercises/practice/resistor-color/impl.mips index 19bf7ed..f24cafc 100644 --- a/exercises/practice/resistor-color/impl.mips +++ b/exercises/practice/resistor-color/impl.mips @@ -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 diff --git a/exercises/practice/rna-transcription/impl.mips b/exercises/practice/rna-transcription/impl.mips index fc13a33..5748ccf 100644 --- a/exercises/practice/rna-transcription/impl.mips +++ b/exercises/practice/rna-transcription/impl.mips @@ -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 diff --git a/exercises/practice/rotational-cipher/impl.mips b/exercises/practice/rotational-cipher/impl.mips index 3582fd4..9aaec44 100644 --- a/exercises/practice/rotational-cipher/impl.mips +++ b/exercises/practice/rotational-cipher/impl.mips @@ -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 diff --git a/exercises/practice/scrabble-score/impl.mips b/exercises/practice/scrabble-score/impl.mips index 5f72ba9..d89ca00 100644 --- a/exercises/practice/scrabble-score/impl.mips +++ b/exercises/practice/scrabble-score/impl.mips @@ -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 diff --git a/exercises/practice/square-root/impl.mips b/exercises/practice/square-root/impl.mips index 1b64a5e..e1d83ec 100644 --- a/exercises/practice/square-root/impl.mips +++ b/exercises/practice/square-root/impl.mips @@ -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 diff --git a/exercises/practice/triangle/impl.mips b/exercises/practice/triangle/impl.mips index 8f7068d..f5af510 100644 --- a/exercises/practice/triangle/impl.mips +++ b/exercises/practice/triangle/impl.mips @@ -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 diff --git a/exercises/practice/trinary/impl.mips b/exercises/practice/trinary/impl.mips index a4b0820..825b1d9 100644 --- a/exercises/practice/trinary/impl.mips +++ b/exercises/practice/trinary/impl.mips @@ -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