News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: NES Debugging issue  (Read 2320 times)

Sledge

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
NES Debugging issue
« on: August 26, 2011, 05:49:02 pm »
While playing megaman for nes, I noticed that whenever I "step into" when playing, the program counter takes me to 0xC02B, which code is:

Code: [Select]
07:C02B:A5 1F     LDA $001F = #$00    ; load acumulator with value at $001F, which is 0x00
07:C02D:F0 FC     BEQ $C02B               ; if Z is set (which always is), jumps back to previous instruction

the above code was commented by me, and dissassembled thru FCEUX

My problem with this code is, the adress being loaded at A is always 0x00, so the branch will always occur, right?
But if I keep stepping into, the code will branch to $D4A8, totally out of the blue, right after loading A in the the instruction at C02B!
Why does that happen?



FinS

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • nothing much
Re: NES Debugging issue
« Reply #1 on: August 26, 2011, 06:52:57 pm »
It's a loop to detect when it is done transferring data. You can set a break on execute 07:C02F so you can see what happens when it is done

Bregalad

  • Hero Member
  • *****
  • Posts: 2755
    • View Profile
Re: NES Debugging issue
« Reply #2 on: August 27, 2011, 04:48:55 am »
Quote
My problem with this code is, the adress being loaded at A is always 0x00, so the branch will always occur, right?
Wrong, I guess the loop expects an interrupt to modify the variable. Basically this piece of codes waits for the synchronization interrupt.