Code Monkey home page Code Monkey logo

ijvm_experiments's Introduction

IJVM_Experiments

IJVM Assembly programs written in (Extended) Tanenbaum IJVM.

This repository contains some example programs written by me. Part of these have been generated with a small toolchain I've written.

IJVM implementation requirements

  • bfi2 uses extended instructions (NEWARRAY, IALOAD, IASTORE)
  • calc uses extensive recursion

Files:

calc

A reverse polish notation calculator with extensive feature set (not/and/or/xor/plus/minus/division/etc.)

Not a particularly complicated program but throws together a large number of operators.

bfi2

A brainfuck interpreter, compiles the brainfuck to bytecode with some optimisations, and and finally executes it. Works by giving it a

bf_prog ":" bf_input

mandelbread

A mandelbrot set viewer, the tricky part here is that IJVM obviously only has integers, and a very limited set of arithmetic operations on these integers.

After constructing a mulitply that relies on the fact that BIPUSH x; DUP; IADD gives 2 * x and a slightly more involved division algorithm which works with the same principle, we have the basic building blocks.

The rest of the algorithm is simply scaled up complex numbers (so theyre large enough for integer calculations), and division at the right time. (Also comparison to 2 power is replaced with bitmasking)

In pseudocode (python), the core method would simply be (shifted 8 bits)

def mandelbrot_int(real0, imag0, max_iterations):
    real, imag = real0, imag0

    for n in range(max_iterations):
        realq = (real * real) >> 8
        imagq = (imag * imag) >> 8

        #if (realq + imagq) >> (8 + 3) > 0:
        if (realq + imagq) & 0xfffff000 != 0:
            return n

        imag = ((real * imag) >> (8 - 1)) + imag0
        real = realq - imagq + real0

    return max_iterations

Helpful links

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.