aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basics/main.c20
-rw-r--r--basics/string.S18
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