The readbyte() function constantly checks if any of the mapped interfaces is enabled. It is more efficient to check the address, which is present in a register anyway, and only check the interfaces if the address is under 0x4000.
On R-Type RZX replay, the number of retired instructions drops from 20.1M to 16.5M (from 13.8% to 11.1% of total) as seen in the callgrind dump below.
--------------------------------------------------------------------------------
Ir file:function
--------------------------------------------------------------------------------
before:
45,498,785,091 (31.03%) z80/z80_ops.c:z80_do_opcodes [/home/henry/build/fuse-emulator-fuse/fuse]
20,271,656,484 (13.82%) memory_pages.c:readbyte [/home/henry/build/fuse-emulator-fuse/fuse]
12,135,737,120 ( 8.28%) ./z80/opcodes_base.c:z80_do_opcodes
after:
45,375,286,300 (30.57%) z80/z80_ops.c:z80_do_opcodes [/home/henry/build/fuse-emulator-fuse/fuse]
16,531,600,685 (11.14%) memory_pages.c:readbyte [/home/henry/build/fuse-emulator-fuse/fuse]
12,085,983,272 ( 8.14%) ./z80/opcodes_base.c:z80_do_opcodes
the same patch with (hopefully) fixed coding style.
Thanks! Committed in [fe8398].
Related
Commit: [fe8398]