asdf part - kenrube/Esopoly GitHub Wiki
asdf is a minimalistic language with only 4 instructions.
If we want to print a character, we need to switch the bit twice by the instruction a
(aa
) while in memory cell #1 (initially we are in cell #3). Then a bit from cell #2 will be written to the memory buffer. As soon as 8 bits are accumulated in the buffer, the character with the corresponding ASCII code will be output to the console.
Our main task is to form the desired bit value in memory cell #2. The universal way is the sequence of sssas
instructions. The only thing, before its first use it's necessary to move to cell #-1.
s -1 -> 0
s 0 -> 1
s 1 -> 2
a Toggle the bit (0 -> 1 or 1 -> 0) and set the toggle flag
s 2 -> 1 (in the opposite direction, since the toggle flag is set), clear toggle flag
Now we are in cell #1. Wrote the contents of the bit in cell #2 with the aa
commands (they also set the toggle flag) to the buffer and again execute the same sequence.
s 1 -> 0 (toggle flag set), clear toggle flag
s 0 -> 1
s 1 -> 2
a toggle the bit, set toggle flag
s 2 -> 1, clear toggle flag
As you can see, we entered the cycle. If we want to toggle the bit and write it to the buffer, we execute the sequence sssasaa
, if we want to write the same bit to the buffer - just execute aa
.
From now on, we know what to do, so we create the source (for convenience, the formation of individual bits is divided by |
):
|asaasaa|sssasaa| aa|sssasaa| aa| aa| aa|sssasaa| print 'a' (01100001)
|sssasaa|sssasaa| aa| aa|sssasaa| aa|sssasaa| aa| print 's' (01110011)
|sssasaa|sssasaa| aa|sssasaa| aa|sssasaa|sssasaa| aa| print 'd' (01100100)
| aa|sssasaa| aa|sssasaa| aa|sssasaa| aa|sssasaa| print 'f' (01100110)
| aa| aa|sssasaa|sssasaa| aa| aa| aa| aa| print ' ' (00100000)
| aa|sssasaa| aa| aa|sssasaa| aa| aa| aa| print 'p' (01110000)
| aa|sssasaa| aa| aa|sssasaa| aa|sssasaa|sssasaa| print 'r' (01110010)
| aa|sssasaa| aa|sssasaa|sssasaa| aa| aa| aa| print 'o' (01101111)
|sssasaa|sssasaa| aa|sssasaa| aa|sssasaa| aa| aa| print 'g' (01100111)
|sssasaa|sssasaa| aa| aa|sssasaa| aa|sssasaa|sssasaa| print 'r' (01110010)
| aa|sssasaa| aa|sssasaa| aa| aa| aa|sssasaa| print 'a' (01100001)
|sssasaa|sssasaa| aa|sssasaa|sssasaa| aa|sssasaa|sssasaa| print 'm' (01101101)
However, the language has one nice feature that will allow us to shorten this source in the general source code: it is case insensitive, which allows using 2 symbols per 1 instruction (a
/A
, s
/S
). After embedding the source code will look like this:
DASAsSDAafdaSFfAassadsaD head
|asAAsaA|SssAsaA| aa|sSSAsAa| aA| aa| aA|SSsaSaa| print 'a' (01100001)
|ssSasaa|SSsASAA| aa| Aa|sSsaSaa| AA|sSsAsaa| Aa| print 's' (01110011)
|SsSasAa|sssAsAA| Aa|ssSAsaa| Aa|sSsaSaa|sssASaa| aA| print 'd' (01100100)
| Aa|sssaSaA| aa|SSsAsAa| aa|SSsASAA| aa|ssSAsaa| print 'f' (01100110)
| Aa| Aa|SssAsaA|sSSAsAa| aa| Aa| aA| aA| print ' ' (00100000)
| aa|ssSAsaA| aa| aA|SsSasAa| aA| aa| aA| print 'p' (01110000)
| Aa|SssAsaa| Aa| aA|SSsAsaa| Aa|SSsaSaA|sSsaSAa| print 'r' (01110010)
| aA|SsSasaa| Aa|SsSAsAa|sssaSaa| aA| AA| aa| print 'o' (01101111)
|sssaSaA|sSSAsAa| aA|sSSAsAa| aa|SsSAsAa| aa| aa| print 'g' (01100111)
|SSsAsAa|sSSAsAA| aA| aa|ssSAsaA| aA|sSSaSaa|sssaSaA| print 'r' (01110010)
| aa|SSsaSaa| Aa|sSSAsAA| aA| aa| Aa|sSSAsAA| print 'a' (01100001)
|sSsAsaa|SsSAsAa| aA|sSSAsAA|sSsAsaa| Aa|sSSaSaa|ssSAsaa| print 'm' (01101101)
Let's unite all 4 languages:
DCBA@?\nZ;|38x0SA3tsN`Lo98*G"'&%$#Sc>`v<zLxwI5tWrDpoAm?Oj)Laf8dc\aZ~X|?U=Y;v9ONS54JnHG/jJCBGF(
>b%;_"876Z{321U5.-Qr*N('K%$H(hEf${Abaw=^zs9Zp6Wm3kj0Qglk+voosooooaDo1oo>>o+oosaooooo11ooDo++oo
oasAooooooooo1ooAos+aoooo+oooooo1ASooo+oos[ooooso11oAoooo<oosooooaoo1Aoooo+oooaooooo100ooo++oo
oasoooooooooo10SSoo+0oooo+ooooooo0Aooo+oosooooooo10oAoo++ooaoooooaoo1Aoooo+oooaooooo11oooo++oo
>aaAooooooooo1oSS-s1aooo]ooooooo1oSoaa<oosoooooso11S.oo>+ooasooooaoo10oooo+oooaSoooo11oooo++So
oosAoooooooooo0SAoo+0oooo+[oooooo0Aoaa<ooooooooooo00Aoo++ooasooooooo1ooooS+oosaSoooo10oooo++oo
oaaAooooooooo10oAos+ooooo+oooooo1oSooo+oosooooooo100Aoo>oooosooooaoo10oo-oooooaooo]o100ooooAoo
oa<oooooooooo1oS.os>ooooo+oooooo1oSoao+oosooooooo11oAoo++ooasoooo[oo1oooo<ooossooooo110o--oAoo
oosAoooooooooo0oA-o10oo-ooooooooo0Ao>aooosooooosoo0SA-oooooosoo]oaoo10ooo<ooooaooooo11oo-ooAoo
oasoooooooooo1oS.os+aoooo+oooooo1oSoaa+oosoooooso110ooo++ooosooooooo1AoooS+oooaooooo100ooo++oo
oaaAoooooooooo0o.oo+0oooo+ooooooo0Aoao+oosoooooso110ooo++ooosooooaoo10o.-Sooooaoooooo00o--oAoo
oaaooooooooooo0SS-so0oo-ooooooooo0Ao-oooosooooooo10oA--ooooaoooooaoo10o.>o+oooaSooooo00ooo++So
oosAooo[<ooooo0SAoo+0oooo+ooooooo0Aoaa+oosoooooso10SAoo++ooosooooaoo10o>-oooooaooo]oo00ooooAoo
oa<Aooooooooo10o.oo>aoooo+oooooo10Sooo+oosooooosoo00Aoo++ooosoooo[ooo0ooo<ooooaoooooo00o--oAoo
oosoooooooooo10SS-o10oo-ooooooooo0Ao>oooosooooooo100A-oooooaooo]oaoo10ooo<ooooaooooo11oo--oAoo
oaaAooooooooo1oo.oo+aoooo+oooooo1oAoaa+oosoooooso11SAoo++ooosooooaoo1Aoooo+oooaooooo100ooo++oo
oaaAooooooooo10S.os>0oooooooooooo0So>a+oosooooooo11oAoo++ooaoooooaoo1Aoooo+oooaooooo11oooo++oo
oaaAooooooooo10oAoo+aoooo+[ooooo10Sooo<oosooooosoo00Aoo++ooosooooaooo0oooo+oooaoooooo00ooo+Aoo
>aaAooooooooo1oSS-s10ooo]ooooooo1oAooo<oosooooooo100.ooooooaooooo[oo10oo-oooooaooo]o100ooooAoo
oa<ooooooooooo0SSos+aoooo+oooooo10Sooa+ooooooooooo00Aoo++ooosoooooooo0o.oS+oosaSooooo00ooo+Aoo
oaaAoooooooooo0S.-s1ooo-oooooooo10So-aooosooooooo11o.--ooooaoooooaoo1Aoo-oooooaSoooo100o--oooo
oosoooooooooo10SA-s10oo-oooooooo1oAo-aooosoooooso100.oo++ooosooooaoo10oooS+oooaooooo100ooo++oo
oaaAoooooooooo0oAoo+0oooo+ooooooo0Aoaa+oosooooosoo00ooo++ooosooooaooo0oooS+oooaoooooo00.oooAoo
>osooooooooooo0SSoo+0oooo+oooooo10Aooo+oosooooooo100Aoo+oooaooooo[ooo0ooo<ooooaoooooo00o--oAoo
oosooooooooooo0SS-oo0oo-ooooooooo0Ao>oooosoooooooo00A-oooooaooo]oaooo0ooo<ooooaSooooo00o-ooooo
oosooooooooooo0S.oo+0oooo+ooooooo0Aooo+oosoooooooo00Aoo++ooaoooooaooo0oooo+oooaoooooo00ooo++oo
oaaooooooooooo0SSos+0oooo+ooooooo0Aooo+oosoooooooo00Aoo+oooasoooooooo0o.oSoooooSoooo10oooooAoo
oosAooooooooo10oAoo1aooooooooooo1oAoaaooosoooooso11SAooooooosooooaoo1Aooooooooaooooo11oooooAoo
oosoooooooooo1oSSoo1aooooooooooo1oSoaaooosoooooso100oooooooosooooaoo10oooSooooaooooo100ooooAoo
oaaoooooooooo10SSos1aooooooooooo1oSoaaooooooooooo110Aooooooasoooooooo0oooSoooooSoooo100ooooAoo
oosAoooooooooo0oAoo1aooooooooooo10Aoaaoooooooooooo00Aooooooasoooooooo0oooSoooooSooooo00ooooAoo
oosAoooooooooo0oAoso0oooooooooooo0Soooooosoooooooo00Aooooooosooooaooo0ooooooooaSooooo0oooooooo
oosoooooooooo10SAoso0oooooooooooo0Aoaaoooooooooooo00Aooooooosoooooooo0oooSoooooSoooo110ooooAoo
oosAooooooooo1ooAos10oooooooooooo0Soooooosoooooooo00Aooooooosooooaooo0ooooooooaooooo10oooooAoo
oasoooooooooo10SSoo1aooooooooooo1oSoaaooosoooooso11SAooooooosooooaoo1oooooooooaooooo11oooooooo
ooooooooooooo1ooooo1oooooooooooo1oooooooooooooooo110ooooooooooooooooo0oooooooooooooo10oooooooo
ooooooooooooo10ooooo0oooooooooooo0ooooooooooooooo10ooooooooooooooooo1ooooooooooooooo11oooooooo
ooooooooooooo1oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Unfortunately, not one online interpreter of asdf exists, so you can check only on the author's interpreter (local copy).
Go ahead, conquer the second language of the same author.