Skip to content

reinventingthewheel/micro-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Micro Assembly Specification

This is a specification of a very limited assembly language (almost machine code) for the first level of abstraction from brainfuck.

It does not provide several common operations (such as multiplier), and also lacks labels and macros.

Hence, every instruction should be written in the form:

<I> <A><N>

Where <I> is the instruction letter, <A> is the optional addressing mode symbol and <N> is a non-negative integer.

The addressing mode symbol can be:

  • (none) -> Indicates an literal value. The value will be exactly <N>
  • @ -> Indicates that value is at <N> memory address
  • * -> Indicates a pointer. It will fetch operand value from the address stored at <N>

Instruction Set

Some instructions only accepts literal values, while others can work with values stored on memory and pointers. Here are the instructions in all available forms:

  • L <N> -> Loads the value <N> into register
  • L @<N> -> Loads to register the value at <N> memory address
  • L *<N> -> Loads to register the value value pointed by <N>
  • S @<N> -> Saves register value into <N> memory address
  • S *<N> -> Saves register value into memory address pointed by <N>
  • + <N> -> Adds <N> to register
  • + @<N> -> Adds value at <N> memory address to register
  • + *<N> -> Adds value pointed by <N> to register
  • - <N> -> Subtracts <N> from register (storing result in register)
  • - @<N> -> Subtracts value at <N> memory address from register
  • - *<N> -> Subtracts value pointed by <N> from register
  • J <N> -> Jumps to line number <N>
  • J @<N> -> Jumps to line number in <N> memory address
  • J *<N> -> Jumps to line number pointed by <N>
  • = <N> -> Skips next line if register is equals to <N>
  • = @<N> -> Skips next line if register is equals to value at <N> memory address
  • = *<N> -> Skips next line if register is equals to value pointed by <N>
  • < <N> -> Skips next line if register is less than <N>
  • < @<N> -> Skips next line if register is less than value at <N> memory address
  • < *<N> -> Skips next line if register is less than value pointed by <N>
  • > <N> -> Skips next line if register is greater than <N>
  • > @<N> -> Skips next line if register is greater than value at <N> memory address
  • > *<N> -> Skips next line if register is greater than value pointed by <N>
  • R -> Reads a char from stdin to register
  • W -> Writes a char from register to stdout

Comments starts on the ; character and ends at end of line. White spaces are free

About

Assembler to build programs to a theoretical brainfuck bit code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published