Code Monkey home page Code Monkey logo

flip-jump's Introduction

Snake Animation Snake Animation

No activity tracked

flip-jump's People

Contributors

lestrozi avatar tomhea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flip-jump's Issues

rep

rep(n, i) macro_name a1, a2, a3

for example:
rep(n, i) xor dst+dbit+idw, src+dbit+ydw

Use SLY

use temp files to store all needed data - maybe no needed thanks to ply ability to track line number (with t_newline).
Use PLY for tokenizing and parsing in the assembly level, and at least tokenizing at the macro preprocessor level.

enable -x

use - (minus) at the start of an expression.

for example:
-5+a ; -7*(-13)

run -> fja & fji

Split run.py to:

  • fja.py (FlipJump Assembler)
  • fji.py (FlipJump Interpreter)

Each is a standalone script

remove [len]val

no need for it.
Also - change the .rep to accept expressions with previous addresses labels.

change pad-macro implementation to:
zero_op {
0;0
}
pad x @ pad_start {
pad_start:
.rep (0-pad_start/(2*w))%x i zero_op
}

finish iolib.fj

.input dst

.def input_ascii ascii
.rep 8 i input ascii + i*dw
.end

Also make some output string if needed.
You might also want to change the libXX.fj startup.

Pointers! Add jmp_ptr and flip_ptr

As in main sketches (#51/52).
Using the big_deref and small_deref (should be implemented in libXX.fjm as .derefs or .pointers)
Also think more about setting a bit of dereferenced pointer to 0/1, maybe using:
.mov t src
.xor t (derefed)dst
.xor (derefed)data t (t==seconds xor (derefed)dst)
While xor is test_src and if 1 invert dst

macro call

macro_name a1, a2, a3
(no leading dot, and comma between parameters).

for example:
xor dst+dw, src+7*dw

Readme with examples

Write a readme, with:

  • "how to use the scripts"
  • "how to code is FlipJump assembly"
  • "code examples"
  • "what can it do for now?"

for easy understanding of the project, and easy experimentation with it.

Faster compile time

Partially Done

  • Backpatching (using str->Expr() dict) - not implemented.
  • Fast pass to resolve some main macros (maybe the most used?) - not implemented.
  • Eliminate the deep-copy at some cost (maybe calculate an Expr using a one-time-created immutable-Expr, and a dict for its values). Done.
  • Make sure to pass only over the things you want to change. Done.
  • Run profilers to get insights over the compiler bottlenecks. Done. can be done in the future too.
  • aligned ops and memories. Done.

faster w-aligned assembler

  • restrict [len]val length to w-aligned only.
  • note it in the readme/esolangs
  • change the whole assembly line to output words, not bits (should be much faster).

Think about getting rid of the .fjm files

All .fjm will be .fj files (they will just be preprocessed to a simpler one).
maybe change the .fjc name to another - it is more general than to be unique to FlipJump. (maybe .mbm Memory Bit Map?)

temp=0, reserve

;F ops should be assembled to 0;F.

This makes a zero-initialized memory to be simply created by 0-bits.

That's because 128 zero bits will create a zero bit_var in flip_jump.

The .reserve n op will create a segment with n 0-bits.
Maybe .org addr op for starting a segment in this address.

And maybe: .segment .end for each segment?
allowing user to "allocate" bits as an empty segment.

That means to also update blm to support "empty segments", as segments with size, full of zeros.

Functions and stack

The stack will contain two types of values, both in the size of 1 FlipJump operation (dw bits).

  • return address (F=temp, J=return-address)
  • bit value (F=temp, J=dw/0)

push, pop for every type.

macros for functions: call label, return.

F => F;

only-flip ops (old syntax: "F" or "F;") can only be "F;" from now on.

for example:
IO+1;

Simpler Syntax

  • Get rid of flip_by_dbit,
  • Create a .pad macro replacement
  • Replace string with a macro

Refactor to expression-based assembly

  • set parser to work with expr.
  • set preprocessor to work with Expr.
  • fix the 'eval'ed but no really (mathvec for example)
  • set assembler to work with Expr.

Move to LiberXor, and xor based mov and ops

see my notes, p85-95.
O(2w) fast xor (from bit-var to any bit).
Require the change of var-bit from just [ ;0 / ;dw ] to also have the dbit bits on (e.g. for 64-bits, have the 47 bits, 01000111 on too). So the var bit will actually be: [ ;dbit / ;dw[dbit] ].
This is only for the use of flip_by_dbit instead of flip_by (each will save 4/3/3/2 actions on 64/32/16/8 bit machines).

With it you can build:

  • mov dst src - O(4w) (bit-var to bit-var)
  • output_bit x - O(2w) (output bit-var)
  • if x l0 l1 - O(2w) (replace test, much faster).
  • zero x, one x - O(2w)
  • OR, AND - O(4w)
  • cmp a b lt eq gt - O(4w)

Fix every stl macro to suit the new change, and change the lib64 to the minimalistic it should be.

tqdm support

tqdm for the assembler macro resolve (smart update to total remaining, and manual increments), label resolve, and the interpreter (load time).
The last two can be easily done with the regular tqdm loop over for, maybe with a smart title and names.

add unit tests to stl

  • build simple tests support
  • add test.in + test.out support
  • add explanation for tests in Readme/esolangs

fast call

Make very fast calls, and then change the heavy tests (and heavy stl macros) to use it.
The result should be much smaller file sizes, a POC for riscv2fj.

save 3 return-address variables: ret_addr1, ret_addr2, ret_addr3.

// foreach 1,2,3 do:
ret_addr1: bit 0
def call1 label @ ret {
    wflip ret_addr1+w, ret
    ;label
  ret:
    wflip ret_addr1+w, ret
}
def ret1 {
    ;ret_addr1
}

macro declaration

late update - includes leading "def".

def macro_name p1, p2 @ tp1, tp2 {
...
}

for example:
def exact_xor dst, src @ base_jump_label, cleanup {
....
}

namespaces

ns_name {
    // declare inside variables
    // declare inside macros
    // declare inside labels / ops
    // use inside declarations with a leading "."
}
// use declarations from outside using a leading "ns_name."

Also, allow recursive namespaces (namespace inside a namespace, and so on).

For example:

best_namespace {
    X = 7
    foo i {
        not i+3
    }
  func:
    return
  label:
    ; .func   // inside use ("." for current namespace)
}

best_namespace.foo v
;best_namespace.label
v:    var 64, best_namespace.X

another example: implementing a "struct"/"class".

Make the Calculator!

test/calc.fj
For an input (ignoring whitespaces) of X+Y or X-Y (hex-ascii) it will print f"> {result}".
Endless loop, until q/Q/x/X is inputted.

move to new syntax

change existing code to the new syntax (2.0).
use namespaces for all
namespace RV {
// constants, macros
}

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.