Jump to content
IGNORED

Programming ON the 2600: esoteric langauges


vidak

Recommended Posts

I have to be brief because my partner is calling me haha:

- there is an esoteric langauge with 8 operations

- they are represented by the symbols .,<>[]+-

- the compiler can be as small as 1KB

- it is called 'brainfuck'

 

programming ON the 2600??

Edited by vidak
Link to comment
Share on other sites

Well what I mean is I could make a cart not unlike Warren Robinett's BASIC cartridge except you would have a much lower and more powerful control of the hardware while programming on the 2600. You would only need at least 8 buttons, as well, not counting text formatting keys.

The premise of brainfuck is that you have a one-dimensional array of memory cells, that can each hold an 8-bit number.

 

You may move left and right along the memory cell list, and you may decrement and increment the value in a memory cell. You may also write out the value of the memory cell to the console, and you may read in a value from the console. You may also set up loops, and nested loops, to iterate over sections of code.

 

I believe this esoteric language is sufficiently simple enough to allow some limited programming natively on the Atari 2600 console, so you may write and execute programs in real time on your own 2600.

Link to comment
Share on other sites

I think it's possible - the idea just dawned on me, though.

 

People have already written compilers for brainfuck, and have done it in around 1KB.

 

I suppose I would just have to reimplement their sourcecode.

 

I think I would perhaps implement the 7-bit ASCII character set, but that would take up room. Perhaps I could go with a 5-bit character set, and forego lower case characters.

 

The code for "Hello World" looks like this:

1 +++++ +++               Set Cell #0 to 8
 2 [
 3     >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
 4     [                   as the cell will be cleared by the loop
 5         >++             Add 4*2 to Cell #2
 6         >+++            Add 4*3 to Cell #3
 7         >+++            Add 4*3 to Cell #4
 8         >+              Add 4 to Cell #5
 9         <<<<-           Decrement the loop counter in Cell #1
10     ]                   Loop till Cell #1 is zero
11     >+                  Add 1 to Cell #2
12     >+                  Add 1 to Cell #3
13     >-                  Subtract 1 from Cell #4
14     >>+                 Add 1 to Cell #6
15     [<]                 Move back to the first zero cell you find; this will
16                         be Cell #1 which was cleared by the previous loop
17     <-                  Decrement the loop Counter in Cell #0
18 ]                       Loop till Cell #0 is zero
19 
20 The result of this is:
21 Cell No :   0   1   2   3   4   5   6
22 Contents:   0   0  72 104  88  32   8
23 Pointer :   ^
24 
25 >>.                     Cell #2 has value 72 which is 'H'
26 >---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
27 +++++ ++..+++.          Likewise for 'llo' from Cell #3
28 >>.                     Cell #5 is 32 for the space
29 <-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
30 <.                      Cell #3 was set to 'o' from the end of 'Hello'
31 +++.----- -.----- ---.  Cell #3 for 'rl' and 'd'
32 >>+.                    Add 1 to Cell #5 gives us an exclamation point
33 >++.                    And finally a newline from Cell #6

The same program in minimised form:

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

The main problem is having enough RAM. Writing brainfuck as an interpreter would take up RAM, and writing a compiler would require the 2600 to /write/ the program somewhere on the cart, and that may be possible with some extra bankswitched SRAM or some sort of non-volatile RAM?

Anyway I just wanted to bring this idea I had up to see if anyone found it interesting.

  • Like 1
Link to comment
Share on other sites

I'm actually thinking of doing some YouTube videos on how to learn 6502 assembly for making 2600 games.

 

In my experience, I don't think 6502 assembly is that difficult.

 

Most of the time you're just storing, loading, and branching. It's not that hard.

 

Anyway some lectures/tutorials would easily help more people grasp the concepts.

Edited by vidak
  • Like 4
Link to comment
Share on other sites

True - I'd like people to understand what they're doing, though.

 

Batari BASIC really is a great way to get going really quickly, though.

 

Most programming now is all about doing the most you can in the minimum amount of lines. Assembly is NOTHING like that.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...