Normal without an exception void foo() { printf("hello world\n"); } --- Load/Store access fault (exception 5, 7): int *ptr = (int*)0xdeadbeef; int b = *ptr; *ptr = 1; --- Illegal instruction (exception 2) int *exit_code = (int*) 0x820000c; *exit_code = 0xdeadbeef; --- Illegal instruction II (exception 2) asm("jr %0"::"r"(foo+2)); // [this is an incorrect explained example in class, // where "foo" is in type "void *(void)", // and "+2" advances the address by 2*sizeof(void*)] Q: difference between "jr" and "call"? asm("jr %0"::"r"(foo)); printf("will not get here"); --- Illegal instruction (exception 2) asm("csrw mstatus, %0" ::"r"(0xdeadbeef)); --- explore MISP (gdb) display/t $mip (gdb) b syscall.c:46 --- linux: malloc too much memory #include #include #include #define M256 1024*1024*256 int main() { unsigned long long counter = 0; while(1) { void *tmp = malloc(M256); counter += 256; memset(tmp, 0, M256); printf("allocated %.2f GB memory\n", counter/1024.0); } }