Hello, I've been really interested in NES emulation for the past week or so. Right now I'm researching and beginning to code a 6502 emulator, but I have a few questions.
For an (indirect,x) operation, can the read word pass a page boundary? Because I've read this:
So, what does the cpu read when executing:
$00FF, then $0100? Or $00FF, then $0000?
.....dangit, I went and ate some food and forgot the rest of my questions.
Well, here's one. How's my basic emulation theory look, I got some ideas from http://www.slack.net/~ant/nes-emu/6502.html , but my actual code in progress is quite a bit different.
How do I handle NMI's and IRQ's? Where do they fit into my emulation cycle?
....if I remember my other questions, I'll come back and add them....
For an (indirect,x) operation, can the read word pass a page boundary? Because I've read this:
6502_cpu.txt wrote:
Write instructions (STA, SAX)
# address R/W description
--- ----------- --- ------------------------------------------
1 PC R fetch opcode, increment PC
2 PC R fetch pointer address, increment PC
3 pointer R read from the address, add X to it
4 pointer+X R fetch effective address low
5 pointer+X+1 R fetch effective address high
6 address W write to effective address
Note: The effective address is always fetched from zero page,
i.e. the zero page boundary crossing is not handled.
# address R/W description
--- ----------- --- ------------------------------------------
1 PC R fetch opcode, increment PC
2 PC R fetch pointer address, increment PC
3 pointer R read from the address, add X to it
4 pointer+X R fetch effective address low
5 pointer+X+1 R fetch effective address high
6 address W write to effective address
Note: The effective address is always fetched from zero page,
i.e. the zero page boundary crossing is not handled.
So, what does the cpu read when executing:
Code:
lda ($FF,x) ;x=0
$00FF, then $0100? Or $00FF, then $0000?
.....dangit, I went and ate some food and forgot the rest of my questions.
Well, here's one. How's my basic emulation theory look, I got some ideas from http://www.slack.net/~ant/nes-emu/6502.html , but my actual code in progress is quite a bit different.
my emulation cycle wrote:
My 6502 emulation function takes in the number of cycles to run(although, it can go over since I don't do cycle-by-cycle emulation).
I grab the opcode.
Adjust the "cycles to run" value with the current instructions cycle count, taken from a table.
Grab the addressing mode of the instruction from a table, and resolve the final address needed for the instruction, also adjusting for page boundary cycle hits on the necessary instructions.
Run the instruction.
Check to see if we've ran through enough cycles. If not, go back to grabbing an opcode.
I grab the opcode.
Adjust the "cycles to run" value with the current instructions cycle count, taken from a table.
Grab the addressing mode of the instruction from a table, and resolve the final address needed for the instruction, also adjusting for page boundary cycle hits on the necessary instructions.
Run the instruction.
Check to see if we've ran through enough cycles. If not, go back to grabbing an opcode.
How do I handle NMI's and IRQ's? Where do they fit into my emulation cycle?
....if I remember my other questions, I'll come back and add them....