diff options
| author | Andrew Waterman <waterman@eecs.berkeley.edu> | 2016-07-19 17:10:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-19 17:10:24 -0700 |
| commit | a27ddca0570517e7e40a91c16e4c96c6c5f329e1 (patch) | |
| tree | 361a63af04da0d4fc42fbe28f79c2d280c54f396 /debug/programs/debug.c | |
| parent | 0849aad0c23f24ed7728128873fc852839e988b1 (diff) | |
| parent | edfe598fd06366170628e88aa6dee762d2c37bbc (diff) | |
| download | riscv-tests-a27ddca0570517e7e40a91c16e4c96c6c5f329e1.zip riscv-tests-a27ddca0570517e7e40a91c16e4c96c6c5f329e1.tar.gz riscv-tests-a27ddca0570517e7e40a91c16e4c96c6c5f329e1.tar.bz2 | |
Merge pull request #17 from timsifive/debug
Add end-to-end debug tests
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; +} |
