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. 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 (both RISC-V and MIPS uses it).
An example follows:
; Semicolon makes a comment til the end of line.
; A label is defined with :.
label:
; Instruction arguments starts with destination.
, zero, 2
addi t0
; You may also put instructions after the labels.
label2: add t0, t0, t0
; There's no parenthesis as in RARS, store uses common immediates.
, ra, 3
sb t0
; Hex, octal and binary immediates are supported.
, zero, 0xff
addi t1, zero, 0b010110
addi t1, zero, 0o644
addi t1, zero, 0755 ; A leading 0 also defines an octal.
addi t1
; 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:
, World!%0a
#Hello
; Some directives are supported. "bitsxx" ones creates literal numbers in the
; code, with the bit length specified:
0xca 0xfe 0xba 0xbe 0xde 0xad 0xbe 0xef
.bits8 0xcafe 0xbabe 0xdead 0xbeef
.bits16 0xcafebabe 0xdeadbeef
.bits32 0xcafebabedeadbeef
.bits64 ; The "space" directive adds some bytes of spacing in the code:
16
.space ; The "include" directive "copy-pastes" another file in the code:
include other-asm.asm .
Each architeture folder has test Assembly files you may use as examples.
Standard calls handled by the emulator are as follows. Refer to the architeture documentation on how to perform them:
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.
The RISC-V implementation for EGG uses the standard Assembly syntax. It implements the registers and instructions from the base integer set and the multiplication extension described in this document.
Environment call numbers are placed in the a7
register,
and arguments are placed in a0
and a1
.
An ebreak
instruction will perform a BREAK call.
Example program (writes “Hello, World!”, breaks a line and exits):
, zero, 3
addi a7, zero, msg
addi a0, zero, 14
addi a1
ecall
ebreak
msg:
, World!%0a #Hello
The assembled program is loaded at the address 0
on the
machine startup, and the pc
register is set to
0
. The stack pointer register is not initialized: the
program should initialize it if it wants to use the stack.
The MIPS32 implementation for EGG uses the standard Assembly syntax.
Environment call numbers are placed in the v0
register,
and arguments are placed in a0
and a1
.
An break
instruction will perform a BREAK call.
The assembled program is loaded at the address 0
on the
machine startup, and the pc
register is set to
0
.
Sagui is a fantasy 8 bit RISC architecture created by Dr. Marco
Zanata, professor at Universidade Federal do Paraná. The implementation
in EGG has one extension: a instruction movr r0, r0
is
actually interpreted as a BREAK system call.
It uses the standard Assembly syntax.
O REDUX-V é uma versão 8-bits do RISC-V.
Ele usa a sintaxe Assembly padrão do EGG.