VOGONS


First post, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Here is something that might help other emulator writers out there.

Since my emulator's unit of execution is a cycle it has some performance issues as a lot of host cycles have to be spent executing 8+ types of cycles for each emulated instruction. As such I need to improve that so for that I need a measuring tool. Below is a skeleton of a program where you can put any instructions you want and the run it (in place of a real BIOS) and count the time from beginning until you see the HLT instruction. Divide that by number of cycles your emulator executed and you see how fast you are.

For example, CAPE can do "aaa" (which is a 4 cycle instruction so the EU will never be starved from the prefetch queue) with an average speed of 25000 cycles/ms or 25Mhz. In other words at its maximum speed, if all CAPE would execute would "aaa" then it can cycle accurate emulate that at around 25Mhz 8088.

Just change the "aaa" instruction below with whatever you want. To compile you can use MASM32 (free from here: http://masm32.com/download.htm) like this:

ml /AT /Fm /Fl /Bllink16.exe yourfile.asm /Feyourfile.bin

It will produce a bin file of 64k size and load it like a normal BIOS.

.286
.model tiny
.code

start:

start_here:
; preparetion, put stuff in registers
mov ax, 12
mov dx, 1

; the instruction you chose will be execute bx * cx * 40 = 10 * 60000 * 40 = 24000000 (24 million times)
mov bx, 10
outer:
mov cx, 60000
repct = 40
inner:
REPEAT repct

; insert instruction here
; =========
aaa
; =========

ENDM
loop inner
dec bx
jnz outer
hlt

org 0FFF0h

jmp start_here

org 0FFFFh
db 0ffh

end start

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/