egg

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 786d886fe2ab33c13ffdc310a7d6ffadabaf256d
parent 4b4b429a88d9a3a8e183a5ba4573e67fadc20ba9
Author: Gabriel de Brito <gabrielgbrito@icloud.com>
Date:   Mon,  2 Jun 2025 00:22:40 -0300

Merge pull request #34 from gboncoffee/version.4

Version 3.4.0
Diffstat:
MREADME-pt.md | 11+++++++++++
MREADME.md | 11+++++++++++
Mmain.go | 4++--
Mmips/mips_test.go | 24++++++++++++------------
MreduxK/reduxK.go | 32++++++++++++++++----------------
MreduxK/reduxK_test.go | 8++++----
6 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/README-pt.md b/README-pt.md @@ -115,3 +115,14 @@ A interface do debugger é semelhante à do `gdb` porém bem enxuta. Use a opç como no `gdb`, pois não há necessidade de iniciar um processo do sistema. Os comandos `next` e `continue` podem ser utilizados para iniciar o programa normalmente. Use o comando `help` para ver todos os comandos disponíveis. + +## Apoiando o projeto + +O EGG é utilizado ativamente para educação em ciência da computação e é mantido +por mim e outros voluntários. Você pode apoiar nosso trabalho juntando-se a nós +escrevendo código, ajudando com a documentação e procurando bugs. + +Caso queira nos apoiar financeiramente, por favor considere +[doar para a Ucrânia](https://u24.gov.ua/) ao invés. + +:brazil: :ukraine: diff --git a/README.md b/README.md @@ -113,3 +113,14 @@ The debugger interface is kinda similar to `gdb`, though much smaller. Use the `-d` flag to enter debugger uppon startup. There's no need of `run` command, as there's no process. The `next` or the `continue` commands may be used to start running the program normally. Use `help` to see all available commands. + +## Supporting the project + +EGG is actively used for computer science education and maintained by myself and +other volunteers. You can support our work by joining us writing code, helping +with the docs and checking for bugs. + +If you want to support us financially, please consider instead +[donating to Ukraine](https://u24.gov.ua/). + +:brazil: :ukraine: diff --git a/main.go b/main.go @@ -11,13 +11,13 @@ import ( "github.com/gboncoffee/egg/assembler" "github.com/gboncoffee/egg/machine" "github.com/gboncoffee/egg/mips" + "github.com/gboncoffee/egg/reduxK" "github.com/gboncoffee/egg/reduxv" "github.com/gboncoffee/egg/riscv" "github.com/gboncoffee/egg/sagui" - "github.com/gboncoffee/egg/reduxK" ) -const VERSION = "3.3.3" +const VERSION = "3.4.0" // Put new architetures here... (main.go:/switch architeture) func listArchs() { diff --git a/mips/mips_test.go b/mips/mips_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/gboncoffee/egg/machine" "github.com/gboncoffee/egg/assembler" + "github.com/gboncoffee/egg/machine" ) func TestIsa(t *testing.T) { @@ -501,7 +501,7 @@ func TestIsa(t *testing.T) { // lb t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0xff, 2, 3, 4}) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() v, _ = m.GetRegister(0 + 8) if v != 0xff_ff_ff_ff { @@ -510,7 +510,7 @@ func TestIsa(t *testing.T) { // lbu t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0xff, 2, 3, 4}) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() v, _ = m.GetRegister(0 + 8) if v != 0xff { @@ -519,7 +519,7 @@ func TestIsa(t *testing.T) { // lh t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0xff, 0xff, 3, 4}) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() v, _ = m.GetRegister(0 + 8) if v != 0xff_ff_ff_ff { @@ -528,7 +528,7 @@ func TestIsa(t *testing.T) { // lhu t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0xff, 0xff, 3, 4}) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() v, _ = m.GetRegister(0 + 8) if v != 0xff_ff { @@ -537,7 +537,7 @@ func TestIsa(t *testing.T) { // lw t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{1, 2, 3, 4}) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() v, _ = m.GetRegister(0 + 8) if v != 0x04_03_02_01 { @@ -546,8 +546,8 @@ func TestIsa(t *testing.T) { // sb t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0, 0, 0, 0}) - m.SetRegister(0 + 8, 0xdeadbeef) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(0+8, 0xdeadbeef) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() slice, _ := m.GetMemoryChunk(0xcafebabe, 4) if !reflect.DeepEqual(slice, []uint8{0xef, 0, 0, 0}) { @@ -556,8 +556,8 @@ func TestIsa(t *testing.T) { // sh t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0, 0, 0, 0}) - m.SetRegister(0 + 8, 0xdeadbeef) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(0+8, 0xdeadbeef) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() slice, _ = m.GetMemoryChunk(0xcafebabe, 4) if !reflect.DeepEqual(slice, []uint8{0xef, 0xbe, 0, 0}) { @@ -566,8 +566,8 @@ func TestIsa(t *testing.T) { // sw t0, t1, 0 m.SetMemoryChunk(0xcafebabe, []uint8{0, 0, 0, 0}) - m.SetRegister(0 + 8, 0xdeadbeef) - m.SetRegister(1 + 8, 0xcafebabe) + m.SetRegister(0+8, 0xdeadbeef) + m.SetRegister(1+8, 0xcafebabe) m.NextInstruction() slice, _ = m.GetMemoryChunk(0xcafebabe, 4) if !reflect.DeepEqual(slice, []uint8{0xef, 0xbe, 0xad, 0xde}) { diff --git a/reduxK/reduxK.go b/reduxK/reduxK.go @@ -163,7 +163,7 @@ func (m *ReduxK) NextInstruction() (*machine.Call, error) { r1v, _ := m.GetRegister(1) r2v, _ := m.GetRegister(2) r3v, _ := m.GetRegister(3) - + m.SetMemory(r0v, uint8(r2v)) m.SetRegister(uint64(2), uint64(uint8(int8(r2v)+int8(r3v)))) m.SetRegister(uint64(0), uint64(uint8(int8(r0v)+int8(r1v)))) @@ -190,19 +190,19 @@ func (m *ReduxK) NextInstruction() (*machine.Call, error) { for x := 0; x < 4; x++ { regv, _ := m.GetRegister(uint64(x)) - m.SetRegister(uint64(x), uint64(uint8(int8(regv) + int8(1)))) + m.SetRegister(uint64(x), uint64(uint8(int8(regv)+int8(1)))) } } case 0x7: - if (ra == 0) { + if ra == 0 { for x := 0; x < 4; x++ { regv, _ := m.GetRegister(uint64(x)) - m.SetRegister(uint64(x), uint64(uint8(int8(regv) + int8(uimm)))) + m.SetRegister(uint64(x), uint64(uint8(int8(regv)+int8(uimm)))) } - break + break } - m.SetRegister(uint64(ra), uint64(uint8(int8(rav) + int8(uimm)))) + m.SetRegister(uint64(ra), uint64(uint8(int8(rav)+int8(uimm)))) case 0x8: if rbv == 0 { m.SetRegister(uint64(ra), 1) @@ -212,7 +212,7 @@ func (m *ReduxK) NextInstruction() (*machine.Call, error) { case 0x9: m.SetRegister(uint64(ra), rav&rbv) case 0xa: - if (rb == 0 && ra == 0) { + if rb == 0 && ra == 0 { m.pc++ return &machine.Call{ Number: machine.SYS_BREAK, @@ -220,17 +220,17 @@ func (m *ReduxK) NextInstruction() (*machine.Call, error) { Arg2: 0, }, nil } - + m.SetRegister(uint64(ra), rav|rbv) case 0xb: - if (rb == 0 && ra == 0) { - m.pc++ - r1v, _ := m.GetRegister(1) - r2v, _ := m.GetRegister(2) - return &machine.Call{ - Number: r0v, - Arg1: r1v, - Arg2: r2v, + if rb == 0 && ra == 0 { + m.pc++ + r1v, _ := m.GetRegister(1) + r2v, _ := m.GetRegister(2) + return &machine.Call{ + Number: r0v, + Arg1: r1v, + Arg2: r2v, }, nil } diff --git a/reduxK/reduxK_test.go b/reduxK/reduxK_test.go @@ -158,7 +158,7 @@ func TestReduxK(t *testing.T) { mem, _ := m.GetMemory(uint64(x)) if mem != uint8(x) { t.Fatalf("loadv failed") - } + } } m.NextInstruction() @@ -167,9 +167,9 @@ func TestReduxK(t *testing.T) { for x := 4; x < 7; x++ { m.NextInstruction() mem, _ := m.GetMemory(uint64(x)) - if mem != uint8(x + 1) { + if mem != uint8(x+1) { t.Fatalf("loadv failed") - } + } } m.NextInstruction() @@ -189,7 +189,7 @@ func TestReduxK(t *testing.T) { mem, _ = m.GetMemory(0x08) if mem != 8 { t.Fatalf("loadv failed") - } + } mem, _ = m.GetMemory(0x09) if mem != 10 { t.Fatalf("loadv failed")