function luaP.DecodeInst(z,S)local m=string.byte local r={}local Y=m(S,1)local O=Y%64 r.OP=O Y=m(S,2)*4+(Y-O)/64 local G=Y%256 r.A=G Y=m(S,3)*4+(Y-G)/256 local I=Y%512 r.C=I r.B=m(S,4)*2+(Y-I)/512 local R=z.OpMode[tonumber(string.sub(z.opmodes[O+1],7,7))]if R~="\105\065\066\067"then r.Bx=r.B*512+r.C end return r end
------------------------------------------------------------------------
-- decodes a 4-char little-endian string into an instruction struct
------------------------------------------------------------------------
function luaP:DecodeInst(x)
	local byte = string.byte
	local i = {}
	local I = byte(x, 1)
	local op = I % 64
	i.OP = op
	I = byte(x, 2) * 4 + (I - op) / 64 -- 2 bits of c0 left
	local a = I % 256
	i.A = a
	I = byte(x, 3) * 4 + (I - a) / 256 -- 2 bits of c1 left
	local c = I % 512
	i.C = c
	i.B = byte(x, 4) * 2 + (I - c) / 512 -- 1 bits of c2 left
	local opmode = self.OpMode[tonumber(string.sub(self.opmodes[op + 1], 7, 7))]
	if opmode ~= "iABC" then
		i.Bx = i.B * 512 + i.C
	end
	return i
end
