Code Monkey home page Code Monkey logo

plang's Introduction

Simple Virtual Machine for PLang

This project demonstrates the implementation of a simple virtual machine (VM), capable of executing a custom assembly language, called PLang, with file extensions .pasm.

Requirements

  • At the moment, have the NIM language installed and working on your computer.
  • Be using a Linux distribution.

How to Test

  • Clone the repository: git clone https://github.com/Diegiwg/plang
  • Make the run executable: chmod +x run
  • Execute ./run nim-test

Basic PLang Language (asm)

  • For examples, access the examples folder.

Documentation

The PLang language is designed to be simple, allowing for the creation of custom assembly programs. It supports a variety of instructions for stack manipulation, arithmetic operations, control flow, and procedure calls.

Language Features

  • Stack Manipulation: Instructions for pushing values onto the stack, popping values from the stack, and duplicating values on the stack.
  • Arithmetic Operations: Support for basic arithmetic operations such as addition, subtraction, multiplication, division, and modulus.
  • Control Flow: Instructions for jumping to labels, conditional jumps based on equality, inequality, greater than, and less than comparisons.
  • Procedure Calls: Support for defining and calling procedures, including handling of procedure arguments and return values.
  • Type Casting: Instructions for casting values from one type to another.
  • Printing: Instruction for printing values from the stack.
  • Exit: Instruction for exiting the program with a specified exit code.

Example Program

A simple PLang program might look like this:

label entry
    push 5
    push 10
    add
    print
    exit 0

This program pushes the numbers 5 and 10 onto the stack, adds them together, prints the result, and then exits the program.

Running a PLang Program

To run a PLang program, you would use the run script included in the repository, specifying the path to your .pasm file as an argument. For example:

./run nim ./my_program.pasm

This would execute the my_program.pasm file using the PLang Virtual Machine.

License

This project is licensed under the MIT License. See the LICENSE file for details.

plang's People

Contributors

diegiwg avatar

Stargazers

 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.