Coder Social home page Coder Social logo

xasm's Introduction

Xasm

A dumbed-down version of assembly with REPL support

Issues

Due to jmp being its own function that waits for execution to finish, recursive loops will eventually result in a stack overflow.
To get around this, use the LOOP and LOOPNOINC instructions for looping.

Usage

Registers

Register Usage
R0-12 General purpose registers
P0-12 Paramater registers, for passing arguments to functions/syscalls
RET0-12 Return registers, for returning values from functions/syscalls
L0 Loop register, defines how many times to jmp to a label

Instructions

Instruction Usage
PUSH register Pushes register onto the stack
POP register Pops the top value off the stack and into register
MOV register1 value/register2 Copies the value of value/register2 into register1
INC register Increments the value in register
DEC register Decrements the value in register
ADD register1 value/register2 Adds value/register2 to register
SUB register1 value/register2 Subtracts value/register2 from register
MUL register1 value/register2 Multiplies register1 by value/register2
DIV register1 value/register2 Divides register1 by value/register2
XOR register1 value/register2 Performs an XOR on register1 with value/register2
CMP register1 value/register2 Compares value/register2 to register and sets equal_flag, lesser_flag & greater_flag accordingly
JMP label Calls a builtin or user defined function
JE label Calls label only if equal_flag is true
JNE label Calls label only if equal_flag is false
JZ label Calls label only if zero_flag is true
JNZ label Calls label only if zero_flag is false
JG, JGE, JL, JLE label Jump greater, Jump greater than or equal, Jump less than, Jump less than or equal
SETG, SETGE, SETL, SETLE register Sets register to a boolean based on the lesser, greater and equal flags
LOOP label Calls label until L0 is 0, decrementing it each loop
LOOPNODEC label Calls label L0 times without decrementing it, much faster than LOOP

Builtin functions

Function Usage
print prints P0
printline prints P0 with a newline
input Fetches user input and places it in RET0
debug Prints out the entire program layout - functions, register states etc
exit Exits the program with exit code P0

xasm's People

Contributors

basicallygit avatar

Watchers

 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.