flat assembler
Message board for the users of flat assembler.

Index > Heap > Esoteric Programming Challenges!

Goto page Previous  1, 2, 3 ... 10, 11, 12
Author
Thread Post new topic Reply to topic
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Good news for whoever is following my progress (two downloads, woot! heh). I've done it! 1021 bytes unpacked!

Ooh, page 12 at last! Laughing

P.S. The original TASM version hung if no file was specified, had a buggy "=" directive check (which is non-standard, AFAICT, in Befunge93), and had a stack underflow problem (didn't pop 0 if empty). So I fixed those and made it exit with error upon no file found (originally I said "Bad file" but for space reasons I followed the example of *nix ed line editor with "?", heh). I've tested a few scripts, nothing really weird (chess, eta_hello), but most semi-reasonable should work okay. EDIT: "Divide overflow" in eta_hello (known to be very picky), but chess actually does seem to work. Please report bugs, especially if the older version (source still included) worked but doesn't anymore!

P.S. Pinecone_ could probably use FASM to put this one inside the DOS MZ stub in his Win32 PE version, heh (no pressure). Wink

EDIT: Attachment removed, see below.


Last edited by rugxulo on 26 Oct 2009, 22:21; edited 1 time in total
Post 24 Oct 2009, 17:09
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
rugxulo wrote:

[*]add use of LFN-to-SFN func for more convenience ... easy


EDIT: Very minor new release (befi_2g.zip), adds sed scripts (inside MAKE.BAT) for auto-conversion to NASM/YASM or Octasm. I'm also going to stop spamming this thread and just put it in its own project thread.


Last edited by rugxulo on 30 Oct 2009, 17:57; edited 2 times in total
Post 25 Oct 2009, 12:34
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Some more random / interesting? findings:

Code:
09-2%.@
    


Quote:

[ WinXP ] Sun 10/25/2009>bef -q negmod.bef
-1
[ WinXP ] Sun 10/25/2009>mtfi -3 negmod.bef
-1
[ WinXP ] Sun 10/25/2009>pconeb93 negmod.bef
-1
[ WinXP ] Sun 10/25/2009>befi negmod.bef
1


Guess that's a bug (but who needs that?). Confused

Also, check out the speed difference for this useless snippet (MTFI 8086 version runs it incorrectly so not listed):

Code:
91+:*-:0`#@ #._
    


Quote:

[ WinXP ] Sun 10/25/2009>redir -t bef -q intmax.bef
2147483596 Elapsed time: 82.720 seconds (0:01:22.720)

[ WinXP ] Sun 10/25/2009>redir -t pconeb93 intmax.bef
2147483596 Elapsed time: 50.860 seconds

[ WinXP ] Sun 10/25/2009>redir -t befi intmax.bef
2147483596 Elapsed time: 29.660 seconds


That's on this P4 2.52 Ghz here running XP SP3. I ran the same on my old old P166 (heh), and BEFI was comparatively much much faster (approx. 4 mins. for BEFI vs. 23 mins. for DJGPP-compiled BEF or I think 12 mins. for Pinecone_'s).

EDIT: Using BEF2C -p -o (else itself crashes), the resulting time is 6 mins. on my P166 (GCC 3.4.4, DJGPP 2.04).

Lame examples, but still interesting I thought.
Post 25 Oct 2009, 14:24
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
BASE7.BEF: Not optimized, could be written better (e.g. as chars or only one decimal number instead of having dumb spaces between digits), but hey, it works. Wink

Code:
v    actually works now! Smile
     rugxulo _AT_ gmail _DOT_ com


  decimal = base7

      300 = 606
       99 = 201
       33 = 45

    300/7 = 42 r 6
     99/7 = 14 r 1
     33/7 =  4 r 5


                                 >:91+`#@_.
>99+&v                   >:# !#$_^
     >:#/ 7 # %# :#\_\:!#^_7/
    
Post 03 Nov 2009, 23:07
View user's profile Send private message Visit poster's website Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
rugxulo wrote:
BASE7.BEF: Not optimized, could be written better (e.g. as chars or only one decimal number instead of having dumb spaces between digits), but hey, it works. Wink

Code:
v    actually works now! Smile
     rugxulo _AT_ gmail _DOT_ com


  decimal = base7

      300 = 606
       99 = 201
       33 = 45

    300/7 = 42 r 6
     99/7 = 14 r 1
     33/7 =  4 r 5


                                 >:91+`#@_.
>99+&v                   >:# !#$_^
     >:#/ 7 # %# :#\_\:!#^_7/
    


All you gotta do is change the ending to:
Code:
>:91+`#@_86*+,
    



And now for some reason I feel the urge to do some Befunge coding....

_________________
----> * <---- My star, won HERE
Post 04 Nov 2009, 00:17
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
windwakr wrote:

All you gotta do is change the ending


Yeah, I also thought of that this morning. Anyways, here's a slightly smaller version:

Code:
v#  ,+"0"_@#!`-17:<
>7&v              ^_$#:<
   >:#/ 7 # %# :#\_\:!#^_7/
change all sevens to eights for Octal
    


Now if only eta_hello.bef worked in more interpreters (ahem, befi). Wink
Post 04 Nov 2009, 17:41
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
I've been fairly inactive lately, mostly due to school work. However I have found a practical use for these esoteric languages Smile crackmes.

Look at the following peice of code I wrote for one:
Code:
~:!#v_l\7+89***l{>" a retne tsum uoY" v 
>v  >$:v>0".eman"^}<{"Wrong Serial."0<>#
,:  v0 _^   >!  #v_^  <>"oY"v        ^ <
^_@ >&::'0`#^_'8#$`#v_^     {           
    ^    +*8\-\*8:#6<  ^"u must enter"< 
^"Yay"0_}#      =_0".rebmun laires a "^^    


