HackerTrans
TopNewTrendsCommentsPastAskShowJobs

tomhee

no profile record

Submissions

Show HN: Compile C to Not Gates

github.com
145 points·by tomhee·letztes Jahr·63 comments

comments

tomhee
·letztes Jahr·discuss
Nice job! Just started my own too.
tomhee
·letztes Jahr·discuss
@alok-g I'll be happy to explain - You don't understand it correctly. The flipjump assembly syntax does allow relating to an address with offsets/more advanced stuff, but that doesn't add anything to.the language. It' just adds comfort to the programmer - it's basically like adding labels to an assembly language - it's possible to write assembly without them, just much less convenient.

The power of flipjump results in self modifying code. If I jump to a address that have the [flip 0, jump 0x1000], then I'll get to 0x1000 afterwards, right? But if I flip some specific bit in this instruction before jumping to it, it will become [flip 0, jump 0x1080]. You can call this instruction "memory bit", and the part of jumping to it and resulting in one of two possible addresses 0x1000/0x1040 based on a specific bit in it - "read the memory bit". The action is reading as you get to different place based on the value stored in this instruction. This "read" can also be seen as an "if". How you write then? For example writing "1" whould be doing a "read", and in the "read 0" case - do a flip to this address, and in the "read 1" case don't flip this memory address bit.
tomhee
·letztes Jahr·discuss
Alright - https://github.com/tomhea/flip-jump/wiki/Learn-FlipJump#memo...
tomhee
·letztes Jahr·discuss
Do you have any article that I can read about it? Sounds interesting!
tomhee
·letztes Jahr·discuss
The power is within the self modification of the code. The jump might be implemented by a multiplexer, though it can be implemented in other ways too.
tomhee
·letztes Jahr·discuss
That's cool! And that's possible. Do you have any more data to read about it?
tomhee
·letztes Jahr·discuss
If you have an answer I'd be happy to hear it!
tomhee
·letztes Jahr·discuss
There actually was one with subleq: https://www.google.com/amp/s/blog.attify.com/flare-4-ctf-wri...
tomhee
·letztes Jahr·discuss
Sure!

https://github.com/tomhea/flip-jump/wiki/Learn-FlipJump

This will let you understand how to implement the very basic "if" in flipjump.

I tried to make it as easy for newcomers, but please feel free and update me if something is written complicated.

After you understand up to the macros, you can try yourself to understand the xor macro, which most of the library is built based on it: https://github.com/tomhea/flip-jump/blob/fe51448932e78db7d76...
tomhee
·letztes Jahr·discuss
Good point! It's mentioned in the github wiki here: https://github.com/tomhea/flip-jump/wiki/Learn-FlipJump#memo...

It was once in the Readme but as I kept developing it more it become longer and longer, so I moved it into the wiki, and especially to here: https://esolangs.org/wiki/FlipJump
tomhee
·letztes Jahr·discuss
By the way, as a challenge, try how you can program an "If" statement in Flipjump.
tomhee
·letztes Jahr·discuss
I dont think that the jump can be realized by NOT gates, but it's essentially "where to find the next NOT command". The jump is indeed a crucial part of the language, as it allows going back, and especially to make self-modifying code.
tomhee
·letztes Jahr·discuss
You are indeed right
tomhee
·letztes Jahr·discuss
There is also a brainfuck to flipjump compiler: https://github.com/tomhea/bf2fj
tomhee
·letztes Jahr·discuss
Thanks man, I appreciate it.