#include #include int main(void) { const uint32_t base = 40960; /* 40 KB */ const uint32_t bound = 16384; /* 16 KB */ printf("Simulating hardware address translation\n"); printf("Base register: %u (0x%x)\n", base, base); printf("Bounds register: %u (0x%x)\n\n", bound, bound); uint32_t test_vas[] = {0, 8192, 16383, 16384, 20480}; int n = 5; for (int i = 0; i < n; ++i) { uint32_t va = test_vas[i]; printf("Virtual address %u (0x%x): ", va, va); if (va >= bound) { printf("OUT OF BOUNDS - exception raised\n"); } else { uint32_t pa = va + base; printf("translates to physical %u (0x%x)\n", pa, pa); } } return 0; }