11-25-2022, 03:02 PM
Post: #1
 DavidM Senior Member Posts: 918 Joined: Dec 2013
It is that time of year when our thoughts turn to less mathematical themes... you know what I'm referring to, of course. Code obfuscation! What else did you think I meant!

Well, one of my favorites of this category has always been the "xmas.c" code that generates the lyrics to that seasonal song which is the musical analogy to the food world's fruitcake: "The Twelve Days of Christmas". In this particular case, it seems more appropriate to translate that title to an anagram: "steaDfasTly Cover wiTh mesh " (hence the thread title).

I submit the following with the utmost respect for the inspiration provided by Ian Phillipps with his original "xmas.c" code. I've gone out of my way to circumvent anything which would provide even accidental self-documentation or clarity to the code. It requires the use of the ListExt library, so is limited to 49G/49g+/50g calculators. The code uses trigraphs (eg. "\->" instead of "→") for portability. The INOUT program from this post can be used to convert the source text into an executable program.

I promise you, this actually works:
Code:
\<<"dqj dgg, atis bSnhc. elg egxa aij mo jrC ihe nnl nh side njwv uphjd jre juhe nsrl, aeiu heeenv hOrm ld jeti uji rBij tAfhM oesy mnmed efle-trs gfp B-ei jjjjj eYij, tprn Arj qljgf fql; nn tan a prarr sej RC ihp jkga fy, dt ngvf hfr lAe aQh njl re xag onTdtj jll trj uj, viem tv ACrn, sjje sP-h evente ijr gtcte dfea tee, edw vmry sv wjv hnto jjgpCl asmjg tjP ind mBh rtqo ens sjiet niweji quj tOs hntt eop iie cdn l-jQj jgast fwt iqn AD aq nesht mss sodaj sijer, siae jj meg mer dae ij htii jtogsc Aoj, Qii eal aionni "S\->NL LPOPR{>}+ LFILT 15 9^ RDZ LSHUF"jqwa" S\->NL 2SPLIT 87 - LREPL NL\->S 25RSPLT -60CHR+ S\->NL:: SPLIT LMAP + 12 LSEQ{13 SWAP 14DUP2 + 15LSEQR}LMAP LXIL LPICK LSUM\>>

The execution of this program is best observed by single-stepping through the code. There's no loops, and the bulk of the source code is executed in the very first step when a string is placed on the stack. It doesn't take very long to step through the rest of the program, and I encourage you to try it.

Here's one way to step through the code:
• place the program on the stack