From 272ef0fbde7516d094837605bfe3884385f474c1 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 28 Dec 2016 02:09:15 -0800 Subject: [PATCH] implement addressing modes for fpu load/stores --- TODO | 9 +++++++++ lips/Expander.lua | 2 ++ lips/overrides.lua | 11 +++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 7a8ffe1..90b40dc 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,16 @@ unify/optimize ascii/asciiz/byte/halfword/word into BIN directives also lex strings to binary strings, why not +more useful string escapes e.g. \x + lex expressions in Lexer instead of its own separate lexer +;pseudo-instr for offsets not within 0x8000 range? +addiu at, t0, 0x7FFF +sb t1, 0x62FE(at) +;versus +sb t1, r0+0xE2FD(t0) + directive aliases, are these right? DB = 'BYTE', DH = 'HALFWORD', @@ -15,6 +23,7 @@ implement push/pop/jpop as macros be able to point to specific args of push/pop using variables add file-reading directives (e.g. for automatic hook injection macros) allow generation of shared object files (zelda overlays specifically) +http://wiki.cloudmodding.com/oot/Overlays#Relocation_Entry_Format don't require colons for +/- labels (this shouldn't break anything right?) diff --git a/lips/Expander.lua b/lips/Expander.lua index 08e885f..95d9efe 100644 --- a/lips/Expander.lua +++ b/lips/Expander.lua @@ -31,6 +31,8 @@ function Expander:pop(kind) ret = self.s[self.i] elseif kind == 'CPU' then ret = self:register(data.registers) + elseif kind == 'FPU' then + ret = self:register(data.fpu_registers) elseif kind == 'DEREF' then ret = self:deref() elseif kind == 'CONST' then diff --git a/lips/overrides.lua b/lips/overrides.lua index b4b4f01..8758589 100644 --- a/lips/overrides.lua +++ b/lips/overrides.lua @@ -4,6 +4,13 @@ local unpack = rawget(_G, 'unpack') or table.unpack local path = string.gsub(..., "[^.]+$", "") local data = require(path.."data") +local fpu_tob = { + LDC1=true, + LWC1=true, + SDC1=true, + SWC1=true, +} + local function name_pop(name, character) if name:sub(#name) == character then return name:sub(1, #name - 1), character @@ -51,7 +58,7 @@ local overrides = {} local function tob_override(self, name) -- handle all the addressing modes for lw/sw-like instructions - local dest = self:pop('CPU') + local dest = fpu_tob[name] and self:pop('FPU') or self:pop('CPU') local offset, base if self:peek('DEREF') then offset = 0 @@ -94,7 +101,7 @@ local function tob_override(self, name) end for k, v in pairs(data.instructions) do - if v[2] == 'tob' then + if v[2] == 'tob' or v[2] == 'Tob' then overrides[k] = tob_override end end