egg

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

commit d56f69e48a25f1573eb7121c4bd7adee96e365b3
parent a7b5c5929f107ec6b8aafa93b4b8eb2be8384375
Author: Gabriel G. de Brito <gabrielgbrito@icloud.com>
Date:   Fri, 29 Dec 2023 23:42:28 -0300

Updated READMEs with overall documentation

Diffstat:
MREADME-pt.md | 69++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
MREADME.md | 70+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 135 insertions(+), 4 deletions(-)

diff --git a/README-pt.md b/README-pt.md @@ -5,4 +5,71 @@ EGG (Emulador Genérico do Gabriel) é um emulador modular de arquiteturas de processador, criado para fins educacionais. -O emulador está num estado satisfatório no momento. Eu só preciso documentar tudo, configurar o GitHub Actions e toda a burocracia (issues, pr, etc) para fazer uma release. +O pacote `egg` provém uma interface para interagir com máquinas, assim provendo +suporte a diferentes backends provendo arquiteturas. No momento, há somente o +pacote `egg/riscv` de backend, implementando uma máquina RISC-V IM de 32 bits. +Um backend de MIPS é planejado para o futuro. + +O pacote `egg/assembler` provém uma pequena biblioteca para criação de +assemblers e o suporte ao debugger do EGG. + +## Instalação + +Baixe o binário estático para o seu sistema na página de +[releases](https://github.com/gboncoffee/egg/releases), ou, caso tenha o +compilador de Go instalado, baixe e compile o projeto. + +Nota: o binário para Windows não foi testado. Não tenho acesso a nenhuma máquina +Windows atualmente. + +## Uso + +Rode o emulador com um arquivo de Assembly para montá-lo e iniciar uma máquina +rodando o programa. O backend utilizado por padrão é uma máquina de RISC-V 32 +bits. Use a opção `-a` ou `-arch` para mudar a arquitetura (atualmente há +somente a opção RISC-V. Um backend de MIPS é planejado para o futuro). A opção +`-h` mostra todas as opções de linha de comando e a opção `-l` mostra todas as +arquiteturas suportadas. + +A sintaxe de Assembly varia com a arquitetura, porém, como o projeto provém uma +biblioteca para tal, os backends podem usar uma sintaxe bem semelhante (RISC-V +usa). Exemplo: + +```asm +; Ponto e vírgula define comentários até o fim da linha. + +; Labels são definidos com dois pontos. +label: + ; Os argumentos começam sempre pelo destino. + addi t0, zero, 2 + + ; Também é possível colocar instruções logo após os labels. +label2: add t0, t0, t0 + + ; Não há parênteses como no RARS e stores usam imediatos normais. + sb t0, ra, 3 + + ; Imediatos hexadecimais, octais e binários também são suportados. + addi t1, zero, 0xff + addi t1, zero, 0b010110 + addi t1, zero, 0o644 + addi t1, zero, 0755 ; Um zero à esquerda também define um octal. + +; # define um literal até o final da linha. +; Literais são inseridos no binário (assim como 'db' em outros assemblers). +; Se uma % é seguida de dois digitos hexadecimais, o valor hexadecimal é +; inserido. Use %% para inserir um % (ou %25). +msg: +#Hello, World!%0a +``` + +Cada diretório de cada arquitetura possui programas Assembly de teste que podem +ser usados de exemplo. + +## Debugger + +A interface do debugger é semelhante à do `gdb` porém bem enxuta. Use a opção +`-d` para entrar no debugger assim que iniciar o emulador. Não há comando `run`, +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. diff --git a/README.md b/README.md @@ -6,6 +6,70 @@ EGG stands for "Emulador Genérico do Gabriel" ("Gabriel's Generic Emulator", in portuguese). It's a modular emulator for processor architetures, made for educational purpouses. -Currently, the emulator is in a state I like, I just have to document -everything, setup the GitHub Actions and all the burocracy (issues, pr, etc) so -I make a release. +The `egg` package itself provides only an interface for interacting with +machines, thus supporting different architeture backends. Currently, the only +backend implemented is `egg/riscv`, which implements a RISC-V IM 32 bits +machine. A MIPS backend is coming soon. + +`egg/assembler` also provides a small library for creating assemblers, and the +support for EGG's debugger. + +## Installation + +Simply grab the static binary for your OS at the +[releases](https://github.com/gboncoffee/egg/releases) page. Or, if you have the +Go compiler, build the project from source. + +Note: the Windows binary is untested, as I don't have access to any Windows +machine nowadays. + +## Quickstart + +Running the emulator with an Assembly file will assemble it and start a machine +to run it on. By default, the machine is a RISC-V IM 32 bits. Use the flag `-a` +or `-arch` to change the architeture (currently only RISC-V is supported, a MIPS +backend is coming soon). Run `egg -h` to see all command line options and `egg +-l` to see all supported architetures. + +The Assembly syntax is architeture-dependent. Though, a library is provided for +creating assembler, so backends may use the same overall syntax (RISC-V uses +it). + +An example follows: + +```asm +; Semicolon makes a comment til the end of line. + +; A label is defined with :. +label: + ; Instruction arguments starts with destination. + addi t0, zero, 2 + + ; You may also put instructions after the labels. +label2: add t0, t0, t0 + + ; There's no parenthesis as in RARS, store uses common immediates. + sb t0, ra, 3 + + ; Hex, octal and binary immediates are supported. + addi t1, zero, 0xff + addi t1, zero, 0b010110 + addi t1, zero, 0o644 + addi t1, zero, 0755 ; A leading 0 also defines an octal. + +; A # defines a literal til the end of the line. +; Literals are inserted unchanged to the binary (as 'db' in other assemblers). +; If a % is followed by two hex digits, the hex value is inserted instead. Use +; %% to escape it. +msg: +#Hello, World!%0a +``` + +Each architeture folder has test Assembly files you may use as examples. + +## Debugger + +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.