Data Bank (B) register woes (attn: koitsu, byuu)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Data Bank (B) register woes (attn: koitsu, byuu)
by on (#176935)
So whenever I attempt to change B, the Data Bank register, to a different value using code like this (assume A = 8 bit):

Code:
lda #$XX
pha
plb

... then B apparently isn't updated to $XX immediately, unlike with Direct Page register changes. The tracelog tells me that several, even dozens of absolute (i.e., 16-bit operand) instructions that use the old data bank may pass before it switches to the new one.

Is this normal? Or what am I doing wrong?

Thanks for any advice! :)
Re: Data Bank (B) register woes (attn: koitsu, byuu)
by on (#176938)
plb definitely should be updating DB immediately. What are you using to generate the tracelog?
Re: Data Bank (B) register woes (attn: koitsu, byuu)
by on (#176940)
... I'm a dumb**s. :lol:

Right after posting this, I realized that I was staring at DP (Direct Page) instructions instead of absolute ones like I thought I used in my code ... and DP is always in bank $00, right? So yeah, my mistake. Don't bother with it. :mrgreen:
Re: Data Bank (B) register woes (attn: koitsu, byuu)
by on (#176942)
Ramsis wrote:
DP is always in bank $00, right?

I've been using DP as an index register when I've ran out, so this is very good to know, because if anything I'm trying to point to isn't in bank $00 (which I don't think my object table with as many entries as I want will fit in the ram there) then I'm going to have a problem.