Run a program on a simulated CPU and look inside. simu86 is a command line tool and its engine simu: step one instruction, read the registers and the memory, stop at an address, see in words what a program did, and boot a program on an empty machine with no operating system, which is the start of writing your own OS. Written in Jex. It runs on an ARM64 Linux system (a phone with Termux or exshell works).
| CPU | now | next |
|---|---|---|
| ARM64 | Linux programs (static) and the bare virt board: integer, scalar floating point, exceptions, timer, MMU, serial port, disk, screen |
more of the vector instructions, a faster engine |
| x86-64 | Linux programs (static): integer, SSE and SSE2 (floating point and vectors), the usual system calls: simu86 run, stats, trace, info (the core came from the tool jx86) |
a bare machine for an operating system, AVX, threads |
simu86 run prog-x86 # a static x86-64 Linux program (the file tells the CPU): run it
simu86 stats prog-x86 # run it and say what kinds of instructions it did, and how fast
simu86 trace prog-x86 20 # the address and the bytes of the first 20 instructions
simu86 info FILE # what a program file is, and whether simu86 can run it
simu86 cpus # what each CPU can do
simu86 demo # a small machine is built, run and explained
simu86 examples/hello.jex # build and run a program for the empty machine
simu86 stats my.jex # run it and say what kinds of instructions it did
simu86 # the prompt: type / to see the commands
simu86> /load examples/hello.jex
loaded examples/hello.jex: a bare ARM64 program on the empty machine (RAM 64 MB), starts at 0x400000b0
simu86> /step 3
0x400000b0 140000e6 jump
...
simu86> /regs
simu86> /mem 0x40100000 64
simu86> /break 0x40000448
simu86> /run
| command | what it does |
|---|---|
/dir [FOLDER], /cd FOLDER, /pwd |
look for files (folders end with /, * marks a .jex); ~/ :/ f:/ are home, 0:/ the phone storage |
/boot FILE |
load it on the empty machine (a raw kernel linked at a low address; a source with #target or #!library is recognised by itself) |
/load FILE [ARGS] |
a .jex source (built with jexcmp) or a static ARM64 program |
/run |
run to the end, to a break point or to the limit |
/step [N] |
one instruction (or N): address, instruction word, its kind, the registers that changed |
/regs |
x0..x30, sp, pc, the flags (and the exception level on the empty machine) |
/mem ADDRESS [BYTES] |
memory as bytes and letters |
/break ADDRESS, /break off |
stop there; forget the stops |
/stats |
run and report the share of every kind of instruction |
/reset |
start the program again |
/info |
what is loaded and where it is |
/demo |
a small empty-machine program |
/config, /set NAME VALUE, /defaults |
the settings |
/help, /exit |
The same words work as commands: simu86 [run] PROGRAM [ARGS], simu86 boot KERNEL, simu86 stats PROGRAM, simu86 demo, simu86 config, simu86 set NAME VALUE, simu86 help.
The exit code is the one of the program (139: it used an address with no memory; 132: an instruction that is not simulated yet; 124: the limit).
Kept in ~/.config/simu86/config (a text file).
| name | values (the first is the usual one) | meaning |
|---|---|---|
cpu |
auto, arm64, x86-64 | the CPU (auto: the file tells) |
ram |
64 | MB of the empty machine, 1..1024 |
limit |
0 | stop after so many instructions (0: no limit) |
regs |
changed, all | what /step shows |
base |
hex, dec | how numbers are shown |
color |
on, off | |
report |
off, on | the report after every run |
compiler |
jexcmp | what builds a .jex file |
A program with a #target virt block has no operating system under it: it starts at entry, its memory is the ram you name, the byte register
console is the serial port and writing to exit stops the machine. See examples/ and the guide
BARE.md of Jex (vectors, interrupts, the timer, the MMU).
sh build.sh # _out/simu86 (needs jexcmp; JCMP=path chooses it)
sh test.sh
In exshell: ex install simu86. Anywhere on Linux ARM64 (a phone with Termux too), from the releases of this repository:
curl -fsSL https://raw.githubusercontent.com/C2k-studio/simu86/main/install.sh | sh
wget -qO- or jurl -fsSL work in the place of curl -fsSL. Options after sh -s --: --dir FOLDER, --version 0.2.2.
The program is also on the releases page with its SHA-256.
To build a .jex source you need the compiler Jexcmp (jexcmp).
simu86 demoand read the program and the report.simu86, then/load examples/uart.jex,/step 5,/regs.- Change the text in
examples/uart.jex,/loadit again and/run.
| file or folder | what is in it |
|---|---|
simu86.jex |
the command line: commands, settings, building a source, reports |
s86_line.j |
the line editor of the prompt (from the tool ascode) |
simu/ |
the engine: the CPU, the system calls, the machine and its devices. It has its own interface, documents and tests and uses nothing outside its folder: copy the folder into your project and #import "simu" |
How to help: CONTRIBUTING.md. The plan: simu/docs/roadmap.md. License: Mozilla Public License 2.0.