It's pretty similar to befunge, but with a few extra instructions...
' enters stringmode for the next character only, then returns to normal mode

{ moves the IP to 0,y (y being the current y position) and resumes executing with the same delta as before.

} same as { but to the right side.

= compare the equality of the top two values on the stack. push 0 if equal, 1 if not equal.

l roll bits of value on the top of the stack left by one bit.

~ acts like input in regular befunge, but reads from the name the user entered into the name/serial form.

& is like ~ but reads from the serial entered instead.

, is the output of the script, either "You must enter a serial.", "You must enter a name.", "Wrong Serial." or "Yay" (meaning success, but I didn't have enough space for that)


These got me thinking.. what other strange instructions could we come up with, that could be useful in terms of flow control that don't take away from the befunge feel, and could potentially help size optimizations?
Post 11 Nov 2009, 10:57
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Pinecone_ wrote:
I've been fairly inactive lately, mostly due to school work.


Yes, I figured as much. Sad that they overwork kids so much these days.

Quote:

However I have found a practical use for these esoteric languages Smile crackmes.


You mean piracy (boo hiss) or just general password-ish related stuff? (Your code doesn't really tell me anything. I'm not sure what it's supposed to do.)

Quote:

These got me thinking.. what other strange instructions could we come up with, that could be useful in terms of flow control that don't take away from the befunge feel, and could potentially help size optimizations?


Looks vaguely more like Befunge98 than 93. I still don't really get 98, parts of it are a bit weird and confusing. I think Befunge98 can be extended to do whatever you need (fingerprints -> A-Z). Didn't you have plans for extending your interpreter to B98 at some point?

P.S. I likely want to port your existing B93 interpreter to DOS, but some of the routines aren't really obvious where they want what, etc. (I'd have to take another look to be more specific, though.)

EDIT: BTW, B98 seems to choke on whitespace in stringmode (e.g. my GUESSWHO.BEF example), both CCBI and FBBI. I personally consider that a bug, but who knows ....
Post 12 Nov 2009, 15:48
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
rugxulo wrote:
Yes, I figured as much. Sad that they overwork kids so much these days
Thankfully I'm finished year 12 now Smile

rugxulo wrote:
You mean piracy (boo hiss) or just general password-ish related stuff? (Your code doesn't really tell me anything. I'm not sure what it's supposed to do.)
i mean crackmes. I've used befunge variants in two crackmes i've submitted to that site (thats 2/2! :p). If you're wondering, it's a site where reversers write and upload challenges for others to try and crack. Usually that involves writing a keygen or getting a name/password or beating the protection system. It is 100% legal and not one of those 100% legal things that are a gray area morally. Read more on the website.

rugxulo wrote:
I likely want to port your existing B93 interpreter to DOS, but some of the routines aren't really obvious where they want what, etc.
I suspect you already have, but if you haven't, check Windows.asm, I gave descriptions on expected args and returns in there. Also it uses 32-bit registers so would it be possible to port to DOS? Feel free to ask any questions, Ill be happy to help.

rugxulo wrote:
BTW, B98 seems to choke on whitespace in stringmode
And yeah, B98 only pushes one space to the stack in stringmode regardless of how many are in a row.
Post 13 Nov 2009, 13:19
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Pinecone_ wrote:
rugxulo wrote:
Yes, I figured as much. Sad that they overwork kids so much these days
Thankfully I'm finished year 12 now Smile


Good, congrats!

Quote:

rugxulo wrote:
You mean piracy (boo hiss) or just general password-ish related stuff? (Your code doesn't really tell me anything. I'm not sure what it's supposed to do.)
i mean crackmes. I've used befunge variants in two crackmes i've submitted to that site (thats 2/2! :p). If you're wondering, it's a site where reversers write and upload challenges for others to try and crack. Usually that involves writing a keygen or getting a name/password or beating the protection system. It is 100% legal and not one of those 100% legal things that are a gray area morally. Read more on the website.


Wow, that's something totally different that I've never heard of.

Quote:

rugxulo wrote:
I likely want to port your existing B93 interpreter to DOS, but some of the routines aren't really obvious where they want what, etc.
I suspect you already have, but if you haven't, check Windows.asm, I gave descriptions on expected args and returns in there. Also it uses 32-bit registers so would it be possible to port to DOS? Feel free to ask any questions, Ill be happy to help.


You did give some description, but it was still a little confusing. I'll have to look at it in more depth later. And yes, you can use 32-bit regs in DOS (DJGPP does all the time [e.g. Quake], as does OpenWatcom [e.g. Doom]).

Quote:

rugxulo wrote:
BTW, B98 seems to choke on whitespace in stringmode
And yeah, B98 only pushes one space to the stack in stringmode regardless of how many are in a row.


You're right, I didn't know (hadn't read the full spec). I'll have to read it more in-depth later. (Actually found old specs to '96 and '97, and I tried for a few hours late last night to write a program to tell which one it's running on, but that was very frustrating, so I gave up ... for now.)
Post 13 Nov 2009, 22:13
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Okay, my latest creation, useless but interesting:

EDIT: Tweaked.

Code:
!"  "-!#v_"8879">,1k$>,@
;$R z 3
        >0"39"#@,z+  ^

WinXP> bef -q whichbef2.bef                        93
WinXP> befi whichbef2.bef                          93
WinXP> pconeb93 whichbef2.bef                      93
WinXP> fbbi -93 whichbef2.bef                      93
WinXP> ccbi --befunge93 whichbef2.bef              93
WinXP> for %a in (whichbef2.bef) do mtfi -3 %~sa   93
WinXP> for %a in (whichbef2.bef) do mtfi -6 %~sa   96
WinXP> for %a in (whichbef2.bef) do mtfi -7 %~sa   97
WinXP> fbbi whichbef2.bef                          98
WinXP> ccbi whichbef2.bef                          98
    


Last edited by rugxulo on 14 Apr 2010, 17:50; edited 1 time in total
Post 14 Nov 2009, 02:56
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Since some Befunge98 interpreters don't have a -93 compatibility mode (I'm looking at you, CCBI), I decided to make my "guess who" more compatible so that it works either way. This is a direct result of the different whitespace handling in string mode.

EDIT: CCBI 2 has --befunge93, but it's quirky (reflects on invalid instructions, ugh).

Code:
v (guess who, gleaned from 4tH example, now compatible with B93 or B98)
<v"& "+49"X *"::" *"7" X"5" X!"
 <v" XX"*62" XXXX"::" "6"X/"5" X"5" XXXX!"*44" XXX"+49" XX***"9" X"5" X!"/2
  <v" "8"X\"5" XX"::" XX":" X!"*26" XX"*26" XX"*27" X"5" X":::" X":" XX!"*27
   <v35" X":" X X":" X!"+19" X"/4"4 X"9" X"*72" XX X":" XXXX!"+92" X"+49" X"9
    <v"X":::" X"::" X":::" X"8" X"/3"3 XXX":" XX!"+19" X":::" XXX"6" X"8" X"*
     <v:::" X":::" X":::" X"8" X!"9" X"::" X":::" X":::" X"8" X"/2"( XX!"9" "
      <v9"X/!"8" X"5" XXX//":::" X"+19" X!"8" X":::" X"::" X"5" X"9" X!"8" X"
       <v7" X"/2", XXXX!"9" X"9" //"::" X"/2": XX!"8" X"9" //":::" X"+19" "*2
        <v*93" X** X!"+92" X"8" XX":::" XX"5" X"/2", X***X!"+19" X"9" //XXXX"
         <v*72" XX"::" X "6"*":" "9"X"*28" XX XXX!"*62" XX"6" X ****":" X"
          <v:" "5"*":" X"*62" XXX"5" XX!"*82" XXXX "7"* XXX"6" XXXX"+91" XX!"
           <v/2", XXXX!"*37" X":::" XX!"/2"( X":" ***":" X"*28" "5"X!"/2"& X"
 v          <
 >:!#@_:"!"-  v
 ^   ,_v#`*56:_91+,$
#| #$_ >1-\:,\:!
    


Last edited by rugxulo on 14 Apr 2010, 17:51; edited 1 time in total
Post 14 Nov 2009, 16:37
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Sorry to bump this old (favorite) thread! Wink

I was reading some Lua page today (and not totally convinced at it being such an easy language to learn), and I think it led to some Quine page. Normally I wouldn't even be interested because it's so hard to do. (I am in awe at some like the Intercal version!!) But with Befunge it seemed pretty trivial. (Also, I resent the idea that the obvious Rexx one is "cheating".)

The only problem is mine is SO obvious that it almost 100% mirrors one of the pre-existing ones (and I didn't look):

I wrote:

:0g,1+:94+`#@_


Kevin Vigor, Denis Moskowitz wrote:

:0g,:93+`#@_1+


Yeah, I'm sure somebody can come up with a better method. (That one plus four others are listed here, if you're curious.)

P.S. Isa recently posted here his Net-/OpenBSD BF93 interpreter in the High Level Languages section, in case you missed it.

P.P.S. I was gonna say, "Where's Pinecone_???" but noticed that I too haven't posted much since November. Ah well. Razz
Post 03 Apr 2010, 06:57
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
I'm here!

Sorry for the lack of activity on this forum in (wow... ages... time flies Razz) I've just been busy with other things for a while. Lately I've been practicing for a web development competition (If i win it, I get a free trip to england in 2011 to compete representing australia Very Happy)... Web development seems so boring... and un-esoteric... can't help but be sad that I haven't been doing this stuff much lately...

However I did have a good idea for a new esoteric language!

Consider:
Code:
65 x =
{
    { x 6 + x = } { 91 x == } IF
    x PRINT_ASCII
}
{ 123 x <= } WHILE    
to be equal to:
Code:
x = 65;
while (x <= 123) {
    if (x == 91) x = x + 6;
    PRINT_ASCII(x);
}    
I'm sure you esoteric programming fans can figure out the general idea of the language Smile

Also, due to the syntax I'm planning, the above code can also be written on one line:
Code:
65 x = { { x 7 + x = } { 91 x == } IF x PRINT_ASCII } { 123 x <= } WHILE    
Note: all the spaces will be necesecary, because they will make it easier to make a compiler/interpreter for the language, therefore I'm making them required Razz

A few notes:

  • Variables start with a lower-case letter.
  • Function calls start with an upper-case letter.
  • Between { and } are code "groups". When execution goes over them, the contents (or a pointer to them... whatever, depends on implimentation i guess) is pushed onto the stack. Then functions can execute code that has been pushed onto the stack as a paramater to that function. For example, IF has two paramaters. The first paramater is code which determines the condition (eg. { 0 1 == }) will always be false, and the second should be the code to execute if the result of the condition is true. I believe this type of code grouping will make it very easy to make an interpreter, but am not so sure about a compiler Razz
  • On an interpreter's / compilers side of things, functions and operators could be implimented in exactly the same way.
  • Variable and function names ARE allowed to contain symbols (#$%^&*|<>.....) in their name, as long as their first letter is a character (lower case for variables, upper case for functions). This is to increase obfuscation options Smile Note: a non-breaking space is to be considered a symbol, as are control characters and extended ascii characters. Unicode is not to be supported.


Also I'm not too sure about these things and open to suggestions of how they should be handled:

  • Calling convention
  • String variables


If anyone is feeling bored, feel free to give a go at implementing the language Smile I'm thinking of calling it Inverse.

One last note: I'm defining Language here, to mean the syntax of the language. The functions and operators avaliable to any implimentations of the language can vary, and should be called "Inverse:<Specific Name for implimentation>". My future implementation of Inverse (which may quite possibly be the only one, I'm just stating this stuff in-case someone decides to take interest to this Smile) shall be the only Inverse "variant" to simply be called "Inverse" (with no specific name).

Functions / Operators are to leave their result (if any) on the stack (which then allows them to be assigned to variables easily).

The tricky part for an interpreter/compiler will be knowing whether a reference to a variable or the value of the variable is supposed to be pushed onto the stack. The best (or at least easiest to implement) idea I've had to overcome this is to push a reference to the variable and the variable's current value onto the stack, and then functions/operators uses whichever one they need to perform their purpose and discard the other (or special cases can be made, for example for the operator += which may use both) Smile

I'll go into more detail after I get some time to write some more stuff up about it and give a go at writing an interpreter... Unfortunately that time wont come for at least a month from now.

PS: Inverse was inspired by Reverse Polish Notation.

Edit: Fixed a would-be bug in the code Razz


Last edited by Pinecone_ on 07 Apr 2010, 08:12; edited 2 times in total
Post 06 Apr 2010, 14:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16858
Location: In your JS exploiting you and your system
revolution
Your "new" language looks like Forth.
Post 06 Apr 2010, 15:27
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Really?... Razz I've never studied Forth... *Checks out Forth*

Edit: It does seem to have similarities... kind of like Forth is a super-advanced Inverse from the future! Hmmmm... Maybe using my new Inverse language I created a time-travel machine, traveled back in time and invented Forth (obviously I couldn't use my real name back then or I would have confused myself now)

Yes, that's what happened Razz

lol anyway, I'm still interested in doing this... as soon as I get some time to... (I'm also interested in learning Forth now Razz)
Post 06 Apr 2010, 15:46
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Forth is cool but confusing. In particular, few adhere to the standard, so you often have some mishmash of half-implemented versions. But they're usually still interesting. Wink

Anyways, I updated my hack (befi.com), bugfix to properly ignore uppercase letters (which apparently fixes official befunge[3x].bf examples). Also tweaked some other stuff. Of course, to add the fix, I had to increase the code, and shrinking back to 1024 wasn't too easy, so now it always returns a bogus errorlevel (to be fixed eventually/hopefully).

There's also another interpreter, Serprex/Marsh (written in C99, apparently for *nix since it assumes "/dev/random") which seems pretty fast, e.g. even faster than BEFI.COM on this P4 (but not other cpus) when compiled with GCC 4.4.2 -mtune=pentium4 -O2 -fomit-frame-pointer.

CCBI (Win32 or Linux32/64 only) was also updated to version 2, and he also updated Mycology. He now has a --befunge93 mode, but it's quirky (reflects on invalid instructions, e.g. ';', why??? not even official BEF or FBBI do that!).

Actually, a lot of guys in #esoteric on irc.freenode.net seem to be writing Befunge interpreters but aren't finished optimizing yet (heh). Wink

P.S. Here's some new results for my benchmark.bef (although I *may* have accidentally used GCC 4.2.3 instead of much-faster 4.4.2, but whatever, the comparison is the same, used same .EXE for each machine). Note that I didn't use DJGPP's "redir -t" this time because a while back I made a temporary two-byte change to BEFI.COM and, on my AMD64x2 laptop running Vista, it slowed down twice as much (but only under REDIR!), so I avoided that here just in case.

Quote:

91+:*-:0`#@ #._

=====================================================
gcc-4.4.2 -s -O2 -mtune=pentium4 -fomit-frame-pointer bef.c -o bef.exe

[ MS-DOS 6.22 ] 486 Sx/25 >runtime befi.com benchmar.bef
2147483596 50:41.92 elapsed
[ MS-DOS 6.22 ] 486 Sx/25 >runtime bef.exe -q benchmar.bef
2147483596 04:09:29.73 elapsed

[ DR-DOS 7.03 ] P166 no MMX >runtime befi benchmar.bef
2147483596 03:39.51 elapsed
[ DR-DOS 7.03 ] P166 no MMX >runtime bef -q benchmar.bef
2147483596 21:46.26 elapsed

[ FreeDOS 2038 ] P4 Celeron 2.40 Ghz >runtime befi benchmar.bef
2147483596 33.02 seconds elapsed
[ FreeDOS 2038 ] P4 Celeron 2.40 Ghz >runtime bef -q benchmar.bef
2147483596 01:16.87 elapsed
=====================================================


Laughing
Post 14 Apr 2010, 17:41
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
I remembered (but never got around) to the 1-year anniversary of (last update) of your (Pinecone_)'s Befunge93-win.exe . Oh well, happy birthday to it! Smile (EDIT: I really enjoyed learning Befunge, and it's all your fault, heh!)
Post 08 Nov 2010, 16:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 10, 11, 12

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.