flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3 Next |
Author |
|
Tomasz Grysztar 31 Aug 2009, 16:01
Some graphical demo:
Code: v_EEE@^EEE^@WUU]@_BDB_ >v >:>2\?!%#v_" \.>2\?/#v_v v \0.<5 ! >"#\. ^ v " >,=)^) ^ < >="0: ^> (.1+\ v \ = ?!| > ^ x# < |
|||
![]() |
|
windwakr 31 Aug 2009, 16:17
AWESOME!
|
|||
![]() |
|
Tomasz Grysztar 03 Sep 2009, 13:29
After this post you may conclude I am completely out of my mind. ;)
I've written a simple Brainfuck interpreter in Challenger. There are three special rows on program's plane, marked with "PROGRAM:", "INPUT:" and "OUTPUT:" texts. After the "PROGRAM:" you should put the program to be interpreted and after the "INPUT:" sequence of bytes that will be fed into program when it requests input. The row following the "OUTPUT:" text will be filled with output generated by program. The row just below program is used for the program's data storage. I included the windwakr's 66-char solution to challenge 1 in from the Esoteric Programming Challenges! thread. Note that the newline character (and other control characters) is written into output just as any other character in this implementation. Well, it's a specific one. Code: v v\+.(=1 < > =0"0.-)v # INPUT: # > ^ v \ ":(..< PROGRAM:++++++++++[>+>++++++<<-]++[>>>>+++++[<<+>+++++>-]<+[<.+>-]<+<.<-], = > @v ] v ],,[< >&? v ! >v >v >v >v >v >v >v >0+| ( > >&",-|>".-|>">-|>"<-|>"+-|>"--|>"[-|>"]-| x A^ ?&< : v +0):)=6 ?&< 0 .v\+1:)=7 ?&< v < &\< + : v\1:)=8 ?&< . >"[-| . 0 -v):)=9 ?&< >.1\]],,&> "]-| >&1\-| : + \>0+.:1+ >]!"@\4*&\%&\?[ v ) ^.&\+1&< ] ? v):)=B ?&< = ] [ >0+.:1\-^> ^ \ v):)=D ?&< >0+.:0+ v v < &\< v):)=F ?&<. >"]-| >0+.:0+ |v_=).1\ &> "[-| >&1\-| > ^ << << < <^.&\+1&< \ ^ ,< < v\+.(=1 < ^ < > =0"0.-)v # OUTPUT: # > =).\ ^ ^ \ ":(..< PS. Don't worry. I'm going to get back to fasm development soon. Last edited by Tomasz Grysztar on 03 Sep 2009, 14:54; edited 1 time in total |
|||
![]() |
|
revolution 03 Sep 2009, 13:36
Tomasz Grysztar wrote: After this post you may conclude I am completely out of my mind. Tomasz Grysztar wrote: I've written a simple Brainfuck interpreter in Challenger. BTW: Challenger has no random number generator instruction and no external input, so I don' think you can emulate befunge properly. ![]() |
|||
![]() |
|
Tomasz Grysztar 03 Sep 2009, 13:42
revolution wrote: BTW: Challenger has no random number generator instruction and no external input, so I don' think you can emulate befunge properly. However, if I add ability to poke values by user at the runtime in the Challenger's plane, it might be possible to write some routines waiting for input in a specific cell (just like you may read a keyboard port in a loop with assembly language). Anyway, you're right, I'm not that completely out of my mind, trying to implement Befunge is not in my scope. ![]() |
|||
![]() |
|
revolution 03 Sep 2009, 13:56
If someone writes a befunge interpreter in Brainfuck (albeit without the PRNG) then Challenger will also have a befunge interpreter. An interpreter (Challenger) emulating and interpreter (brainfuck) for an interpreter (befunge). Now if you run all that inside a VM on a PC that has a hypervisor ... ooh, my head hurts.
![]() |
|||
![]() |
|
Tomasz Grysztar 03 Sep 2009, 14:08
BTW, I think I've chosen the wrong approach for this interpreter - I used SP to point into current position in program; if I used it to point to program's data instead, then the data range would be theoretically unlimited (and perhaps the interpreter implementation would become a bit simpler, too). Currently range of data is limited by the maximum size of offset stored in one cell. Of course, this is only theoretical thing, because in practice the plane is even more limited by the 32-bit assembly implementation of Challenger Interpreter.
|
|||
![]() |
|
Tomasz Grysztar 03 Sep 2009, 18:12
One more thing (this is the last one, I promise ;)). This time purely theoretical, thus perhaps even less interesting that previous ones.
In order to prove the Turing completeness of Pure Challenger, I made an implementation of 2-state 5-symbol universal Turing machine. The machine itself is implemented in lines starting from sixth, the initial code just sets up the pointer on the tape in the third row - the small patch of tape is pre-initialized for testing rule 101 emulation (of course for the real thing the whole infinite tape would have to appropriately initialized). The values are processed modulo 5, and because value of capital A is 65, the range of letters A-E is ideal for this purpose. Code: v # BBBBBBBBBBBBBAEAAAAAAAAAAAAAAA >:F:).v v((.< >"D\(.)v >3-| >2-| >"E\).(v >\1-| >"A\).(v >5\%| >"A\).( v >"B\(.) v ^ < > v ^ ).(\C"< |-3< ^ (.)\E"< |-2< ^ (.)\E"< |-1\< ^ (.)\A"< |%\5< ^ ).(\D"< Last edited by Tomasz Grysztar on 03 Sep 2009, 18:20; edited 1 time in total |
|||
![]() |
|
MazeGen 03 Sep 2009, 18:19
Tomasz Grysztar wrote: PS. Don't worry. I'm going to get back to fasm development soon. Haha, that was exactly the first idea which came to my mind while reading this thread today. |
|||
![]() |
|
r22 03 Sep 2009, 18:34
This could be the new MACRO language for FASM 2.x
I'm uncertain whether this would make macro writing in FASM easier or more difficult ![]() ![]() |
|||
![]() |
|
rugxulo 03 Sep 2009, 22:18
MazeGen wrote:
Really? 'Cause I can't think of any high-priority in FASM development that would supercede such a fun distraction as this. ![]() EDIT: More proof that Tomasz really is an "artist" !! ![]() |
|||
![]() |
|
Pinecone_ 04 Sep 2009, 15:39
I hope you don't mind Tomasz, I added your brainfuck interpreter to the Esoteric Programming Challenges! thread under challenge 5 (write a brainfuck interpreter). You are now the only person who's done that challenge (I'm going to try it soon though, in befunge [after I update my interpreter to handle befunge-98 code {which could be quite a while...}])
|
|||
![]() |
|
windwakr 06 Sep 2009, 18:55
You(or someone else) should create a page for it on the Esolangs wiki to get more interest in it.
|
|||
![]() |
|
neville 06 Sep 2009, 22:02
A modified graphical demo
![]() Code: v_EEE@^EEE^@_BDB_@NQQQN@VUUM >v >:>2\?!%#v_" \.>2\?/#v_v v \0.<5 ! >"@\. ^ v " >,=)^) ^ < >="0: ^> (.1+\ v \ = ?!| > ^ x# < Note: ".chl" attachments are not allowed in this forum ![]()
_________________ FAMOS - the first memory operating system |
|||||||||||
![]() |
|
neville 07 Sep 2009, 10:46
A slightly optimised version of Tomasz's Framed Chalenger string copy program (40 bytes, was 46):
Code: )3:(]2;[>?\"!-v ^_x#. < Hello! A more optimised version (32 bytes) but the string is limited to 8 chars including delimiter (or excluding delimiter if ^ used!): Code: )4:(]1;[>?\".-v hello .^_x#. < And now the Windoze (bloatware) version - 4 times bigger and runs at 1/4 speed with some unnecessary flashy stuff :lol: (Best viewed at 8 Hz): Code: )3:(]2;[>?\"!-([([([([])])])])(((([[[[(((())))]]]]))))[][][][]()()()()[]()v ^_x#. [[[[[[[[[[[[((((((((((((]]]]]]]]]]]]))))))))))))[[[[[[[[[[[[< Hello! Replace :( with colon( as required! BBCode disabled - that removed the code boxes and left the smilies (geez, rev :) Smilies disabled - did the trick! _________________ FAMOS - the first memory operating system Last edited by neville on 07 Sep 2009, 11:51; edited 2 times in total |
|||
![]() |
|
revolution 07 Sep 2009, 10:50
neville: tick the box in the edit window to disable BBCode in your post.
[edit] Oops, yeah, disable the smileys, I knew it was one of those option thingies. |
|||
![]() |
|
Tomasz Grysztar 08 Sep 2009, 14:56
I uploaded the version 1.0 of interpreter. It finally has the option to manipulate the plane contents in real time. With Peek command you can read the value of a cell (you have to click the cell with mouse), and with Poke you can write the value to any cell (who does know where I took those names from?
![]() With the existence of Poke command it's now possible to emulate a real-time input for the Challenger programs. Here is an example: Code: ]5;]v > 0=).\#v_ !IN: ^ < It repeatedly reads the cell that comes just after the "IN:" text, and if it detect any non-zero value there, it writes it out in the row below the program. It is quite similar to program that would continuously read the keyboard port to detect the user input. I suggest to run it at maximum speed and drop a few characters with Poke command into a cell after "IN:" to see the effect. I wonder if you could make some kind of game this way. ![]() |
|||
![]() |
|
neville 08 Sep 2009, 21:07
Tomasz Grysztar wrote: I uploaded the version 1.0 of interpreter. It finally has the option to manipulate the plane contents in real time. With Peek command you can read the value of a cell (you have to click the cell with mouse), and with Poke you can write the value to any cell (who does know where I took those names from? With the Poke command it not only provides real-time input but it's also possible to change the program code while the program is running. Nice! ![]() ![]() _________________ FAMOS - the first memory operating system |
|||
![]() |
|
Tomasz Grysztar 09 Sep 2009, 10:44
neville wrote: A slightly optimised version of Tomasz's Framed Chalenger string copy program (40 bytes, was 46): I made a definitely smaller version, which copies the null-terminated string (and since Challenger plane is filled with zeros by default, it copies everything that you write in the second line): Code: ],[)2:(> #.?#\_x Hello! |
|||
![]() |
|
Goto page Previous 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.