Hello!
I'm currently working on a small NES emulator for learning purpose and trying to test my CPU.
When I run the nestest.nes it works fine until (from nestest-1.log)
The Problem i think is that somehow a PLA gets ignored since at CE44 the Accumulator should have the value 0xCE.
I have no idea where this comes from since the tests works fine with PLA and the other instructions until that point.
Running the test again in nestopia also gets the correct results.
I wonder how this can happen when everything works fine before 0xCE42 (stack Operations etc).
Since I'm writing my emulator in ASM and handle writing to the memory with byte ptr ds: and word ptr ds: could it be that i have to switch something
or create one function for push8 and one for push16 instead having it in one?
are my stack functions.
I hope someone can help me!
Regards,
I'm currently working on a small NES emulator for learning purpose and trying to test my CPU.
When I run the nestest.nes it works fine until (from nestest-1.log)
Code:
// nesttest-1.log
CE42 68 PLA A:69 X:7E Y:01 P:27 SP:7E CYC:269 SL:258
CE43 68 PLA A:39 X:7E Y:01 P:25 SP:7F CYC:281 SL:258
CE44 BA TSX A:CE X:7E Y:01 P:A5 SP:80 CYC:293 SL:258
CE42 68 PLA A:69 X:7E Y:01 P:27 SP:7E CYC:269 SL:258
CE43 68 PLA A:39 X:7E Y:01 P:25 SP:7F CYC:281 SL:258
CE44 BA TSX A:CE X:7E Y:01 P:A5 SP:80 CYC:293 SL:258
The Problem i think is that somehow a PLA gets ignored since at CE44 the Accumulator should have the value 0xCE.
Code:
// My result
[CE42] - A: 69 X: 7E Y: 01 P: 27 SP: 7E
[CE43] - A: 69 X: 7E Y: 01 P: 25 SP: 7F
[CE44] - A: 39 X: 7E Y: 01 P: 25 SP: 80
[CE42] - A: 69 X: 7E Y: 01 P: 27 SP: 7E
[CE43] - A: 69 X: 7E Y: 01 P: 25 SP: 7F
[CE44] - A: 39 X: 7E Y: 01 P: 25 SP: 80
I have no idea where this comes from since the tests works fine with PLA and the other instructions until that point.
Running the test again in nestopia also gets the correct results.
I wonder how this can happen when everything works fine before 0xCE42 (stack Operations etc).
Since I'm writing my emulator in ASM and handle writing to the memory with byte ptr ds: and word ptr ds: could it be that i have to switch something
or create one function for push8 and one for push16 instead having it in one?
Code:
cpu_push proc USES eax ecx pValue:WORD, pSize:BYTE
mov cx, 100h
or cl, CPU_REG_SP
invoke cpu_write, cx, pValue, pSize
sub cl, pSize
mov CPU_REG_SP, cl
ret
cpu_push endp
cpu_pop proc USES ecx pSize:BYTE
mov cx, 100h
or cl, CPU_REG_SP
add cl, pSize
mov CPU_REG_SP, cl
invoke cpu_read, cx, pSize
ret
cpu_pop endp
mov cx, 100h
or cl, CPU_REG_SP
invoke cpu_write, cx, pValue, pSize
sub cl, pSize
mov CPU_REG_SP, cl
ret
cpu_push endp
cpu_pop proc USES ecx pSize:BYTE
mov cx, 100h
or cl, CPU_REG_SP
add cl, pSize
mov CPU_REG_SP, cl
invoke cpu_read, cx, pSize
ret
cpu_pop endp
are my stack functions.
I hope someone can help me!
Regards,