No activity tracked
tomhea / flip-jump Goto Github PK
View Code? Open in Web Editor NEWThe single instruction language - Flip a bit, then Jump
License: BSD 2-Clause "Simplified" License
The single instruction language - Flip a bit, then Jump
License: BSD 2-Clause "Simplified" License
rep(n, i) macro_name a1, a2, a3
for example:
rep(n, i) xor dst+dbit+idw, src+dbit+ydw
Start from very small programs - not even using the startup macro, and go up only if you handle them.
Test every function in all libs.
The second point will require finishing the pointers first, to know if anything needed for it.
Rep opcode should only contain the macro and args, not a list of ops.
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.
use - (minus) at the start of an expression.
for example:
-5+a ; -7*(-13)
.var_zero name
.var_one name
.var_zero64 name 0000
.var_one64 name 0001
.var_negone64 name ffff
Also, .var in dww-bits size.
Split run.py to:
Each is a standalone script
implement src/riscv2fj.py
elf riscv (RV32I) executable ==> .fj file using the riscvlib.fj standard library file.
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
}
.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.
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_name a1, a2, a3
(no leading dot, and comma between parameters).
for example:
xor dst+dw, src+7*dw
Check and warn in assemble time about params / dollar_params not used
Write a readme, with:
for easy understanding of the project, and easy experimentation with it.
Partially Done
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?)
find more on my notes
Make a very fast cpp interpreter.
can use parallel_flat_hash_map as the memory.
;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.
Implement stl/riscvlib.fj
Create a new standard library file just for RiscV 32bit Instruction Set (RV32I).
.fj => .fjc
The stack will contain two types of values, both in the size of 1 FlipJump operation (dw bits).
push, pop for every type.
macros for functions: call label, return.
only-flip ops (old syntax: "F" or "F;") can only be "F;" from now on.
for example:
IO+1;
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:
Fix every stl macro to suit the new change, and change the lib64 to the minimalistic it should be.
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.
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
}
wflip address, value
segment address
reserve length
(no leading ".", and comma between args)
Add option (flag) to blm.py Reader, such that it will save a word-address dict, instead of a bit-address dict.
Maybe even default behavior. Maybe treat garbage bits as zeros, if they share a word with defined bits?
maybe macro max-recursion variable (can be changed outside too).
Something simple is sufficient.
late update - includes leading "def".
def macro_name p1, p2 @ tp1, tp2 {
...
}
for example:
def exact_xor dst, src @ base_jump_label, cleanup {
....
}
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".
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.
.fjm => .fj
Test it by hand and smallish 'programs'
Use the argparse library, make one main script (run?)
change existing code to the new syntax (2.0).
use namespaces for all
namespace RV {
// constants, macros
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.