82 lines
3.0 KiB
Lua
82 lines
3.0 KiB
Lua
-- i64-check.lua -- read the M6 i64 marker words and compare them with the
|
|
-- expected ABI/arithmetic values.
|
|
--
|
|
-- I64_MARKERS is the bit address of _i64_markers from the linker map. Each
|
|
-- marker is one 32-bit word at base + n*0x20 bits. The values are pairs:
|
|
-- MSW first, LSW second, so the word order is checked as well as the result.
|
|
--
|
|
-- 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("I64_MARKERS"), 16)
|
|
local N = 57
|
|
local frames = 0
|
|
local checked = false
|
|
|
|
local expect = {
|
|
[0] = 0x2345678A, [1] = 0x00000001, -- addll(carry)
|
|
[2] = 0x00000000, [3] = 0xACF13568, -- addll(12345678h,9ABCDEF0h)
|
|
[4] = 0xFEDCBA98, [5] = 0x00000005, -- subll borrow
|
|
[6] = 0x0000000A, [7] = 0x00000008, -- mull cross terms
|
|
[8] = 0xFFFFFFFF, [9] = 0xFFFFFFF1, -- (-3)*5
|
|
[10] = 0x00010004, [11] = 0xC016906B, -- divll / 1234h
|
|
[12] = 0x00000000, [13] = 0x00000334, -- remll / 1234h
|
|
[14] = 0x00000000, [15] = 0x10000000, -- divll by a >32-bit divisor
|
|
[16] = 0x00000000, [17] = 0x0ABCDEF0, -- remll by a >32-bit divisor
|
|
[18] = 0xFFFFFFDE, [19] = 0xBD0CFDB7, -- sdivll(-1e12, 7)
|
|
[20] = 0xFFFFFFFF, [21] = 0xFFFFFFFF, -- sremll(-1e12, 7) == -1
|
|
[22] = 0xFFFFFFFF, [23] = 0xFFFFFFEF, -- sdivll(123, -7) == -17
|
|
[24] = 0x00000000, [25] = 0x00000004, -- sremll(123, -7) == 4
|
|
[26] = 0x00000100, [27] = 0x00000000, -- 1 << 40
|
|
[28] = 0x00000000, [29] = 0x00000001, -- 8000000000000000h >> 63
|
|
[30] = 0xFFFFFFFF, [31] = 0xFFFFFFFC, -- -16 >> 2
|
|
[32] = 1, [33] = 0, -- cmplt(-1,1), cmplt(1,-1)
|
|
[34] = 1, [35] = 0, -- cmpeq both halves
|
|
[36] = 0x00000006, [37] = 0x00000004, -- i64_slot LSW/MSW word order
|
|
[38] = 0x00000004, [39] = 0x00000006, -- i64 load round-trip
|
|
[40] = 0x0F0F0000, [41] = 0x0F0F0000, -- and
|
|
[42] = 0xFFFF0F0F, [43] = 0xFFFF0F0F, -- or
|
|
[44] = 0xF0F00F0F, [45] = 0xF0F00F0F, -- xor
|
|
[46] = 0x11223344, [47] = 0x55667788, -- zero-argument i64 return
|
|
[48] = 0x11223344, [49] = 0x55667788, -- shll(x, 0)
|
|
[50] = 0x55667788, [51] = 0x00000000, -- shll(x, 32)
|
|
[52] = 0x00000000, [53] = 0x11223344, -- srl(x, 32)
|
|
[54] = 0xFFFFFFFF, [55] = 0x80000000, -- sra(8000..., 32)
|
|
[56] = 0x5A5A5A5A, -- marker after i64_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 i64:"))
|
|
for i = 0, N - 1 do
|
|
io.write(string.format(" %08X", got[i]))
|
|
end
|
|
io.write("\n")
|
|
if bad == 0 then
|
|
print("M6 I64 MAME: PASS")
|
|
else
|
|
for i = 0, N - 1 do
|
|
if got[i] ~= expect[i] then
|
|
print(string.format(
|
|
"M6 i64: marker %d got %08X want %08X",
|
|
i, got[i], expect[i]))
|
|
end
|
|
end
|
|
print("M6 I64 MAME: FAIL")
|
|
end
|
|
end
|
|
end, "i64-check")
|