115 lines
4.1 KiB
Lua
115 lines
4.1 KiB
Lua
-- float-check.lua -- read the M6 float/double marker words and compare them
|
|
-- with the expected GSP bit patterns.
|
|
--
|
|
-- FLOAT_MARKERS is the bit address of _float_markers from the linker map. Each
|
|
-- marker is one 32-bit word at base + n*0x20 bits. Doubles are pairs: LSW
|
|
-- first (the lower address), MSW second, which is also the GSP memory order.
|
|
--
|
|
-- The marker read runs one frame before loader.lua's inspection/exit frame.
|
|
|
|
dofile(os.getenv("M2_LOADER_LUA"))
|
|
|
|
local ENDF = tonumber(os.getenv("LOADER_END") or "2900")
|
|
local BASE = tonumber(os.getenv("FLOAT_MARKERS"), 16)
|
|
local N = 80
|
|
local frames = 0
|
|
local checked = false
|
|
|
|
local expect = {
|
|
[0] = 0x41400000, -- fadd(1.5,2.5) = 4.0
|
|
[1] = 0x40400000, -- fsub(2.5,1.5) = 1.0
|
|
[2] = 0xC0400000, -- fsub(1.5,2.5) = -1.0
|
|
[3] = 0x41C00000, -- fmul(4.0,2.0) = 8.0
|
|
[4] = 0x40C00000, -- fdiv(4.0,2.0) = 2.0
|
|
[5] = 0xC0600000, -- fneg(1.5) = -1.5
|
|
[6] = 0x41400000, -- C body float_add(1.5,2.5)
|
|
[7] = 0x40600000, -- C float_ret() = 1.5
|
|
[8] = 0x00000000, [9] = 0x40280000, -- dadd(1.5,2.5) = 4.0
|
|
[10] = 0x00000000, [11] = 0x40080000, -- dsub(2.5,1.5) = 1.0
|
|
[12] = 0x00000000, [13] = 0xC0080000, -- dsub(1.5,2.5) = -1.0
|
|
[14] = 0x00000000, [15] = 0x40380000, -- dmul(4.0,2.0) = 8.0
|
|
[16] = 0x00000000, [17] = 0x40180000, -- ddiv(4.0,2.0) = 2.0
|
|
[18] = 0x00000000, [19] = 0xC00C0000, -- dneg(1.5) = -1.5
|
|
[20] = 0x00000000, [21] = 0x40280000, -- C double_add(1.5,2.5) = 4.0
|
|
[22] = 0x00000000, [23] = 0x401A0000, -- C double_ret() = 2.5
|
|
[24] = 1, -- fcmpeq(1.5,1.5)
|
|
[25] = 0, -- fcmpeq(1.5,2.5)
|
|
[26] = 1, -- fcmplt(1.5,2.5)
|
|
[27] = 0, -- fcmplt(2.5,1.5)
|
|
[28] = 1, -- fcmple(2.5,2.5)
|
|
[29] = 1, -- fcmpgt(2.5,1.5)
|
|
[30] = 0, -- fcmpge(1.5,2.5)
|
|
[31] = 1, -- fcmpne(1.5,2.5)
|
|
[32] = 0, -- fcmpne(1.5,1.5)
|
|
[33] = 1, -- dcmplt(1.5,2.5)
|
|
[34] = 0, -- dcmplt(2.5,1.5)
|
|
[35] = 1, -- dcmpeq(2.5,2.5)
|
|
[36] = 2, -- ftoi(2.5)
|
|
[37] = 0xFFFFFFFF, -- ftoi(-1.5) = -1
|
|
[38] = 3, -- ftou(3.9)
|
|
[39] = 2, -- dtoi(2.5)
|
|
[40] = 3, -- dtou(3.9)
|
|
[41] = 0x41700000, -- itof(7) = 7.0
|
|
[42] = 0x41700000, -- utof(7) = 7.0
|
|
[43] = 0xC0E00000, -- itof(-3) = -3.0
|
|
[44] = 0x00000000, [45] = 0x402E0000, -- itod(7) = 7.0
|
|
[46] = 0x00000000, [47] = 0x402E0000, -- utod(7) = 7.0
|
|
[48] = 0x00000000, [49] = 0x400C0000, -- ftod(1.5f) = 1.5
|
|
[50] = 0x40D00000, -- dtof(2.5) = 2.5
|
|
[51] = 0x41700000, -- constant 7.0f
|
|
[52] = 0xC0E00000, -- constant -3.0f
|
|
[53] = 0x00000000, [54] = 0x402E0000, -- constant 7.0
|
|
[55] = 0x00000000, [56] = 0xC01C0000, -- constant -3.0
|
|
[57] = 1, -- fcmpge(2.5,2.5)
|
|
[58] = 0, -- fcmpgt(1.5,1.5)
|
|
[59] = 0xFFFFFFFF, -- dtoi(-1.5) = -1
|
|
[60] = 0, -- fcmple(2.5,1.5)
|
|
[61] = 0, -- dcmpeq(1.5,2.5)
|
|
[62] = 11, -- fb_lt(1.5,2.5) true path
|
|
[63] = 22, -- fb_lt(2.5,1.5) false path
|
|
[64] = 33, -- db_lt(1.5,2.5) true path
|
|
[65] = 44, -- db_lt(2.5,1.5) false path
|
|
[66] = 3, -- fcount_lt(1.5,4.0): 1.5,2.5,3.5
|
|
[67] = 0x00000000, [68] = 0x400C0000, -- dsel_i(1,1.5,2.5) = 1.5
|
|
[69] = 0x00000000, [70] = 0x401A0000, -- dsel_i(0,1.5,2.5) = 2.5
|
|
[71] = 0x00000000, [72] = 0x40280000, -- dsel_f(<,4.0,8.0) = 4.0
|
|
[73] = 0x00000000, [74] = 0x40380000, -- dsel_f(>,4.0,8.0) = 8.0
|
|
[75] = 0x00000000, -- fnegzero(): GSP canonicalises -0.0
|
|
[76] = 0x00000000, -- fposzero()
|
|
[77] = 0x00000000, [78] = 0x00000000, -- dnegzero(): two zero words
|
|
[79] = 0x5A5A5A5A, -- marker after float_run returns
|
|
}
|
|
|
|
emu.register_frame_done(function()
|
|
frames = frames + 1
|
|
if frames == ENDF - 1 and not checked then
|
|
checked = true
|
|
local prog = manager.machine.devices[':maincpu'].spaces['program']
|
|
local got = {}
|
|
local bad = 0
|
|
for i = 0, N - 1 do
|
|
got[i] = prog:read_u32(BASE + i * 0x20)
|
|
if got[i] ~= expect[i] then
|
|
bad = bad + 1
|
|
end
|
|
end
|
|
io.write(string.format("M6 float:"))
|
|
for i = 0, N - 1 do
|
|
io.write(string.format(" %08X", got[i]))
|
|
end
|
|
io.write("\n")
|
|
if bad == 0 then
|
|
print("M6 FLOAT MAME: PASS")
|
|
else
|
|
for i = 0, N - 1 do
|
|
if got[i] ~= expect[i] then
|
|
print(string.format(
|
|
"M6 float: marker %d got %08X want %08X",
|
|
i, got[i], expect[i]))
|
|
end
|
|
end
|
|
print("M6 FLOAT MAME: FAIL")
|
|
end
|
|
end
|
|
end, "float-check")
|