Deven is a simple programming Language created for my friend Deven.
p: Pushes the follwoing integer onto the Stacki: Reads a char from the console and pushes its ascii value onto the Stack. This only reads the first char. All follwoing chars are ignored.o: prints the top element of the Stack as an ascii charP: Pops the top element from the stacka: Adds the top two Elements of the stack together and stores the result on the stacks: Subtracts the top two Elements of the stack together and stores the result on the stackj: Jumps relatively to the current position by the amount stored on top of the stack if the second top value on the stack is 1d: Duplicates the i-th element from the stack where i is the integer following the commandD: Deletes the i-th element from the stack where i is the integer following the commande: Checks if the top two elements are equal. If yes it pushes 1 onto the stack otherwise 0.S: Checks if the second element from top is smaller than the top element on the stack. If yes it pushes 1 onto the stack otherwise 0.
When starting a new subroutine, the stack should always have the return address relative to the routine end followed by the arguments on top of it.
There are five examples available:
python3 deven.py examples/helloworld.devenPrints "Hello World" to the consolepython3 deven.py examples/add.devenAsks for two numbers and adds them together. Result has to be between 0-9 in order to be displayed correctlypython3 deven.py examples/modulo.deven 17 10Calculates modulo (in this case 17%10) and stores the result on top of the stackpython3 deven.py examples/primes.deven 111Checks if a number (in this case 111) is prime. If yes it will put 1 on top of the stack, otherwise 0.python3 deven.py examples/primelist.deven 20Outputs for each number in the interval [2,..,n-1] wheter it is prime and outputs "y" if it is and "n" otherwise. In this case it would check from 2 to 19 and the output would beyynynynnnynynnnyny