egg

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

commit 7564600d2b3a24ac2b1299334571f34ec4eebaa8
parent 17827a258af16a0e93c51c9d46195ab15ff41f7c
Author: Gabriel G. de Brito (AKA 96) <gabrielgbrito@icloud.com>
Date:   Sat, 30 Dec 2023 00:29:37 -0300

Merge pull request #1 from gboncoffee/gboncoffee-repo-setup


Diffstat:
A.github/ISSUE_TEMPLATE/bug_report.md | 32++++++++++++++++++++++++++++++++
A.github/ISSUE_TEMPLATE/feature_request.md | 20++++++++++++++++++++
M.gitignore | 1+
MREADME-pt.md | 71++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
MREADME.md | 72+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 192 insertions(+), 4 deletions(-)

diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Version [e.g. 22] + - `egg --version` output + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ /egg +/egg-windows diff --git a/README-pt.md b/README-pt.md @@ -1,3 +1,5 @@ +[![Go](https://github.com/gboncoffee/egg/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/gboncoffee/egg/actions/workflows/go.yml) + [Read this document in English](README.md) # EGG, um emulador de processadores genérico @@ -5,4 +7,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 @@ -1,3 +1,5 @@ +[![Go](https://github.com/gboncoffee/egg/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/gboncoffee/egg/actions/workflows/go.yml) + [Ler esse documento em português](README-pt.md) # EGG, a generic processor emulator @@ -6,6 +8,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.