from Hacker News

Solving the Mystery of ARM7TDMI Multiply Carry Flag

by skrrtww on 10/23/24, 1:13 AM with 33 comments

  • by userbinator on 10/23/24, 1:40 AM

    And just to get this out of the way, the carry flag’s behavior after multiplication isn’t an important detail to emulate at all. Software doesn’t rely on it.

    On as fixed of a hardware as a game console, and with the accompanying anti-piracy/anti-cheating/emulation efforts of that industry, I'd expect it to be. From the history of emulating previous consoles, we know that any deterministic difference can and will be exploited, either to determine whether the hardware is authentic, or incidentally as a result of unintentional bugs.

    This reminds me of the Z80, where two undefined flags resisted analysis for several decades; a 2-year-old set of slides on the state of that here: https://archive.fosdem.org/2022/schedule/event/z80/attachmen...

  • by skrrtww on 10/23/24, 1:36 AM

    https://shonumi.github.io/blog/nds_rolling.html

    More context on how this value affects (at least one) DS game- see post from December 27th, 2019.

  • by ujikoluk on 10/23/24, 4:34 AM

    > Seriously, they decided that the program counter should be a general purpose register. Why???

    Don't really understand this reaction. Why not? Seems to make for a nice regular design that the PC is just another register.

  • by flohofwoe on 10/23/24, 8:04 AM

    > it allows the program counter to be used a general purpose register

    From a CPU emulator writer's perspective this isn't all that strange. For instance on Z80 the immediate jump instruction `JP nnnn` is loading a 16-bit immediate value into the internal PC register, which is the same thing as loading a 16-bit value into a regular register pair (e.g. 'LD HL,nnnn') - e.g. the mnemonics for the jump instruction could just as well be `LD PC,nnnn` ;)

    A relative jump (which does a signed-add of an 8-bit offset value to the 16-bit address in PC) is the same math as the Z80 indexed addressing mode (IX+d) and (IY+d) (I don't know though if the same transistors are used).

    A RET (load 16-bit value from stack into PC) is the the same operation as a POP (load 16-bit value from stack into a regular register pair).

    ...so it's almost surprising that the program counter isn't exposed as a regular register in most (traditional) CPUs. I guess in modern CPUs it's not so simple because of the internal pipelining though.