aboutsummaryrefslogtreecommitdiff
path: root/debug/programs/debug.c
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-06-07 16:59:26 -0700
committerTim Newsome <tim@sifive.com>2016-07-18 18:51:54 -0700
commit6990284b8eab8d4e4f57f82ac8918913c5c63e97 (patch)
tree6c3f83d00f215e9e829745c9bde1a5573b82066b /debug/programs/debug.c
parentf29d14a877d4873c12fa80c9df5b265474a85b05 (diff)
downloadriscv-tests-6990284b8eab8d4e4f57f82ac8918913c5c63e97.zip
riscv-tests-6990284b8eab8d4e4f57f82ac8918913c5c63e97.tar.gz
riscv-tests-6990284b8eab8d4e4f57f82ac8918913c5c63e97.tar.bz2
Made some progress towards working with spike.
I'm writing all the tests so they should just work on real hardware, too.
Diffstat (limited to 'debug/programs/debug.c')
-rw-r--r--debug/programs/debug.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/debug/programs/debug.c b/debug/programs/debug.c
index 2cad88f..afca484 100644
--- a/debug/programs/debug.c
+++ b/debug/programs/debug.c
@@ -1,27 +1,46 @@
#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
-char c = 'x';
+unsigned int crc32a(uint8_t *message, unsigned int size);
-void print_row(int length)
+void rot13(char *buf)
{
- for (int x=0; x<length; x++) {
- printf("%c", c);
+ 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++;
}
- printf("\n");
+}
+
+size_t strlen(const char *buf)
+{
+ int len = 0;
+ while (buf[len])
+ len++;
+ return len;
}
int main()
{
- volatile int i = 42;
- const char *text = "constant\n";
- int threshold = 7;
+ volatile int i = 0;
+ int j = 0;
+ char *fox = "The quick brown fox jumps of the lazy dog.";
+ unsigned int checksum = 0;
- // Wait for the debugger to get us out of this loop.
+start:
while (i)
- ;
+ j++;
- printf("%s", text);
- for (int y=0; y < 10; y++) {
- print_row(y);
- }
+ rot13(fox);
+ checksum ^= crc32a(fox, strlen(fox));
+ rot13(fox);
+ checksum ^= crc32a(fox, strlen(fox));
+
+ return checksum;
}