wswan:guide:optimization_v30mz
Optimizing for the NEC V30MZ CPU
While the V30MZ is an 80186-compatible CPU, its instruction timings differ wildly from common expectations and are more reflective of its 1990s-era design:
MUL
is very fast on this CPU, taking 3-4 cycles. As a result, “shift plus add” ladders will almost always be slower or, at best, equal in performance.- Using
XCHG
overPUSH/POP
(andXCHG AX, reg
overMOV AX, reg
) is a popular pattern on the 8088/8086 due to the speed benefit. However, on the V30MZ, that is not the case:XCHG
on V30MZ always takes 3 cycles.PUSH
andPOP
take 1 cycle each for general registers. This means thatPUSH/POP
will be one cycle faster.- While
MOV AX, reg
is one byte larger thanXCHG AX, reg
, it also only takes 1 cycle.
XLAT
takes 5 cycles. Many simple CPU operations (such asSHR reg, 4
orMUL reg
- both taking 3 cycles) can actually be faster!
TODO: Expand this list.
wswan/guide/optimization_v30mz.txt · Last modified: 2024/02/17 20:11 by asie