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

Author Topic: Geiger's debug console terminology?  (Read 2353 times)

Reptilian

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Geiger's debug console terminology?
« on: December 21, 2014, 07:42:26 pm »
I'm using Geiger's snes9x debugger. I'm learning to decompress some SNES graphics/fonts, so i started tracing the graphics from a RAM address using breakpoints. The console started giving me numbers, but i cant understand the terminology, for example:

$80/8D8A 8C 0B 42    STY $420B  [$81:420B]   A:807F X:320A Y:0001 P:envMxdIzc

$80/8D8D C2 20       REP #$20                A:807F X:320A Y:0001
P:envMxdIzc

$80/8D8F 8A          TXA                     A:807F X:320A Y:0001 P:envmxdIzc

$80/8D90 69 0A 00    ADC #$000A              A:320A X:320A Y:0001 P:envmxdIzc

What does every thing exactly mean?...i'm very confused, i would appreciate any help or directions. Thanks!

Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3532
    • View Profile
    • Aeon Genesis
Re: Geiger's debug console terminology?
« Reply #1 on: December 21, 2014, 09:19:10 pm »
First of all, you'll want to look at the control panel and untick the box marked "squelch." It's hiding some important information (like the stack pointer.)

Let's pick this apart, bit by bit:
$80/8D8A 8C 0B 42    STY $420B  [$81:420B]   A:807F X:320A Y:0001 P:envMxdIzc

$80/8D8A <-- this is the address that contains the code currently being executed.
8C 0B 42 <-- this is the hexadecimal representation of the operation/instruction being performed.
STY $420B <-- this is the mnemonic representation of the operation/instruction being performed (the "command", essentially) along with any relevant parameters.
[$81:420B] <-- this is the effective address being operated on.
A/X/Y: <-- these show the contents of your accumulator (A) and index (X/Y) registers.
P: <-- this shows the status of the processor (various flags.)

In essence, this means that when the SNES executes code at machine address 808D8A, it executes an STY $420B operation (STore Y at $420B). In this case, this means that the contents of the Y index register (Y:0001) gets stored at machine address 81:420B. $420B happens to be a special address that triggers a direct memory transfer (from ROM to RAM, or from RAM to VRAM, usually.)

The other mnemonics are REP (REset Processor bits), TXA (Transfer X to A), and ADC (ADd with Carry). Note the contents of P after the REP #$20 executes - the capital M is now lowercase. More on this in a bit. Note the status of A after the TXA executes - A now contains the exact same thing as X (320A.)

Now regarding REP and its brother operation SEP (SEt Processor bits). The SNES is famous for being a 16 bit console. Each of the registers A, X, and Y as you can see are four digits. Each digit is representative of four bits - all four together are 16 bits. Huzzah! But it's also important to note that the SNES is not a fast machine, and that performing operations in 16 bits tends to be a tiny bit more costly than performing them in 8 bits from a performance perspective. You don't always need all sixteen bits (and performance aside it's even sometimes helpful to just be operating in 8 bits!) so the designers have given us a way to tell the system to operate in 16 bits (default) or 8 bits. Note that you can set 8-bit mode for A, and for X/Y together, but you can't set it for X and not for Y.

REP #$20 REsets the bit on the Processor that tells the system whether A is 8 or 16 bits; since it's clearing the bit (back to default) A is now 16 bits. This is important, because ADC #$000A (69 0A 00) only works when A is 16 bits. If A is 8 bits (M is set) then the processor will interpret this as ADC #$0A (69 0A) instead, and will treat the 00 as the start of the next instruction. This sort of thing usually causes games to crash.

The bits on P include C (carry flag, affects adding 1 during ADC and its equivalent subtraction operation and is also handy for greater than or less than equivalencies), Z (zero flag, useful for exact is/is not equivalencies), D (decimal flag, which tmk nobody ever uses), X (X/Y 8-bit flag), A (accumulator 8-bit flag), V (result overflow), N (result negative), and E (emulation bit which can only be accessed via special instruction.)

That's a lot of information in a fairly condensed space; hopefully it's some use to you. Good luck!

STARWIN

  • Sr. Member
  • ****
  • Posts: 454
    • View Profile
Re: Geiger's debug console terminology?
« Reply #2 on: December 22, 2014, 08:48:17 am »
I'll throw some links for reference.

http://problemkaputt.de/fullsnes.htm - information about SNES in a very compact form - don't expect to understand all sections of it.
http://www.romhacking.net/documents/423/ - information about the CPU used in SNES (and related processors) in a very not compact form - don't expect to read all of it.