diff options
Diffstat (limited to 'debug/programs/debug.c')
| -rw-r--r-- | debug/programs/debug.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/debug/programs/debug.c b/debug/programs/debug.c new file mode 100644 index 0000000..20b1cdc --- /dev/null +++ b/debug/programs/debug.c @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include <stdlib.h> + +unsigned int crc32a(uint8_t *message, unsigned int size); + +void rot13(char *buf) +{ + while (*buf) { + if ((*buf >= 'a' && *buf <= 'm') || + (*buf >= 'A' && *buf <= 'M')) { + *buf += 13; + } else if ((*buf >= 'n' && *buf <= 'z') || + (*buf >= 'N' && *buf <= 'Z')) { + *buf -= 13; + } + buf++; + } +} + +size_t strlen(const char *buf) +{ + int len = 0; + while (buf[len]) + len++; + return len; +} + +extern void *__malloc_freelist; + +int main() +{ + __malloc_freelist = 0; + + volatile int i = 0; + int j = 0; + char *fox = "The quick brown fox jumps of the lazy dog."; + unsigned int checksum = 0; + +start: + while (i) + j++; + + rot13(fox); + checksum ^= crc32a(fox, strlen(fox)); + rot13(fox); + checksum ^= crc32a(fox, strlen(fox)); + + return checksum; +} |
