Segmentation fault when reading the program
counter and incrementing it by 2 (Intel 8080)
ERROR:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000405411 in nextWord (c=0x494d) at memory.c:32
32 uint16_t word = readWord(c, c->pc);
THE CODE: (I added the upper portion in case it's needed).
uint8_t readByte(i8080* const c, uint16_t addr)
{
return c->memory[addr & 0xFF];
}
uint16_t readWord(i8080* const c, uint16_t addr)
{
return (readByte(c, addr + 1) << 8 | readByte(c, addr));
}
uint16_t nextWord(i8080* const c)
{
uint16_t word = readWord(c, c->pc);
c->pc += 2;
return word;
}
```C