Comments (3)
This definitely puzzled me, but I think I've figured it out: the stack is stomping upon the instruction mid-flight.
The cycle breakdown for JSR per 64doc is:
1 PC R fetch opcode, increment PC
2 PC R fetch low address byte, increment PC
3 $0100,S R internal operation (predecrement S?)
4 $0100,S W push PCH on stack, decrement S
5 $0100,S W push PCL on stack, decrement S
6 PC R copy low address byte to PCL, fetch high address
byte to PCH
So in this case:
PC is initially 0x17B; S is initially 0x7D so the stack pointer is currently at 0x17D.
- fetch opcode from 0x17b, which is 0x20;
- fetch low byte of target address from 0x17c, which is 0x55;
- read from the stack, by coincidence address 0x17d, doing absolutely nothing with the result;
- write the current high byte of the PC, which is value 1, to the stack at 0x17d;
- write the current low byte of the PC, which is 0x7d, to the stack at 0x17c;
- fetch high byte of target address from 0x17d, which is now 1, because it was written there back in cycle 4.
from processortests.
WAIT. Wow. This test is executing instructions INSIDE of the stack. I didn't even think about that!
This is both the best and worst test ever written.
You, my friend, have won the internet.
from processortests.
Just to follow up, I implemented that order of operation and that passed the test, thank you so much!
var addressLow = readByte();
pushWord(state.pc);
var addressHigh = readByte();
state.pc = (addressHigh << 8) | addressLow;
from processortests.
Related Issues (20)
- 65816: DBR should not be reset on BRK/COP in emulation mode
- 65816: Emulation mode stack wrapping HOT 2
- 65816: (dp,x) emulation mode page wrapping
- 65816: More emulation mode stack wrapping HOT 2
- Possible wrong cycle count for NES 6502 0C and 1/3/5/7/D/FC HOT 4
- 8088 Test Suite HOT 4
- Inconsistency of the negative flag in decimal mode across 6502 emulators HOT 2
- nes6502 README.md has incorrect sample HOT 1
- 8088 8D instruction (LEA) test has LEA r, r forms. HOT 4
- The 6502 tests assume the P register has bits 4 & 5.
- Opcode 6B Respects D Flag on NES Tests
- Opcode 9C/9E: nes6502 Result Inconsistent with Test ROM HOT 2
- 8088: some `name`s refer to `si` but should refer to `di` HOT 7
- 6502: JSR Overwriting Instruction HOT 3
- Possibly wrong test case d133 [ADD.b D0, (d8, A3, Xn)] HOT 2
- 68000: Suggestion for additional DIVS/DIVU test cases
- Test case issue `5ca0` `ADD.l Q, -(A0)` HOT 2
- 65816: missing coverage for zero flag in 16-bit adds
- 6502 CMOS (rockwell and WDC) have incorrect tests for BBR/BBS? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from processortests.