Archived
1
0
Fork 0

[GeckoConverter] handle C0/E0 properly

This commit is contained in:
sup39 2022-04-25 18:48:04 +09:00
parent 8cd885a0d1
commit 76657315b3

View file

@ -115,8 +115,8 @@
"# utility functions\n",
"searchSymbol = lambda addr, lang: bsearch(symLsts[lang], addr, lambda sym: sym.addr)[1]\n",
"def convertAddr(addr, src, dst, verbose=False):\n",
" sym0 = searchSymbol(addr, dst)\n",
" sym = symMaps[src][sym0.name]\n",
" sym0 = searchSymbol(addr, src)\n",
" sym = symMaps[dst][sym0.name]\n",
" addrN = addr-sym0.addr+sym.addr\n",
" if verbose:\n",
" print('%08x: %d + %s'%(addrN, addr-sym0.addr, sym))\n",
@ -163,7 +163,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"8040a2a8: 0 + [8040a2a8] gpMarDirector (4)\n"
"804158dc: 0 + [804158dc] @2861 (6)\n"
]
}
],
@ -227,6 +227,7 @@
" @returns: converted code with type `(int, int)[]`\n",
" '''\n",
" insts = [x for p in code for x in p]\n",
" # lis + lwz/lhz/lbz/ori\n",
" for i in range(1, len(insts)):\n",
" if insts[i-1]>>16 &0xfc1f == 15<<10:\n",
" '''\n",
@ -260,6 +261,9 @@
" insts[i-1] = insts[i-1]&0xffff0000 | haN\n",
" insts[i] = insts[i]&0xffff0000 | loN\n",
" logger.info('%08x -> %08x %s'%(addr, addrN, s))\n",
" # lwz/lhz/lbz r13/r2\n",
" # TODO\n",
" # DONE\n",
" return tuple(\n",
" tuple(insts[i:i+2])\n",
" for i in range(0, len(insts), 2)\n",
@ -277,6 +281,12 @@
" ans = []\n",
" for code in gecko:\n",
" inst = code[0][0]\n",
" # handle instruction that do not involves RAM\n",
" ctype = inst>>24\n",
" if ctype in [0xC0, 0xE0]: # TODO\n",
" ans.append(code)\n",
" continue\n",
" # handle instruction that involves RAM\n",
" addr = 0x80000000|inst&0x1ffffff\n",
" sym0 = bsearch(srcSymLst, addr, lambda sym: sym.addr)[1]\n",
" instN = inst\n",
@ -291,7 +301,7 @@
" sym = dstSymMap[sym0.name]\n",
" if sym.size != sym0.size:\n",
" logger.error(\n",
" '%08X: function size different! (%d -> %d) %s',\n",
" '%08X: different function size! (%d -> %d) %s',\n",
" inst, sym0.size, sym.size, sym.name,\n",
" )\n",
" continue\n",