All Projects → tomhea → flip-jump

tomhea / flip-jump

Licence: BSD-2-Clause License
The simplest programming language - Flip a bit, then Jump

Programming Languages

python
139335 projects - #7 most used programming language
C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to flip-jump

venus
OO Standard Library for Perl 5
Stars: ✭ 14 (-22.22%)
Mutual labels:  standard-library
MemeAssembly
A Meme-based programming language
Stars: ✭ 31 (+72.22%)
Mutual labels:  esoteric-programming-language
Ugly-Distributed-Crawler
基于Redis实现的简单到爆的分布式爬虫
Stars: ✭ 45 (+150%)
Mutual labels:  simple
HTML-Crypto-Currency-Chart-Snippets
💹 Simple HTML Snippets to create Tickers / Charts of Cryptocurrencies with the TradingView API 💹
Stars: ✭ 89 (+394.44%)
Mutual labels:  simple
elcalc
➗ Cross-Platform calculator built with Electron!
Stars: ✭ 88 (+388.89%)
Mutual labels:  simple
django-menu-generator
A straightforward menu generator for Django
Stars: ✭ 24 (+33.33%)
Mutual labels:  simple
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (+16.67%)
Mutual labels:  simple
SSTMCSPGAAS
Stupidly Simple Tiny Minimal Coming Soon Page Generator As A Service
Stars: ✭ 23 (+27.78%)
Mutual labels:  simple
perf
PERF is an Exhaustive Repeat Finder
Stars: ✭ 26 (+44.44%)
Mutual labels:  simple
Headache
Programming Language that compiles to 8 Bit Brainfuck
Stars: ✭ 59 (+227.78%)
Mutual labels:  esoteric-programming-language
Creamy
A simple CMS in the style of Perch.
Stars: ✭ 32 (+77.78%)
Mutual labels:  simple
spaceship-go
Spaceship Go - A journey into the Standard Library
Stars: ✭ 64 (+255.56%)
Mutual labels:  standard-library
hascal
Hascal is a general purpose and open source programming language designed to build optimal, maintainable, reliable and efficient software.
Stars: ✭ 56 (+211.11%)
Mutual labels:  simple
qsel
Quantum programming language putting entanglement and superposition front and center
Stars: ✭ 37 (+105.56%)
Mutual labels:  esoteric-programming-language
simpleRPC
Simple RPC implementation for Arduino.
Stars: ✭ 28 (+55.56%)
Mutual labels:  simple
double-sdk
A simple way to write CS:GO cheats!
Stars: ✭ 15 (-16.67%)
Mutual labels:  simple
simple-debug.css
Debug your layouts with one line of CSS
Stars: ✭ 32 (+77.78%)
Mutual labels:  simple
Chat-Server
Simple chatroom in C
Stars: ✭ 74 (+311.11%)
Mutual labels:  simple
contentfully
A simple but performant REST client for Contentful.
Stars: ✭ 13 (-27.78%)
Mutual labels:  simple
Simple-YouTube-Downloader
YouTube download client with focus on simplicity
Stars: ✭ 31 (+72.22%)
Mutual labels:  simple

FlipJump

FlipJump is an Esoteric language (FlipJump esolangs page), with just 1 operation:

  • Flip a bit, then (unconditionally) jump.
  • The operation takes 2 memory words, then flips (inverts) the bit referenced by the first word, and jumps to the address referenced by the second word.

This project is both a Macro Assembler and a Standard Library to the language.

Hello, World!

A simple fj hello-world program, not using the standard library:

def startup @ code_start > IO  {
    ;code_start
  IO:
    ;0
  code_start:
}


def output_bit bit < IO {
    IO + bit;
}
def output_char ascii {
    rep(8, i) output_bit ((ascii>>i)&1)
}

def end_loop @ loop_label {
    loop_label:
    ;loop_label
}

    startup
    
    output_char 'H'
    output_char 'e'
    output_char 'l'
    output_char 'l'
    output_char 'o'
    output_char ','
    output_char ' '
    output_char 'W'
    output_char 'o'
    output_char 'r'
    output_char 'l'
    output_char 'd'
    output_char '!'
    
    end_loop

