VR4300

From N64brew Wiki
Revision as of 03:44, 4 August 2021 by Vanadium (talk | contribs)
Jump to navigation Jump to search

The VR4300 is the CPU of the Nintendo 64, and is an NEC VR4300i with slight modifications. Running at 93.75 MHz, the VR4300 handles game logic, reading responding to controller input from the PIF, and preparing display lists and audio command lists for the RCP to draw and synthesize audio.

VR4300 Users Manual

Known Bugs

Some VR4300 CPUs contain the “VR4300 multiplication bug”. This causes incorrect results to be generated, under certain circumstances, after computing a floating-point multiplication. The bug was fixed in later steppings, and affects some but not all Nintendo 64 consoles. There is a ROM which tests if your hardware is affected by this bug (where?)

GCC accepts the -mfix4300 flag, which tells GCC to generate code with a workaround for this bug—two nop instructions are inserted after every mul.s or mul.d. For example, consider this function:

float mul(float x, float y) { return x * y; }

If the fix is disabled, GCC will generate the following assembly (for the n32 ABI):

# Does not contain workaround, may cause problems.
mul:
        jr      $31
        mul.s   $f0,$f12,$f14

With the setting enabled, GCC will append nop instructions. Note that in this case, the second one goes into the branch delay slot.

# Contains workaround for CPU bug.
mul:
        jr      $31
        nop
        mul.s   $f0,$f12,$f14
        nop