Mwandoe-Shali / monty

The goal of this project is to create an interpreter for Monty ByteCodes files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project: 0x19. C - Stacks, Queues - LIFO, FIFO

Resources

Read or watch:

Learning Objectives

General

  • What do LIFO and FIFO mean
  • What is a stack, and when to use it
  • What is a queue, and when to use it
  • What are the common implementations of stacks and queues
  • What are the most common use cases of stacks and queues
  • What is the proper way to use global variables

Available operation codes:

Opcode Description
push Pushes an element to the stack. e.g (push 1 # pushes 1 into the stack)
pall Prints all the values on the stack, starting from the to of the stack.
pint Prints the value at the top of the stack.
pop Removes the to element of the stack.
swap Swaps the top to elements of the stack.
add Adds the top two elements of the stack. The result is then stored in the second node, and the first node is removed.
nop This opcode does not do anything.
sub Subtracts the top two elements of the stack from the second top element. The result is then stored in the second node, and the first node is removed.
div Divides the top two elements of the stack from the second top element. The result is then stored in the second node, and the first node is removed.
mul Multiplies the top two elements of the stack from the second top element. The result is then stored in the second node, and the first node is removed.
mod Computes the remainder of the top two elements of the stack from the second top element. The result is then stored in the second node, and the first node is removed.
# When the first non-space of a line is a # the line will be trated as a comment.
pchar Prints the integer stored in the top of the stack as its ascii value representation.
pstr Prints the integers stored in the stack as their ascii value representation. It stops printing when the value is 0, when the stack is over and when the value of the element is a non-ascii value.
rotl Rotates the top of the stack to the bottom of the stack.
rotr Rotates the bottom of the stack to the top of the stack.
stack This is the default behavior. Sets the format of the data into a stack (LIFO).
queue Sets the format of the data into a queue (FIFO).

Tasks

Task File
0. push, pall SOON
1. pint SOON
2. pop SOON
3. swap SOON
4. add SOON
5. nop SOON
6. sub SOON
7. div SOON
8. mul SOON
9. mod SOON
10. comments SOON
11. pchar SOON
12. pstr SOON
13. rotl SOON
14. rotr SOON
15. stack, queue SOON
16. Brainf*ck 1000-school.bf
17. Add two digits 1001-add.bf
18. Multiplication 1002-mul.bf
19. Multiplication level up 1003-mul.bf

About

The goal of this project is to create an interpreter for Monty ByteCodes files.


Languages

Language:C 86.5%Language:Brainfuck 8.1%Language:MATLAB 2.6%Language:M 2.1%Language:Forth 0.6%