Code Palindromes

by @edent | # #

An idle thought on a long weekend. Is it possible to create an executable binary which is a palindrome?

It’s trivial to create a palindromic program in, say, Python:

print("hello") # )"olleh"(tnirp

Save that as test.py and then run cat test.py | rev | python3 and it’ll work. But that’s boring!

You could do the same by reversing the bits, rather than the characters:

01110000 01110010 01101001 01101110 
01110100 00101000 00100010 01101000 
01100101 01101100 01101100 01101111 
00100010 00101001 00100000 00100011 
00000100 10010100 01000100 11110110 
00110110 00110110 10100110 00010110 
01000100 00010100 00101110 01110110 
10010110 01001110 00001110

That requires a bit more bit-bashing to run properly. And, if I’m honest, I think padding stuff with reversed comments is cheating.

Is it possible to make an executable assembly program which can be read forwards and back?

Leave a Reply

Your email address will not be published. Required fields are marked *