Skip to content

TheFausap/PythonApplication42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S42 - Stack based VM

It includes the standard operator of a generic stack based VM. It accept a one liner program, composed by

the stack is LIFO

  • INT or FLOAT : put the value into stack
  • ADD : to perform addition of the latest two values inserted
  • SUB : to perform subtraction
  • MUL : to perform multiplication
  • DIV : to perform division
  • DUP : to duplicate the latest value on the stack
  • POP : to remove the latest inserted value on the stack
  • < : to perform a comparison between the latest two values on the stack it put on the stack the boolean result.
  • [x,y] : it perform an IF using the boolean result from a comparison returning on the stack x if true, y if false.
  • {z} : put on the stack the program Z in order to be executed later, i.e.: {DUP,MUL}, with the command EXE.
  • . : print out on the screen the latest value in the stack

Example

5 4 7 4 ADD . SUB MUL . 10 < [20,30] . {DUP,MUL} EXE .

About

Stack based VM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages