CPU_Math.i

Summary
CPU_Math.i
Macros
muluUnsigned multiplication (S-CPU MMIO)
divuUnsigned division (S-CPU MMIO)
mulsSigned multiplication (S-PPU MMIO)

Macros

mulu

Unsigned multiplication (S-CPU MMIO)

If :out: parameter is omitted, get result in RDMPYL/H (uint16) after 5 cycles

Parameters

:in:    n1    Multiplicand (uint8)    a/x/y     Requires RW a8 or i8
                                      constant  Uses a, sets RW a8
:in:    n2    Multiplier (uint8)      a/x/y     Requires RW a8 or i8
                                      constant  Uses a, sets RW a8
:out?:  ret   Product (uint16)        a/x/y     Sets RW a16 or i16

Example

lda      #$88
mulu     a,$7f, x      ;Returns x = #$4378

divu

Unsigned division (S-CPU MMIO)

If :out: parameters are omitted, get quotient in RDDIVL (uint16) and remainder in RDMPYL (uint16) after 13 cycles

Parameters

:in:    n1    Dividend (uint16)       a/x/y     Requires RW a16 or i16
                                      constant  Uses x, sets RW i16
:in:    n2    Divisor (uint8)         a/x/y     Requires RW a8 or i8
                                      constant  Uses a, sets RW a8
:out?:  ret   Quotient (uint16)       a/x/y     Sets RW a16 or i16
:out?:  retr  Remainder (uint16)      a/x/y     Sets RW a16 or i16

muls

Signed multiplication (S-PPU MMIO)

Not available during Mode 7 rendering If :out: parameter is omitted, result available in MPYL/M/H (sint24) immediately

Parameters

:in:    n1    Multiplicand (sint16)   x/y       Uses a, sets RW a8
                                      constant  Uses a, sets RW a8
:in:    n2    Multiplier (sint8)      a         Requires RW a8
                                      constant  Uses a, sets RW a8
:out?:  ret   Product (sint24)        ax/ay     Sets RW a8i16