- By Dennis Nderitu and Samson Kimani
opcode | functionality |
---|---|
push | add element to the 'top' of stack and 'end' of queue. |
pop | remove element from 'top' of stack and 'end' of queue. |
pall | print every member of the structure. |
pint | prints the member value at the top of stack. |
swap | swaps the order of the 1st and 2nd elements in stack. |
add | add top two member values. |
sub | subtract the top element from the 2nd top element. |
div | divide the 2nd element by the top element. |
mul | multiply the top two elements of the stack. |
mod | the remainder when the 2nd element is divided by the top element. |
comment | there is the ability to parse comments found in bytecode ->'#'. |
pchar | print character at the top of the stack. |
pstr | print the character at the top of the stack. |
rotl | moves element at the top to the bottom of the stack. |
rotr | the bottom of the stack becomes the top. |
queue, stack | toggles the doubly link list implementation style. |
nop | opcode should do nothing. |
- SimpleImplement the push and pall opcodes.
- The push opcode
- The opcode push pushes an element to the stack.
- Implement the pint opcode.
- The pint opcode
- The opcode pint prints the value at the top of the stack, followed by a new line.
- Implement the pop opcode.
- The pop opcode
- The opcode pop removes the top element of the stack
- Implement the swap opcode.
- The swap opcode
- The opcode swap swaps the top two elements of the stack.
- SimpleImplement the add opcode.
- The add opcode
- The opcode add adds the top two elements of the stack.
- Implement the nop opcode.
- The nop opcode
- The opcode nop doesn’t do anything.
- Implement the sub opcode.
- The sub opcode
- The opcode sub subtracts the top element of the stack from the second top element of the stack.
- Implement the div opcode.
- The div opcode
- The opcode div divides the second top element of the stack by the top element of the stack.
- Implement the mul opcode.
- The mul opcode
- The opcode mul multiplies the second top element of the stack with the top element of the stack.
- Implement the mod opcode.
- The mod opcode
- The opcode mod computes the rest of the division of the second top element of the stack by the top element of the stack.
- ImplementEvery good language comes with the capability of commenting. When the first non-space character of a line is #, treat this line as a comment (don’t do anything).
- Implement the pchar opcode.
- The pchar opcode
- The opcode pchar prints the char at the top of the stack, followed by a new line.
- TheImplement the pstr opcode.
- The pstr opcode
- The opcode pstr prints the string starting at the top of the stack, followed by a new line.
- TheImplement the rotl opcode.
- The rotl opcode
- The opcode rotl rotates the stack to the top.
- Implement the rotr opcode.
- The rotr opcode
- The opcode rotr rotates the stack to the bottom.