HackerTrans
TopNewTrendsCommentsPastAskShowJobs

tomhee

no profile record

Submissions

Show HN: Compile C to Not Gates

github.com
145 points·by tomhee·ปีที่แล้ว·63 comments

comments

tomhee
·ปีที่แล้ว·discuss
Nice job! Just started my own too.
tomhee
·ปีที่แล้ว·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
·ปีที่แล้ว·discuss
Alright - https://github.com/tomhea/flip-jump/wiki/Learn-FlipJump#memo...
tomhee
·ปีที่แล้ว·discuss
Do you have any article that I can read about it? Sounds interesting!
tomhee
·ปีที่แล้ว·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
·ปีที่แล้ว·discuss
That's cool! And that's possible. Do you have any more data to read about it?
tomhee
·ปีที่แล้ว·discuss
If you have an answer I'd be happy to hear it!
tomhee
·ปีที่แล้ว·discuss
There actually was one with subleq: https://www.google.com/amp/s/blog.attify.com/flare-4-ctf-wri...
tomhee
·ปีที่แล้ว·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
·ปีที่แล้ว·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
·ปีที่แล้ว·discuss
By the way, as a challenge, try how you can program an "If" statement in Flipjump.
tomhee
·ปีที่แล้ว·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
·ปีที่แล้ว·discuss
You are indeed right
tomhee
·ปีที่แล้ว·discuss
There is also a brainfuck to flipjump compiler: https://github.com/tomhea/bf2fj
tomhee
·ปีที่แล้ว·discuss
Thanks man, I appreciate it.