Giter Club home page Giter Club logo

monty's Introduction

Monty Language Interpreter

About

  • This is an introductory project that explains:
  • 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
  • How to work with git submodules

Requirements

  • Ubuntu 14.04 LTS
  • GCC version 4.8.4 with flags: -Wall -Werror -Wextra and -pedantic

Installation

  1. Clone the repository https://github.com/ibeckermayer/monty.git

  2. Compile the program gcc -Wall -Werror -Wextra -pedantic *.c -o monty

  3. Run the program as follows:

  • Usage: monty <file.m>
  • Ex: ./monty ./bytecodes/00.m

There are multiple .m files to choose from in the bytcodes files that run different Opcode functionality. Below is a table of all the Opcode options. Each file in the bytcodes folder contains different Opcodes that run their specific functionality.

Opcode Name Opcode Description
push pushes an element on to the stack
pall prints all the values on the stack, starting from the top
pint prints the value at the top of the stack
pop removes the top element of the stack
swap swaps the top two elements of the stack
add adds the top two elements of the stack
nop doesn't do anything
sub subtracts the top element of the stack from the second top element of the stack
div divides the second top element of the stack by the top element of the stack
mul multiplies the second top element of the stack with the top element of the stack
mod computes the modulus of the second top element of the stack by the top element of the stack
comments (#) add a # to the beginning of the line to comment in the file
pchar prints the ASCII equivalent of the number at the top of the stack
pstr prints the ASCII equivalent of the numbers stored in each element in the stack, starting from the top
rotl rotates the top element of the stack to the bottom of the stack
rotr rotates the bottom element of the stack to the top of the stack

Example

vagrant@vagrant-ubuntu-trusty-64:~$ cat -e bytecodes/000.m
push 0$
push 1$
push 2$
  push 3$
                   pall    $
push 4$
    push 5    $
      push    6        $
pall$
vagrant@vagrant-ubuntu-trusty-64:~$ ./monty ./bytecodes/000.m
3
2
1
0
6
5
4
3
2
1
0
vagrant@vagrant-ubuntu-trusty-64:~$

monty's People

Watchers

Kemia Mbongo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.