remedyvm

A toy RISC virtual machine inspired by Bell Lab's `dis' and Tsoding's `bm'
git clone git://git.ethandl.dev/remedyvm
Log | Files | Refs

commit d1c4af22120775e40f06afe5cb81435adc02eb6b
parent 806908fbf1edea3f1632e78a03b0b0d47b1ec07e
Author: Ethan Long <Ethan.Long@anu.edu.au>
Date:   Thu, 15 Jun 2023 00:08:52 +1000

Welp... Arrows in troff files don't work.

Diffstat:
Mdoc/specs.ms | 20++++++++++----------
Mdoc/specs.pdf | 0
Mimplementations/C/nobuild.c | 3++-
Dimplementations/C/remedyVM.c | 6------
4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/doc/specs.ms b/doc/specs.ms @@ -93,7 +93,7 @@ The instruction copies/moves the value stored in one temporary to another temporary. .SH 4 Usage -.AL "move <CND> <DST> <SRC>" "move <CND> y x" "y \[<-] <CND> ? x : y" +.AL "move <CND> <DST> <SRC>" "move <CND> y x" "y <- <CND> ? x : y" .NH 3 .CW swap @@ -103,7 +103,7 @@ The instruction swaps the value stored in one temporary with the value in another temporary. .SH 4 Usage -.AL "swap <CND> <TEMP1> <TEMP2>" "swap <CND> x y" "if CND { x \[<>] y }" +.AL "swap <CND> <TEMP1> <TEMP2>" "swap <CND> x y" "if CND { x <-> y }" .NH 3 .CW push @@ -113,7 +113,7 @@ The instruction pushes the specified temporary onto the stack. .SH 4 Usage -.AL "push <CND> <SRC>" "push <CND> x" "if CND { sp \[<-] sp + size(x), stack \[<-] x : stack }" +.AL "push <CND> <SRC>" "push <CND> x" "if CND { sp <- sp + size(x), stack <- x : stack }" .NH 3 .CW pop @@ -123,7 +123,7 @@ The instruction pops from the top of the stack into the specified temporary. .SH 4 Usage -.AL "pop <CND> <DEST>" "pop <CND> x" "if CND { sp \[<-] sp - size(x), (x, stack) \[<-] (x, xs) in stack(x:xs) }" +.AL "pop <CND> <DEST>" "pop <CND> x" "if CND { sp <- sp - size(x), (x, stack) <- (x, xs) in stack(x:xs) }" .NH 3 .CW load @@ -136,7 +136,7 @@ into the specified .CW <TEMP> . .SH 4 Usage -.AL "load <CND> <TEMP> <MEMADDR>" "store <CND> y x" "CND ? y \[<-] Mem(x)" +.AL "load <CND> <TEMP> <MEMADDR>" "store <CND> y x" "CND ? y <- Mem(x)" .NH 3 .CW store @@ -149,7 +149,7 @@ into the memory pointed to by .CW <MEMADDR> . .SH 4 Usage -.AL "store <CND> <TEMP> <MEMADDR>" "store <CND> y x" "CND ? Mem(x) \[<-] y" +.AL "store <CND> <TEMP> <MEMADDR>" "store <CND> y x" "CND ? Mem(x) <- y" .B NOTE: the order of the store instruction is reversed to the regular load & other typical instructions. @@ -165,7 +165,7 @@ The instruction adds two temporaries and puts the result in a third. .SH 4 Usage -.AL "add <CND> <DEST> <TEMP> <TEMP>" "add <CND> z x y" "z \[<-] CND ? x + y" +.AL "add <CND> <DEST> <TEMP> <TEMP>" "add <CND> z x y" "z <- CND ? x + y" .NH 3 .CW sub @@ -180,7 +180,7 @@ and puts the result in .CW <DEST> . .SH 4 Usage -.AL "sub <CND> <DEST> <TEMP1> <TEMP2>" "sub <CND> z x y" "z \[<-] CND ? x \[-] y" +.AL "sub <CND> <DEST> <TEMP1> <TEMP2>" "sub <CND> z x y" "z <- CND ? x - y" .NH 3 .CW mul @@ -191,7 +191,7 @@ instruction multiplies two temporaries together, putting the result in .CW <DEST> . .SH 4 Usage -.AL "mul <CND> <DEST> <TEMP> <TEMP>" "mul <CND> z x y" "z \[<-] CND ? x \[mu] y" +.AL "mul <CND> <DEST> <TEMP> <TEMP>" "mul <CND> z x y" "z <- CND ? x * y" .NH 3 .CW div @@ -206,7 +206,7 @@ and puts the result in .CW <DEST> . .SH 4 Usage -.AL "div <CND> <DEST> <TEMP1> <TEMP2>" "div <CND> z x y" "z \[<-] (CND && y \[!=] 0) ? x \[di] y" +.AL "div <CND> <DEST> <TEMP1> <TEMP2>" "div <CND> z x y" "z <- (CND && y != 0) ? x / y" .B NOTE: if .CW <TEMP2> diff --git a/doc/specs.pdf b/doc/specs.pdf Binary files differ. diff --git a/implementations/C/nobuild.c b/implementations/C/nobuild.c @@ -4,7 +4,8 @@ #define CFLAGS "-Wall", "-Wextra", "-std=c99", "-pedantic" void build_vm() { - CMD("cc", CFLAGS, "-o", "remedyVM", "remedyVM.c"); + + CMD("cc", CFLAGS, "-o", "bin/interp", "src/interp.c"); } int main() { diff --git a/implementations/C/remedyVM.c b/implementations/C/remedyVM.c @@ -1,6 +0,0 @@ -#include <stdio.h> - -int main() { - printf("Hello, world"); - return 0; -}