13
\$\begingroup\$

The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS:

��Û������������������ˆ��È���ˆB0�ˇ*,x�r�pH@NÆ˝T,�g�Œ$F(FIÏa®.GÏu0C˙íp%NÆ˝ÿJÄg�™,@"$<��ÌNÆˇ‚JÄg�í*�"�$&<��a®NÆˇ÷,�"NÆˇ‹F�k�r‹Ç*BA˙¸C˙Ra�ºª∆j��Úp�@�0j�^@�[f(¸A˙�8¸+(¸`�ˇ¯&Ã`‘@�]f8¸Nu c êàTÄ1@ˇ˛`º@�aj�T@�!kÆ@�{fª∆j��ö�}fÙ`ö@�"fB(¸A˙�(¸`��� Lª∆j
�"g›`ÚRçB ���gB êàTÄ1@ˇ˛(¸"NÆ8¸¸L`�ˇT@�'fp�8¸+<(¿`�ˇ@@�`f
 $Uå8¿`�ˇ0A˙�ˆ∞(�fVàr�8ÿQ…ˇ¸`�ˇ2g��p–¡`‡A˙TC˙^a��∫ ��gB\ êáÄ��� ‰à(¸��Ú G!@�!@�A˙¬"$<��ÓNÆˇ‚(�g��$"�$&ñáNÆˇ–"NÆˇ‹"N,x�NÆ˛bap�NuaÓ`"JNÆ˝Np
Nu@�:j�˛ûr�¬¸�
@�0“Ä�0k�:jp�`‰8¸+<(¡`�˛d@�{j�˛®@�aÂH8¸AÏ8¿8¸+`�˛H  êà‚àSÄ8ÿQ»ˇ¸Nu�+ —ï�- ëï�* ¡Ì�*Ä�/ "É¿H¡*Å�.    `%ld�A˙ˇ˙"$
NƸFXç�! ]Nê�: ] ù�; ]+�= ∞ïW¿HÄH¿*Ä�? ] gNê�$�+�%�Xç�\ *≠�+@��@ -�+m��+U�*Ä�_�Dï�& ¡ï�| Åï�~�Fï�> ∞ï[¿HÄH¿*Ä�#L›�HÁ�¿ o�NêJùg WNê`Pè�,"$NÆ˛»�^"NÆ˛Œ+��¯ Âà+5���fl"NÆ˛ò"NÆ˛òa.out���Û���������������������È����KÔ˜�IÔ¯�(à,x�C˙�p%NÆ˝ÿJÄfNu,@NÆˇƒ,�NÆˇ *�`dos.library�"N,x�NÆ˛bp�Nu����Ú

Challenge

Write a FALSE interpreter in any language (doesn't have to be an executable!). As usual, shortest bytes wins. Make sure to try to get it under 1020 though :)

Language Specs

Literals

  • 123 put integer onto the stack
  • 'c put character code onto the stack

Stack

  • $ DUP
  • % DROP
  • \ SWAP
  • @ ROT
  • ø PICK (dup the nth stack item)

Arithmetic

  • + ADD
  • - SUBTRACT
  • * MULTIPLY
  • / DIVIDE
  • _ negate (negative numbers are entered 123_)
  • & bitwise AND
  • | bitwise OR
  • ~ bitwise NOT

Comparison (false is zero, true is all bits set (-1 or ~0) so that bitwise operators may be used)

  • > greater than
  • = equals

Lambdas and flow control (tests are for non-zero)

  • [...] define and put a lambda onto the stack
  • ! execute lambda
  • ? conditional execute: condition[true]?.
    • An if-else can be expressed as: condition$[\true\]?~[false]?
  • # while loop: [condition][body]#

Names

  • a-z put a reference to one of the 26 available variables onto the stack
  • : store into a variable
  • ; fetch from a variable

Input and Output

  • ^ read a character (-1 for end-of-input)
  • , write a character
  • "string" write a string (may contain embedded newlines)
  • . write top of stack as a decimal integer
  • ß flush buffered input/output

Other

  • {...} comment
  • whitespace is ignored, may be needed to separate consecutive integers

Examples

Copy file:

{ copy.f: copy file. usage: copy < infile > outfile  }

ß[^$1_=~][,]#

Factorial:

{ factorial program in false! }

[$1=~[$1-f;!*]?]f:          { fac() in false }

"calculate the factorial of [1..8]: "
ß^ß'0-$$0>~\8>|$
"result: "
~[\f;!.]?
["illegal input!"]?"
"

Primes to 100:

{ writes all prime numbers between 0 and 100 }

99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#
\$\endgroup\$

closed as unclear what you're asking by Conor O'Brien, Mego, Blue, redstarcoder, FlipTack Dec 23 '16 at 23:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ I think the code you posted might not be displaying correctly. It probably contains unprintable characters. Can you provide a link to where you got the code? \$\endgroup\$ – mbomb007 Sep 6 '15 at 21:26
  • \$\begingroup\$ Sure! strlen.com/files/lang/false/False12b.zip \$\endgroup\$ – RK. Sep 6 '15 at 21:27
  • \$\begingroup\$ Please include the language specification of FALSE in your challenge to make the post self-contained. \$\endgroup\$ – Martin Ender Sep 6 '15 at 21:27
  • 4
    \$\begingroup\$ It might be a good idea to specify a controlled subset of FALSE. The inline machinecode facility of the language would make this considerably harder to implement portably, and the IO primitives might also limit participation by users of some languages. \$\endgroup\$ – JohnE Sep 6 '15 at 21:33
  • 2
    \$\begingroup\$ Also, can we be guaranteed to have a valid FALSE program as input? \$\endgroup\$ – Conor O'Brien Dec 23 '16 at 19:20