Ich versuche gerade einen C-6502 Emulator, der ursprünglich für DOS
geschrieben war (in ANSI-C) mit gcc auf Linux zu compilieren, leider
komme ich gerade nicht weiter...
Ich bekomme einen Segfault an folgender Stelle:
1 | opcode = gameImage[PC++];
|
Die Variablen sind so angelegt:
1 | WORD pc_reg = 0;
|
2 | #define PC pc_reg
|
3 | BYTE opcode;
|
WORD ist unsigned short, BYTE ist unsigned char.
Der Code sieht so aus:
1 | void exec6502(int timerTicks)
|
2 | {
|
3 | while (timerTicks > 0) {
|
4 | printf("PC:%05d timerTicks:%d\n", PC, timerTicks);
|
5 |
|
6 | // fetch instruction
|
7 | opcode = gameImage[PC++];
|
8 | // execute instruction
|
9 | instruction[opcode]();
|
10 |
|
11 | // calculate clock cycles
|
12 | clockticks6502 += ticks[opcode];
|
13 | timerTicks -= clockticks6502;
|
14 | clockticks6502 = 0;
|
15 | }
|
16 | }
|
Die exec6502() wird mit exec6502(1024); aufgerufen.
Ich hoffe ihr könnt mir dabei helfen, ich denke mal es fehlt nichts,
kann aber noch sonst noch mehr Code Posten.