-- aggregate-check.lua -- read the M6 aggregate marker words and compare them -- with the expected ABI/layout values. -- -- AGGREGATE_MARKERS is the bit address of _aggregate_markers from the linker -- map. Each marker is one 32-bit word at base + n*0x20 bits. The raw-object -- markers pin the byte layout (little-endian, fields in ascending order) and -- the guards prove an aggregate copy does not overrun the object. -- -- 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("AGGREGATE_MARKERS"), 16) local N = 49 local frames = 0 local checked = false local expect = { [0] = 0x11223344, [1] = 0x00005566, -- mk_six fields [2] = 0x11223344, [3] = 0x00005566, -- raw six object word/half [4] = 0x600D600D, -- guard after a 6-byte copy [5] = 0xAABBCCDD, [6] = 0x0000005A, -- mk_five fields (5-byte object) [7] = 0xAABBCCDD, [8] = 0x0000005A, -- raw five object word/byte [9] = 0x000000A5, -- guard after a 5-byte copy [10] = 0x00000010, [11] = 0x00000011, -- mk_big fields [12] = 0x00000012, [13] = 0x00000013, [14] = 0x00000014, [15] = 0x00000010, [16] = 0x00000011, -- raw big object words [17] = 0x00000012, [18] = 0x00000013, [19] = 0x00000014, [20] = 0xAAAA5555, [21] = 0x12345678, -- mk_pair (the 1987 _mkpair) [22] = 0x00000100, [23] = 0x00000009, -- mk_outer nested fields [24] = 0x00000003, [25] = 0xDEADBEEF, [26] = 0xDEADBEEF, -- mk_uni field and raw word [27] = 0x3366EF96, -- sum_six(six, 100) [28] = 0x00000024, -- sum_big(big) [29] = 0x12345678, -- sum_uni(uni) [30] = 0x000000CF, -- c_usesix(50) [31] = 0x00000018, -- c_usebig(10) [32] = 0x00000405, -- c_useouter(0x200) [33] = 0x0BADF00D, -- c_useuni(...) [34] = 0x0000000B, -- c_sumpair({5,6}) [35] = 0x00000030, -- c_sumsix({0x10,0x20}) [36] = 0x112233C2, -- c_sumuni(l + c[5]) [37] = 0x000000D2, -- c_usemixed(100) [38] = 0x00000064, -- mixed raw a [39] = 0x00000064, -- mixed raw i64 LSW (little-endian) [40] = 0x00000000, -- mixed raw i64 MSW [41] = 0x00000000, -- mixed raw double LSW (GSP 1.5) [42] = 0x400C0000, -- mixed raw double MSW [43] = 0x40D00000, -- mixed raw float (GSP 2.5) [44] = 0x00000007, -- mixed raw char [45] = 0x000B1405, -- c_mkbits fields a=5 b=20 c=-5 [46] = 0xFFFFFFFB, -- signed int c:4 sign-extends [47] = 0x00000BA5, -- raw packed bitfield word [48] = 0x5A5A5A5A, -- marker after aggregate_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 aggregate:")) for i = 0, N - 1 do io.write(string.format(" %08X", got[i])) end io.write("\n") if bad == 0 then print("M6 AGGREGATE MAME: PASS") else for i = 0, N - 1 do if got[i] ~= expect[i] then print(string.format( "M6 aggregate: marker %d got %08X want %08X", i, got[i], expect[i])) end end print("M6 AGGREGATE MAME: FAIL") end end end, "aggregate-check")