From e25ee2013c10ac9c10f81d498a640994e7a8cb18 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 21 Apr 2016 04:23:47 -0700 Subject: [PATCH] fix some pseudo-branch instructions --- lips/overrides.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lips/overrides.lua b/lips/overrides.lua index d6adf32..55f231d 100644 --- a/lips/overrides.lua +++ b/lips/overrides.lua @@ -224,15 +224,15 @@ overrides.BNEIL = overrides.BEQI function overrides.BLTI(self, name) local branch = branch_basics[name] - local rs = self:pop('CPU') + local reg = self:pop('CPU') local immediate = self:pop('CONST') local offset = self:pop('REL'):set('signed') - if rs == 'AT' then + if reg == 'AT' then self:error('register cannot be AT in this pseudo-instruction') end - self:push_new('SLTI', 'AT', reg) + self:push_new('SLTI', 'AT', reg, immediate) self:push_new(branch, 'R0', 'AT', offset) end @@ -257,11 +257,12 @@ function overrides.BLEI(self, name) if name == 'BLEI' then beq_offset = offset else + -- FIXME: this probably isn't correct for branch-likely instructions beq_offset = 2 -- branch to delay slot of the next branch end self:push_new('BEQ', reg, 'R0', beq_offset) - self:push_new('SLT', 'AT', reg) + self:push_new('SLT', 'AT', reg, immediate) self:push_new(branch, 'AT', 'R0', offset) end