NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode


Subjectjsr/rts new  
Posted byworkingclass77
Posted on1/15/04 11:26 PM
From IP66.169.215.42  



i think i'm having a problem in my jsr and/or rts functions, but i'm not sure, so if someone would look at them, i'd appreciate it:

inline DWORD CPU6502::JSRa () {
WORD pLoc = GetParamAbsolute();
m_registerPC += 2;

StackPush(HIGH(m_registerPC));
StackPush(LOW(m_registerPC));
m_registerPC = pLoc;
return 6;
}

inline DWORD CPU6502::RTS () {
BYTE pcLow = StackPop();
BYTE pcHigh = StackPop();
m_registerPC = MAKE_WORD(pcHigh, pcLow) + 1;
return 6;
}

GetParamAbsolute() is returning the address contained right after the instruction. maybe thats wrong, i dunno. anyway, thanks.




SubjectRe: jsr/rts  
Posted by<_Hyde_>
Posted on1/16/04 07:18 AM
From IP63.93.74.140  



As far as I can tell they look all right... GetParamAbsolute() should be returning an absolute address (i.e. PRGRAM [PC + 1] | (PRGRAM [PC + 2] << 8), considering PC points to the jsr instruction).

hydesprojects.cjb.net


SubjectRe: jsr/rts new  
Posted byAnonymous
Posted on1/16/04 10:45 AM
From IP66.169.215.42  



right, ok...that's what its doing...so the problem is somewhere else in this tangled mess of code :)




SubjectRe: jsr/rts new  
Posted byblargg
Posted on1/16/04 9:24 PM
From IP199.170.89.113  



Just write a short machine code sequence that has a JSR to an RTS. Step through and verify that the addresses are correct. Should pinpoint the cause(s) of the problem.





SubjectRe: jsr/rts new  
Posted byMuchaserres
Posted on1/17/04 10:26 AM
From IP62.82.128.43  



On JSRa(), m_registerPC should only be incremented by 1 (a byte before the next opcode). Just look at

m_registerPC = MAKE_WORD(pcHigh, pcLow) + 1;

On RTS() PC is incremented by one cause the pushed PC is just the byte before the actual instruction. So I think you should only increment m_registerPC by one, not two.

Hope this helps. Cya!




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo