Skip to content
Snippets Groups Projects
Commit 8461600b authored by Michal Privoznik's avatar Michal Privoznik
Browse files

02: Off by one errors fixes

parent 16863c3a
No related branches found
No related tags found
No related merge requests found
......@@ -104,16 +104,16 @@ test1(uint8_t **frames, unsigned long nframes)
goto cleanup;
}
for (uint16_t addr = 0x0000; addr < nframes * FRAME_SIZE; addr++) {
for (size_t addr = 0x0000; addr < nframes * FRAME_SIZE; addr++) {
uint8_t b;
if (read_byte(mmu, addr, &b) < 0) {
ERROR("Failed to read byte at address 0x%x", addr);
ERROR("Failed to read byte at address 0x%x", (uint16_t)addr);
goto cleanup;
}
if (write_byte(mmu, addr, b) < 0) {
ERROR("Failed to write byte at address 0x%x", addr);
ERROR("Failed to write byte at address 0x%x", (uint16_t)addr);
goto cleanup;
}
}
......@@ -143,7 +143,7 @@ test2(uint8_t **frames, unsigned long nframes)
for (i = 0; i < 2; i++) {
size_t len = strlen(strings[i]);
uint16_t addr = i ? 0x01ff - len : 0x0100;
uint16_t addr = i ? nframes * FRAME_SIZE - len : 0;
int j;
for (j = 0; j < len; j++) {
......@@ -156,7 +156,7 @@ test2(uint8_t **frames, unsigned long nframes)
for (i = 0; i < 2; i++) {
size_t len = strlen(strings[i]);
uint16_t addr = i ? 0x01ff - len : 0x0100;
uint16_t addr = i ? nframes * FRAME_SIZE - len : 0;
int j;
for (j = 0; j < len; j++) {
......@@ -174,7 +174,7 @@ test2(uint8_t **frames, unsigned long nframes)
}
}
hexdump(mmu, 0x0100, 0x01ff);
hexdump(mmu, 0x0, nframes * FRAME_SIZE - 1);
ret = 0;
cleanup:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment