diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-08-13 06:23:12 +0000 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-05 16:02:29 +0100 |
| commit | 6f0ebbad84419de65a03a0ea6e41cbc6b49d6eb0 (patch) | |
| tree | f5fbeb6e3f50ebb57000f9b1aac6e3ba129d6587 | |
| parent | 8e968078e6aee470a02bed7728100b2df1877e90 (diff) | |
| download | farga-6f0ebbad84419de65a03a0ea6e41cbc6b49d6eb0.tar.gz farga-6f0ebbad84419de65a03a0ea6e41cbc6b49d6eb0.zip | |
basics: Fix typo on 'palindrome'
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
| -rw-r--r-- | basics/main.c | 20 | ||||
| -rw-r--r-- | basics/string.S | 18 |
2 files changed, 19 insertions, 19 deletions
diff --git a/basics/main.c b/basics/main.c index 207fee2..89d4401 100644 --- a/basics/main.c +++ b/basics/main.c @@ -45,26 +45,26 @@ void test_reverse_string() } /* - * Returns true if the given string is a palyndrome, false otherwise. + * Returns true if the given string is a palindrome, false otherwise. * * Implemented in string.S */ -bool is_palyndrome(char *str); +bool is_palindrome(char *str); -void test_is_palyndrome() +void test_is_palindrome() { - assert(is_palyndrome(NULL) == 0); - assert(is_palyndrome("") == 0); - assert(is_palyndrome("aba") == 1); - assert(is_palyndrome("aaa") == 1); - assert(is_palyndrome("This is a a si sihT") == 1); + assert(is_palindrome(NULL) == 0); + assert(is_palindrome("") == 0); + assert(is_palindrome("aba") == 1); + assert(is_palindrome("aaa") == 1); + assert(is_palindrome("This is a a si sihT") == 1); - printf("is_palyndrome:\tOK\n"); + printf("is_palindrome:\tOK\n"); } int main() { test_factorial(); test_reverse_string(); - test_is_palyndrome(); + test_is_palindrome(); } diff --git a/basics/string.S b/basics/string.S index e04e4de..0f3bcc1 100644 --- a/basics/string.S +++ b/basics/string.S @@ -48,13 +48,13 @@ reverse_done: end: jr ra -.globl is_palyndrome -.type is_palyndrome, @function +.globl is_palindrome +.type is_palindrome, @function -// bool is_palyndrome(char *str); -is_palyndrome: +// bool is_palindrome(char *str); +is_palindrome: // Return early on null pointer. - beq a0, zero, palyndrome_no + beq a0, zero, palindrome_no // Set `t0` to point to the end of the string. add t0, a0, zero @@ -68,14 +68,14 @@ pal_set_end_ptr: // to be done and we can return early. Otherwise decrement `t0` so it points // to the byte right before the null termination. pal_end_ptr_done: - beq a0, t0, palyndrome_no + beq a0, t0, palindrome_no addi t0, t0, -1 pal_loop: // Swap values between the two pointers. lb t1, 0(a0) lb t2, 0(t0) - bne t1, t2, palyndrome_no + bne t1, t2, palindrome_no // Move pointers and check whether the pointers have already crossed. If // they have not crossed yet there is still looping to be done. Otherwise @@ -84,10 +84,10 @@ pal_loop: addi t0, t0, -1 bleu a0, t0, pal_loop -palyndrome_yes: +palindrome_yes: li a0, 1 jr ra -palyndrome_no: +palindrome_no: li a0, 0 jr ra |
