egg

Multi-architecture emulator.
Log | Files | Refs | README | LICENSE

CONTRIBUTING.md (2152B)


      1 [Ler esse documento em português](CONTRIBUINDO.md)
      2 
      3 # I found a bug!
      4 
      5 Please [fill an issue](https://github.com/gboncoffee/egg/issues) describing your
      6 bug if none is already opened.
      7 
      8 # Feature requests
      9 
     10 Please [fill an issue](https://github.com/gboncoffee/egg/issues) describing your
     11 feature request if none is already opened. Features can be anything from a new
     12 syscall, a new debugger command, or a new architeture backend. Please remind
     13 that the purpouse of this project is to be simple, so stuff like a `x86_64`
     14 backend will never happen.
     15 
     16 # I would like to write code for it
     17 
     18 Well, first thanks! The codebase is very simple and navigatable. Enjoy your
     19 time, and if you have any questions,
     20 [fill an issue](https://github.com/gboncoffee/egg/issues).
     21 
     22 To contribute with code, open a pull request!
     23 
     24 ## Adding backends
     25 
     26 Create a new Go package at the project directory. For example, let's add a
     27 backend for the fictional R2D2 instruction set architeture:
     28 
     29 ```shell
     30 $ cd egg
     31 $ mkdir r2d2
     32 $ cd r2d2
     33 $ touch r2d2.go
     34 $ touch r2d2_test.go
     35 ```
     36 
     37 We'll implement everything in `r2d2.go`:
     38 
     39 ```go
     40 // Package egg/r2d2 implements a R2D2 machine for the EGG emulator.
     41 package r2d2
     42 
     43 import (
     44 	"github.com/gboncoffee/egg/assembler"
     45 	"github.com/gboncoffee/egg/machine"
     46 )
     47 
     48 // The R2D2 struct implements the machine interface needed by the EGG emulator.
     49 type R2D2 struct {
     50 	registers [32]uint32
     51 	pc        uint32
     52 	mem       [math.MaxUint32 + 1]uint8
     53 }
     54 ```
     55 
     56 The required functions are in the interface `Machine` imported via the
     57 `egg/machine` package. They should be implemented as methods on pointers rather
     58 than on the struct itself.
     59 
     60 Most functions there are rather simple. The documentation can be found
     61 [at pkg.go.dev](https://pkg.go.dev/github.com/gboncoffee/egg).
     62 
     63 The `egg/assembler` package is also imported because it has the definitions
     64 required for the debugger support. The interface requires the implementation of
     65 the assembler function `Assemble(string) ([]uint8, []assembler.DebuggerToken,
     66 error)`. If it's second return value is `nil`, debugger support is
     67 disabled. Furthermore, this package helps with the boilerplate of creating a
     68 simple assembler.