This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LeDark Lua's profile picture

[VM] A project I'm working on...

Started by LeDark Lua, 18 January 2016 - 07:13 PM
LeDark Lua #1
Posted 18 January 2016 - 08:13 PM
I'm working on a VM…
Sneak peak:


Dunno if I should release it… Anyone interested?
If you want to know the current commands for it, comment :)/>
Commands

;Adds two numbers from the stack and pushes result on top of stack
ADD
SUB
MUL
DIV

LT ;Less Than pushes 1 [ true ] else 0 [ false ]
MT ;More Than pushes 1 [ true ] else 0 [ false ]
EQ ;Equals pushes 1 [ true ] else 0 [ false ]

JMP ;Gets a number from the stack and jumps to that position
GOTO <pos> ;jumps to that position

JMPT <pos> ;if the top of the stack has 1 in it, go to that position
JMPF <pos> ;if the top of the stack has 0 in it, go to that position

CONST <value> ;pushes a value to the top of stack

LOAD <name> ;loads a value with that name
STORE <name> ;stores a value with that name

PRINT ;Prints a value from the top of the stack

POP ;removes a value form the top of the stack

CALL <name> <number of arguments> ;goes to the position. gets the number of arguments from the top of the stack
LCALL <number of name def> <number of arguments> ;Calls a Lua function
RET ;pushes a value to the top of the stack and returns to the called position

HLT ;Exits the program
Suggest any commands? Comment :)/>
Edited on 22 January 2016 - 08:22 PM
LeDark Lua #2
Posted 19 January 2016 - 12:49 PM
Added current commands.
Luca_S #3
Posted 19 January 2016 - 07:54 PM
Is this something like LASM if yes, I would really like to try it out :D/>
LeDark Lua #4
Posted 19 January 2016 - 08:40 PM
Is this something like LASM if yes, I would really like to try it out :D/>
Yes. It is like it. If you really wan't to try it, PM me :)/>
Waitdev_ #5
Posted 21 January 2016 - 02:38 AM
sudo :P/>
LeDark Lua #6
Posted 22 January 2016 - 09:19 PM

CONST 5
STORE 0

FUNC "f"
  LOAD 0
  PRINT
  LOAD 0
  CONST 1
  SUB
  STORE 0
  CONST 1
  LOAD 0
  LT
  JMPT 25
  RET

  CALL "f"

CALL "f"
; LOAD 0
; PRINT
HLT

Hmmmm???
Edited on 22 January 2016 - 08:20 PM