Another example, this time some arithmetic one, as a proof of assembly-like style of this language.
It goes to the fifth row (it is defined by constant in the first character of program), looks for decimal value there and converts this string into value in accumulator. Then it calculates the square of this number, and writes it back as a decimal string in the row below the original number:

This is the first time I used the & instruction, and I used it extensively.

02 Sep 2009, 21:29

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

BTW: Challenger has no random number generator instruction and no external input, so I don' think you can emulate befunge properly.

03 Sep 2009, 13:36

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

revolution wrote:

BTW: Challenger has no random number generator instruction and no external input, so I don' think you can emulate befunge properly.

Well, one would have to implement PRG subroutine, as for the input/output - the same problem as with above interpreter.
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.

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.

03 Sep 2009, 13:56

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

03 Sep 2009, 14:08

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

Last edited by Tomasz Grysztar on 03 Sep 2009, 18:20; edited 1 time in total

03 Sep 2009, 18:12

MazeGen

Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia

MazeGen

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.

03 Sep 2009, 18:19

r22

Joined: 27 Dec 2004
Posts: 805

r22

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

03 Sep 2009, 18:34

rugxulo

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

rugxulo

MazeGen wrote:

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.

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" !!

03 Sep 2009, 22:18

Pinecone_

Joined: 28 Apr 2008
Posts: 180

Pinecone_

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...}])

04 Sep 2009, 15:39

windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA

windwakr

You(or someone else) should create a page for it on the Esolangs wiki to get more interest in it.

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.

07 Sep 2009, 10:50

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

08 Sep 2009, 14:56

neville

Joined: 13 Jul 2008
Posts: 507
Location: New Zealand

neville

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? ).

Over 30 years ago I wrote a crude Z80 editor/assembler in BASIC using PEEK & POKE commands on my TRS80 clone (with 16Kb RAM, expanded to 48Kb by piggy-backing the RAM chips 3 high)

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! (best done at 8Hz!) In fact you could even write a program from scratch while it is running, so it executes code as you enter it. This could be the genesis of a Challenger game, where the IP follows you around.... Then when you can do it at 8Hz, try 50Hz! Maybe not maximum speed though

_________________FAMOS - the first memory operating system

08 Sep 2009, 21:07

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

neville wrote:

A slightly optimised version of Tomasz's Framed Chalenger string copy program (40 bytes, was 46):

Code:

)3:(]2;[>?\"!-v
^_x#. <
Hello!

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):

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum