commit 95b0946ddca8c0d9a24447d426aaca1f36a6400b
parent aafa5fa1979a25539a3057f7b4c89fdb11137ccf
Author: Gabriel de Brito <me@gboncoffee.dev.br>
Date: Thu, 23 Jul 2026 11:25:14 -0300
Merge pull request #39 from gboncoffee/fix-pia-j
Fixed PIÁ J instructions encoding
Diffstat:
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/main.go b/main.go
@@ -19,7 +19,7 @@ import (
"github.com/gboncoffee/egg/sagui"
)
-const VERSION = "3.5.1"
+const VERSION = "3.5.2"
// Put new architetures here... (main.go:/switch architeture)
func listArchs() {
diff --git a/pia/pia.go b/pia/pia.go
@@ -687,7 +687,7 @@ func encodeB32(rd uint8, rs uint8, func_ uint8, imm uint32) uint32 {
// Format: imm[15:1] | imm[16] | imm[27:17] | opcode[3:0]
func encodeJ32(imm uint32, bit16 uint8, opcode uint8) uint32 {
immLow := (imm >> 1) & 0xFFFF
- immMid := (imm >> 17) & 0x7FF
+ immMid := (imm >> 17) & 0xFFF
return (immLow << 17) | (uint32(bit16) << 16) | (immMid << 4) | uint32(opcode)
}
@@ -1008,15 +1008,11 @@ func assembleJ32Instruction(mnemonic string, t assembler.ResolvedToken, addr uin
bit16 = 1
return encodeJ32(imm, bit16, 0xD), nil
case "lrj":
- offset := target - int32(addr)
- offset = offset >> 1
- imm := uint32(offset) & 0xFFFFFFF
+ imm := uint32(target - int32(addr))
bit16 = 0
return encodeJ32(imm, bit16, 0xE), nil
case "lrjl":
- offset := target - int32(addr)
- offset = offset >> 1
- imm := uint32(offset) & 0xFFFFFFF
+ imm := uint32(target - int32(addr))
bit16 = 1
return encodeJ32(imm, bit16, 0xE), nil
default: