commit c1951440c7110cfa3ca16eeac9ee3018635130e4
parent 82b43f33d3d93701e8955ba277bbec2e46677b71
Author: Gabriel G. de Brito <gabrielgbrito@icloud.com>
Date: Sat, 24 Aug 2024 11:03:22 -0300
find . -name '*.go' -exec gofmt -w {} \;
Diffstat:
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/assembler/assembler.go b/assembler/assembler.go
@@ -141,7 +141,7 @@ func ResolveTokens(tokens []Token, process func(*Instruction) error, translateAr
resolvedTokens = append(resolvedTokens, ResolvedToken{
Line: instruction.Line,
File: instruction.File,
- Type: TOKEN_INSTRUCTION,
+ Type: TOKEN_INSTRUCTION,
Value: []byte(instruction.Mnemonic),
Address: address,
Reserved: instruction.Reserved,
@@ -164,12 +164,12 @@ func ResolveTokens(tokens []Token, process func(*Instruction) error, translateAr
}
debuggerTokens = append(debuggerTokens, DebuggerToken{
- Line: token.Line,
- File: token.File,
+ Line: token.Line,
+ File: token.File,
Instruction: string(token.Value),
- Args: args,
- Address: token.Address,
- Label: reverseLabels[token.Address],
+ Args: args,
+ Address: token.Address,
+ Label: reverseLabels[token.Address],
})
for _, arg := range args {
diff --git a/riscv/riscv_test.go b/riscv/riscv_test.go
@@ -55,7 +55,7 @@ func TestMem(t *testing.T) {
t.Fatalf("Error getting addr %v: %v - %v", math.MaxUint32, err, v)
}
- err = m.SetMemory(math.MaxUint32 + 1, 39)
+ err = m.SetMemory(math.MaxUint32+1, 39)
if err == nil {
t.Fatalf("Did not failed in trying to set more than %v", math.MaxUint32)
}
@@ -80,22 +80,22 @@ func TestChunkedMem(t *testing.T) {
t.Fatalf("Error getting addr 0: %v - %v", err, v)
}
- err = m.SetMemoryChunk(math.MaxUint32 - 2, arr)
+ err = m.SetMemoryChunk(math.MaxUint32-2, arr)
if err != nil {
t.Fatalf("Error setting addr %v: %v", math.MaxUint32, err)
}
- v, err = m.GetMemoryChunk(math.MaxUint32 - 2, 3)
+ v, err = m.GetMemoryChunk(math.MaxUint32-2, 3)
if err != nil || !reflect.DeepEqual(v, arr) {
t.Fatalf("Error getting addr %v: %v - %v", math.MaxUint32, err, v)
}
- err = m.SetMemoryChunk(math.MaxUint32 - 1, arr)
+ err = m.SetMemoryChunk(math.MaxUint32-1, arr)
if err == nil {
t.Fatalf("Did not failed in trying to set more than %v", math.MaxUint32)
}
- v, err = m.GetMemoryChunk(math.MaxUint32 - 1, 3)
+ v, err = m.GetMemoryChunk(math.MaxUint32-1, 3)
if err == nil {
t.Fatalf("Did not failed in trying to set more than %v: %v", math.MaxUint32, v)
}
@@ -179,17 +179,17 @@ func TestAssembler(t *testing.T) {
}
for i := 0; i < len(correctCode); i++ {
- asmi := uint32(code[i * 4])
- asmi = asmi | uint32(code[i * 4 + 1]) << 8
- asmi = asmi | uint32(code[i * 4 + 2]) << 16
- asmi = asmi | uint32(code[i * 4 + 3]) << 24
+ asmi := uint32(code[i*4])
+ asmi = asmi | uint32(code[i*4+1])<<8
+ asmi = asmi | uint32(code[i*4+2])<<16
+ asmi = asmi | uint32(code[i*4+3])<<24
if asmi != correctCode[i] {
t.Logf("Byte 0: %x Byte 1: %x Byte 2: %x Byte 3: %x",
- code[i * 4],
- code[i * 4 + 1],
- code[i * 4 + 2],
- code[i * 4 + 3])
- t.Fatalf("Incorrect instruction: %x (expected %x) at address %x", asmi, correctCode[i], i * 4)
+ code[i*4],
+ code[i*4+1],
+ code[i*4+2],
+ code[i*4+3])
+ t.Fatalf("Incorrect instruction: %x (expected %x) at address %x", asmi, correctCode[i], i*4)
}
}
}
@@ -210,7 +210,7 @@ func (m *RiscV) assertRegister(t *testing.T, v string, r uint64, s string) {
func (m *RiscV) ensureBranch(t *testing.T, i string) {
pc := m.pc
m.NextInstruction()
- if pc == m.pc - 4 {
+ if pc == m.pc-4 {
t.Fatalf("%s didn't branch correctly: %d", i, m.pc)
}
}
@@ -218,7 +218,7 @@ func (m *RiscV) ensureBranch(t *testing.T, i string) {
func (m *RiscV) ensureDontBranch(t *testing.T, i string) {
pc := m.pc
m.NextInstruction()
- if pc != m.pc - 4 {
+ if pc != m.pc-4 {
t.Fatalf("%s didn't pass correctly: %x", i, m.pc)
}
}
@@ -348,11 +348,11 @@ func TestInstructions(t *testing.T) {
//
ret := m.pc
m.NextInstruction()
- if m.pc == ret + 4 {
+ if m.pc == ret+4 {
t.Fatalf("jal does not jump correctly")
}
m.NextInstruction()
- if m.pc != ret + 4 {
+ if m.pc != ret+4 {
t.Fatalf("jalr does not return correctly")
}
@@ -410,7 +410,7 @@ func TestInstructions(t *testing.T) {
m.assertRegister(t, "t0", 0xaaaaa000, "lui t0, 0xaaaaa")
pc := m.pc
m.NextInstruction()
- m.assertRegister(t, "t0", uint64(0xaaaaa000 + pc), "auipc t0, 0xaaaaa")
+ m.assertRegister(t, "t0", uint64(0xaaaaa000+pc), "auipc t0, 0xaaaaa")
//
// Multiplication extension.