The FlipJump assembly supports a str "Hello, World!" syntax for initializing a variable with a string value (str is defined in iolib.fj)
Look at tests/hello_world.fj program using print_str macro (stl/iolib.fj) for more info.

Note that all of these macros are already implemented in the standard library:

  • startup in runlib.fj
  • end_loop in bitlib.fj (loop)
  • output_char in iolib.fj
  • output in iolib.fj (for printing string consts, e.g. output "Hello, World!")

How to run?

>>> fj.py hello.fj --no-stl
Hello, World!
  • The --no-stl flag tells the assembler not to include the standard library. The flag is needed as we implemented the macros ourselves.
  • You can use the -o flag to save the assembled file for later use too.
  • You can use the -t flag for testing the run with the expected outputs.

You can also assemble and run separately:

>>> fja.py hello.fj -o hello.fjm --no-stl
>>> fji.py hello.fjm
Hello, World!
  • The first line will assemble your code (w=64 as bits default).
  • The second line will run your code.

Moreover - you can run multiple test programs with defined input (.in file), and compare the outputs (with .out file):

>>> fji.py assembled/ --tests inout/
...
All tests passed! 100%
  • The first path is the directory of the assembled .fjm test files.
  • The second path is the directory of the corresponding .in and .out files (same name as the test.fjm name, but with a different extension).
  • The tests will be run one at a time. For each failed test, a UNIX-like diff will be printed.

For example, you can test the entire FlipJump project (using all the tests in the tests/ dir) by:

>>> fja.py tests --tests
...
>>> fji.py tests/compiled --tests tests/inout
...
All tests passed! 100%

You can also use the faster (stable, but still in development) cpp-based interpreter (under src/cpp_fji):

>>> fji hello.fjm
Hello, World!

Project Structure

src (assembler + interpreter source files):

  • cpp_fji/ - the cpp interpreter (much faster, about 2Mfj/s).
  • riscv2fj/ - translates a riscv-executable to an equivalent fj code.
  • fj_parser.py - pythonic lex/yacc parser.
  • preprocessor.py - unwind all macros and reps.
  • assembler.py - assembles the macroless fj file.
  • fjm_run.py - interpreter assembled fj files.
  • defs.py - classes/functions/constants used throughout the project.
  • fjm.py - read/write .fjm (flip-jump-memory) files.
  • fja.py - the FlipJump Assembler script.
  • fji.py - the FlipJump Interpreter script.
  • fj.py - the FlipJump Assembler & Interpreter script.

stl (standard library files - macros):

  • runlib.fj - constants and initialization macros.
  • bitlib.fj - macros for manipulating binary variables and vectors (i.e. numbers).
  • mathlib.fj - advanced math macros (mul/div).
  • hexlib.fj - macros for manipulating hexadecimal variables and vectors.
  • declib.fj - macros for manipulating decimal variables and vectors.
  • iolib.fj - input/output macros, bit/hex/dec casting.
  • ptrlib.fj - pointers, stack and functions.

tests (FlipJump programs), for example:

  • compiled/ - the designated dir for the assembled test/ files.
  • inout/ - .in and .out files for each test in the folder above.
  • calc.fj - command line 2 hex/dec calculator, a [+-*/%] b.
  • func.fj - performs function calls and operations on stack.
  • hexlib.fj - tests the basic macros in stl/hexlib.fj.

fjms (FlipJump Memory, compiled programs), for example:

  • quine.fjm - a quine by lestrozi; prints itself.
  • hello_world.fjm - prints "Hello, World!\n(:".

Read More

A very extensive explanation can be found on the github wiki page.

More detailed explanation and the specifications of the FlipJump assembly can be found on the FlipJump esolangs page.

Start by reading the bitlib.fj standard library file. That's where the FlipJump magic begins.

You can also write and run programs for yourself! It is just that easy :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].