Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 03:40:09 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Poll
Question: Should I change the letter commands to symbols ($, %, &, etc.) or leave them as letters?
Keep as letters - 0 (0%)
Change to symbols - 1 (100%)
Total Voters: 1

Pages: [1]   Go Down
  Print  
Author Topic: Spyrodecimal - esolang -  (Read 579 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« on: 08 January, 2012, 22:48:13 »
0

First off, esolang is short for esoteric programming language.
Spyrodecimal is an esolang where all the commands are numbers.

Here are all the commands:

0 - Pauses the program for 1/10 second.
1 - Prints the ASCII equivalent of the number in memory.
n - Prints the actual number in memory.
2 - Increases the number in memory.
3 - Decreases the number in memory.
4 - Gets one character of input, and stores it in memory.
5 - Prints a new line.
6 - Generates a random number between 1 and 256 and stores it in memory.
7 - Moves the program reader back for the amount in memory. For example, if 5 is in memory, it will move back 5 spaces.
8 - Erases the memory.
9 - Same as 7, except moves the reader forward instead of backward.
q - Quits the interpreter.
x - quits the program, but not the interpreter.
s - Stores the current memory value into one of six variables (a, b, c, d, e, f). Variables are not affected by 8. Syntax (s<var> example: sa)
r - Recalls the value stored into one of six variables (a, b, c, d, e, f) and stores it in memory. Syntax (r<var> example: ra)

I'm currently working on the interpreter (in C++).
Any ideas are welcome!
« Last Edit: 10 January, 2012, 02:39:30 by Spyro543 » Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« Reply #1 on: 09 January, 2012, 00:33:45 »
0

Project Update:
Source Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <string>
#include <stdlib.h>
#include <windows.h>
using namespace std;
int loopstart = 0;
int main()
{
    cout << "Spyrodecimal Interpreter\nBy Spyro543 -- Type 'q' to exit\n------------------------\n";
    string prgm;
    signed int mem = 0;
    bool loop = false;
    while (true)
    {
        cout << ">>> ";
        cin >> prgm;
        for (int i=0;i < prgm.length();i++)
        {
            char data = prgm[i];
            switch (data)
            {
                case '0':
                Sleep(0.1);
                break;
                case '1':
                if (prgm[i+1]=='n') cout << mem;
                else cout << (char)mem;
                break;
                case '2':
                mem++;
                break;
                case '3':
                mem--;
                break;
                case '4':
                char inp;
                mem = 0;
                cin >> inp;
                mem = (int)inp;
                break;
                case '5':
                cout << "\n";
                break;
                case '6':
                mem = rand() % 256 + 1;
                break;
                case '7':
                loop = false;
                loopstart = i;
                break;
                case '8':
                mem = 0;
                break;
                case '9':
                if (loop==true)
                {
                    i++;
                    loop = false;
                }
                else
                {
                i = loopstart;
                loop = true;
                }
                break;
                case 'q':
                return 0;
                break;
                case 'n':
                break;
                default:
                cout << "\nUnknown command...\n";
            }
        }
        cout << "\nProgram finished.\n";
    }
}
CPP file and executable attached to this post. I'm still having a little trouble with the 7's and 9's (also, the 7 has to be before the 9).

* spyrodec.cpp (1.96 KB - downloaded 21 times.)
* spyrodec.exe (889.06 KB - downloaded 19 times.)
« Last Edit: 09 January, 2012, 02:33:43 by Spyro543 » Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Juju
Evil Fluttershy (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 23:48:21
Date Registered: 17 March, 2010, 07:46:57
Location: Québec, North Equestria
Posts: 4625


Total Post Ratings: +401

View Profile WWW
« Reply #2 on: 09 January, 2012, 19:08:45 »
0

Haha nice!

Calc version soon?
Logged

LuaIDE
Reuben Quest HD: The PC Remake
Zarmina Project: Play Read
Nspire I/O: Info Download


THEGAME
Spoiler for Other stuff:
Also Yuki "ジュジュ" Kagayaki
Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads
Find what P+4zJ means and you get free candy! cc4daa9c4645bd123ed22e385ed701fd
#omnimaga on OmniNet, EFNet and Pesterchum
Omnimaga Owner and Former Administrator
Fan of My Little Jim Bauwens: Losing the Game is Magic
Proud member of POLN - Ponys Oppositing Lol Names
Member of OBEL - Omnimaga Board of the EFnrgelnicshh Language - Office Omnimagois de la Langue FArnagnlçaaiiss
あなたはこのゲームを失った
Spoiler for Old spoileryception stuff:

Spoiler for Coming soon...:
Indefinitely halted [|.........] 10%
OmnomIRC Mobile [||||......] 40% (argh threads >_<)
Spoiler for Current/Past TI-related projects:
The Axe Parser Wiki / Founder and maintainer
Keytar Hero [|||||_____] 50% Engine done, wackiness left to do (Halted)
OmniOS
VVVVVV [||||______] 40% (Made most of the engine, extremely glitchy) (Gave it to Leafy)
░█▀█░█░█░█▀▀░█▀█░█▀█░█▀█░▀█▀░█▀▄
░█▀█░▄▀▄░█▀▀░█▀█░█░█░█░█░░█░░█░█
v0.1.0
░▀░▀░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀░[|||||||||¦] 95ish% (Completed)
tilibs-wii? [._________] 0% (Nope.)
Spoiler for Spoilers:
<!---->
wxWabbitemu Developer
Spoiler for Other Userbars:






<!--Everything done, got 90% Cheesy sudo apt-get install z80asm z80dasm-->
Spoiler for Quote:
We are in 2034. The situation on Earth is catastrophic. The ozone layer has been completely destroyed by the carbonic gas of automobiles, the chemical industries, and the poosh-poosh in little cans. In the end, the earth cooks under the rays of the sun. We must find a planet on which can live 6 billion idiots. The planetary federation turns to the strongest country in the world: Canada. It is Canadian knowledge that has allowed, on October 28, 2034, the launch of the spaceship Romano Fafard, which leaves earth to search the confines of the Universe. Where the hand of man has never set foot.
I hate TI right now
Quote from: jimbauwens
You make me lose the game
Everytime I read your name
Spoiler for The real answer to life, the universe and everything:
Spoiler for Old HTML stuff:
<div style="margin:20px; margin-top:5px"><div class="smallfont" style="margin-bottom:2px">Spoiler for This is another spoiler: <input type="button" value="Show" style="width:60px;font-size:10px;margin:0px;padding:0px;" onclick="window.location.replace('http://goo.gl/QMET');"></div><div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;"><div style="display: none; ">HAHAHA SUCCESSFUL RICKROLL IS SUCCESSFUL</div></div></div><!-- old avatars:
http://fc00.deviantart.net/fs71/f/2011/120/d/f/nepeta_nyan_cat_by_supuru-d3f8tcx.gif
http://th01.deviantart.net/fs70/PRE/i/2011/099/5/b/rainbow_dash_derping_by_moongazeponies-d3dmg7l.png
http://25.media.tumblr.com/tumblr_lqhvmtSIwo1qm2frqo1_1280.png--><!---->
I may or may not be inactive during work hours (9AM to 5PM EST, Monday to Friday), so for any inquiries please leave a message after the beep and I'll answer you when I have time. Beep. Nevermind, I'm on vacation now. Cheesy
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« Reply #3 on: 09 January, 2012, 22:22:05 »
0

Haha nice!

Calc version soon?
Maybe, if I can figure out how to get string formatting in TI-BASIC like I did with C++.
Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« Reply #4 on: 09 January, 2012, 22:47:38 »
0

Another Project Update!!!
The roles of  7 and 9 have changed:
7 - Ignores everything until the next 7. (Could allow for comments?)
9 - Repeats the command before it once.
And a new command has been added:
x - quits the program, but not the interpreter.
Here's the source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <string>
#include <stdlib.h>
#include <windows.h>
using namespace std;
int loopstart = 0;
int main()
{
    cout << "Spyrodecimal Interpreter\nBy Spyro543 -- Type 'q' to exit\n------------------------\n";
    string prgm;
    signed int mem = 0;
    int pos = 0;
    char data;
    bool ignore = false;
    bool repeat = false;
    while (true)
    {
        cout << ">>> ";
        cin >> prgm;
        for (int i=0;i < prgm.length();i++)
        {
            data = prgm[i];
            if (ignore==true)
            {
                if (data=='7')
                {
                    ignore = false;
                }
            }
            else
            {
                switch (data)
                {
                    case '0':
                    Sleep(100);
                    break;
                    case '1':
                    if (prgm[i+1]=='n') cout << mem;
                    else cout << (char)mem;
                    break;
                    case '2':
                    mem++;
                    break;
                    case '3':
                    mem--;
                    break;
                    case '4':
                    char inp;
                    mem = 0;
                    cin >> inp;
                    mem = (int)inp;
                    break;
                    case '5':
                    cout << "\n";
                    break;
                    case '6':
                    mem = rand() % 256 + 1;
                    break;
                    case '7':
                    ignore = true;
                    break;
                    case '8':
                    mem = 0;
                    break;
                    case '9':
                    if (repeat==false)
                    {
                        i--;
                        repeat = true;
                    }
                    else if (repeat==true)
                    {
                        repeat = false;
                    }
                    break;
                    case 'q':
                    return 0;
                    break;
                    case 'n':
                    break;
                    case 'x':
                    goto end;
                    break;
                    default:
                    break;
                }
            }
        }
        end:
        cout << "\nProgram finished.\n";
    }
}
Attached are the source file and executable.

* spyrodec.cpp (2.47 KB - downloaded 17 times.)
* spyrodec.exe (889.06 KB - downloaded 16 times.)
« Last Edit: 09 January, 2012, 23:07:57 by Spyro543 » Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Juju
Evil Fluttershy (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 23:48:21
Date Registered: 17 March, 2010, 07:46:57
Location: Québec, North Equestria
Posts: 4625


Total Post Ratings: +401

View Profile WWW
« Reply #5 on: 09 January, 2012, 23:13:17 »
0

Well, you could use hexadecimal instead of using letters that isn't numbers. Suggestion like this. Plus you could store your program in a BigNum and crypt stuff in decimal or use nib{ in Axe (if you want to "compile" programs). Therefore keeping the idea of an entierely decimal language.
« Last Edit: 09 January, 2012, 23:17:40 by Juju » Logged

LuaIDE
Reuben Quest HD: The PC Remake
Zarmina Project: Play Read
Nspire I/O: Info Download


THEGAME
Spoiler for Other stuff:
Also Yuki "ジュジュ" Kagayaki
Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads
Find what P+4zJ means and you get free candy! cc4daa9c4645bd123ed22e385ed701fd
#omnimaga on OmniNet, EFNet and Pesterchum
Omnimaga Owner and Former Administrator
Fan of My Little Jim Bauwens: Losing the Game is Magic
Proud member of POLN - Ponys Oppositing Lol Names
Member of OBEL - Omnimaga Board of the EFnrgelnicshh Language - Office Omnimagois de la Langue FArnagnlçaaiiss
あなたはこのゲームを失った
Spoiler for Old spoileryception stuff:

Spoiler for Coming soon...:
Indefinitely halted [|.........] 10%
OmnomIRC Mobile [||||......] 40% (argh threads >_<)
Spoiler for Current/Past TI-related projects:
The Axe Parser Wiki / Founder and maintainer
Keytar Hero [|||||_____] 50% Engine done, wackiness left to do (Halted)
OmniOS
VVVVVV [||||______] 40% (Made most of the engine, extremely glitchy) (Gave it to Leafy)
░█▀█░█░█░█▀▀░█▀█░█▀█░█▀█░▀█▀░█▀▄
░█▀█░▄▀▄░█▀▀░█▀█░█░█░█░█░░█░░█░█
v0.1.0
░▀░▀░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀░[|||||||||¦] 95ish% (Completed)
tilibs-wii? [._________] 0% (Nope.)
Spoiler for Spoilers:
<!---->
wxWabbitemu Developer
Spoiler for Other Userbars:






<!--Everything done, got 90% Cheesy sudo apt-get install z80asm z80dasm-->
Spoiler for Quote:
We are in 2034. The situation on Earth is catastrophic. The ozone layer has been completely destroyed by the carbonic gas of automobiles, the chemical industries, and the poosh-poosh in little cans. In the end, the earth cooks under the rays of the sun. We must find a planet on which can live 6 billion idiots. The planetary federation turns to the strongest country in the world: Canada. It is Canadian knowledge that has allowed, on October 28, 2034, the launch of the spaceship Romano Fafard, which leaves earth to search the confines of the Universe. Where the hand of man has never set foot.
I hate TI right now
Quote from: jimbauwens
You make me lose the game
Everytime I read your name
Spoiler for The real answer to life, the universe and everything:
Spoiler for Old HTML stuff:
<div style="margin:20px; margin-top:5px"><div class="smallfont" style="margin-bottom:2px">Spoiler for This is another spoiler: <input type="button" value="Show" style="width:60px;font-size:10px;margin:0px;padding:0px;" onclick="window.location.replace('http://goo.gl/QMET');"></div><div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;"><div style="display: none; ">HAHAHA SUCCESSFUL RICKROLL IS SUCCESSFUL</div></div></div><!-- old avatars:
http://fc00.deviantart.net/fs71/f/2011/120/d/f/nepeta_nyan_cat_by_supuru-d3f8tcx.gif
http://th01.deviantart.net/fs70/PRE/i/2011/099/5/b/rainbow_dash_derping_by_moongazeponies-d3dmg7l.png
http://25.media.tumblr.com/tumblr_lqhvmtSIwo1qm2frqo1_1280.png--><!---->
I may or may not be inactive during work hours (9AM to 5PM EST, Monday to Friday), so for any inquiries please leave a message after the beep and I'll answer you when I have time. Beep. Nevermind, I'm on vacation now. Cheesy
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« Reply #6 on: 10 January, 2012, 02:41:42 »
0

MORE UPDATES!!!

Source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <string>
#include <stdlib.h>
#include <windows.h>
using namespace std;
int loopstart = 0;
int main()
{
    cout << "Spyrodecimal Interpreter\nBy Spyro543 -- Type 'q' to exit\n------------------------\n";
    string prgm;
    signed int mem = 0;
    int pos = 0;
    char data;
    signed int a = 0;
    signed int b = 0;
    signed int c = 0;
    signed int d = 0;
    signed int e = 0;
    signed int f = 0;
    char var;
    while (true)
    {
        cout << ">>> ";
        cin >> prgm;
        for (int i=0;i < prgm.length();i++)
        {
            data = prgm[i];
            switch (data)
            {
                case '0':
                Sleep(100);
                break;
                case '1':
                cout << (char)mem;
                break;
                case '2':
                mem++;
                break;
                case '3':
                mem--;
                break;
                case '4':
                char inp;
                mem = 0;
                cin >> inp;
                mem = (int)inp;
                break;
                case '5':
                cout << "\n";
                break;
                case '6':
                mem = rand() % 256 + 1;
                break;
                case '7':
                i -= mem;
                break;
                case '8':
                mem = 0;
                break;
                case '9':
                i += mem;
                break;
                case 'q':
                return 0;
                break;
                case 'n':
                cout << mem;
                break;
                case 'x':
                goto end;
                break;
                case 'r':
                var = prgm[i+1];
                if (var=='a') mem = a;
                else if (var=='b') mem = b;
                else if (var=='c') mem = c;
                else if (var=='d') mem = d;
                else if (var=='e') mem = e;
                else if (var=='f') mem = f;
                break;
                case 's':
                var = prgm[i+1];
                if (var=='a') a = mem;
                else if (var=='b') b = mem;
                else if (var=='c') c = mem;
                else if (var=='d') d = mem;
                else if (var=='e') e = mem;
                else if (var=='f') f = mem;
                break;
                default:
                break;
            }
        }
        end:
        cout << "\nProgram finished.\n";
    }
}
Look at the first post, 1n is now n, s and r commands are added, and 7 and 9 are changed.
Download links:
Source: http://anova.57o9.org/junk/spd/spyrodec.cpp
EXE: http://anova.57o9.org/junk/spd/spyrodec.exe

This update takes Spyrodecimal one step further to becoming Turing complete!
« Last Edit: 10 January, 2012, 02:42:21 by Spyro543 » Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Nick
LV9 Veteran (Next: 1337)
*********
Offline Offline

Gender: Male
Last Login: 28 May, 2013, 18:19:14
Date Registered: 05 June, 2011, 20:01:07
Location: 51° 12′ 34″ N, 3° 13′ 31″ E
Posts: 1179


Total Post Ratings: +158

View Profile WWW
« Reply #7 on: 10 January, 2012, 19:50:45 »
0

but if i understand it correct, you can only have one goto and one label, or not?

and btw, i voted for change to symbols, since i think it might get too complicated when using variables..
« Last Edit: 10 January, 2012, 19:53:00 by Nick » Logged

compu
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: Yesterday at 19:00:46
Date Registered: 09 January, 2011, 22:45:52
Location: Germany
Posts: 229

Total Post Ratings: +53

View Profile
« Reply #8 on: 12 January, 2012, 21:22:47 »
0

Here is my try at a small interpreted language Smiley

It has one variable for operations (like your memory, I call it register), 256 labels and 2048 bytes of memory where you can read and write from.

Spoiler for Commands:
d      Enable/disable debug mode
n      Print new line
i      Get char from keyboard
p      Print char
I      Get number from keyboard
P      Print number
k        Immediately get char from keyboard (doesn't wait for enter) without local echo
t      Generate random number
lX      Create label X
jX      Jump to label X
sX      Store register to X, where X must be one printable character, e.g. 12 wouldn't work. This means, you can't access all 2048 bytes through this command, you will have to use SX and RX
rX      Restore X to register
SX      Store register to the address stored in X (like a pointer)
RX      Restore value at the address stored in X to register
1      Increment register
2      Decrement register
+X      register = register + value at X
-X      register = register - value at X
*X      register = register * value at X
/X      register = register / value at X
x      Clear register
=X      Store X (=88) in register
?XY      If-Clause
      X --> =      register == Y
      X --> !      register != Y
      X --> >      register >  Y
      X --> <      register <  Y
;      Ends If-Clause (and btw, at the moment nested Ifs don't work at all)

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <iostream>
#include <conio.h>
#include <string.h>
#include <string>
#include <windows.h>
#include <time.h>

using namespace std;

int main(void)
{
int memory[2048];
int label[256];
int reg;
int deep;
bool ignore = false;
bool debug = false;
char tmp;
srand((unsigned)time(NULL));
while(true)
{
string program;
cout << endl << ">>>";
cin >> program;
memset(memory,0,2048*sizeof(int));
memset(label,0,256*sizeof(int));
reg = 0;
deep = 0;
for (int i=0; i < program.length(); i++)
{
if(program[i] == 'l')
{
label[program[i+1]] = i+1;
if(debug) cout << "Label " << program[i+1] << " at " << i+1 << endl;
}
}
for (int i=0; i < program.length(); i++)
{
if(ignore && program[i] != ';') continue;
else ignore = false;
if(debug) cout << "op=" << program[i] << ", pos=" << i << ", reg=" << reg << " (" << (char)reg << ")" << endl;
switch(program[i])
{
case 'd':
debug = !debug;
if(debug) cout << "\tdebug=" << debug << endl;
break;
case 'n':
cout << endl;
break;
case 'i':
if(debug) cout << "\tinput ";
cin >> tmp;
reg = tmp;
break;
case 'p':
if(debug) cout << "\tprint " << (char)reg << endl;
else cout << (char)reg;
break;
case 'I':
if(debug) cout << "\tinput ";
cin >> reg;
break;
case 'P':
if(debug) cout << "\tprint " << reg << endl;
else cout << reg;
break;
case 'k':
reg = getch();
break;
case 't':
reg = rand();
if(debug) cout << "\trand=" << (int)reg << endl;
break;
case 'j':
if(debug) cout << "\tlabel=" << program[i+1] << ", pos=" << label[program[i+1]] << endl;
i = label[program[i+1]];
break;
case 's':
memory[program[i+1]] = reg;
i++;
if(debug) cout << "\tmemory(" << program[i] << ")=" << reg << endl;
break;
case 'r':
reg = memory[program[i+1]];
i++;
if(debug) cout << "\tmemory(" << program[i] << ")=" << reg << endl;
break;
case 'S':
memory[memory[program[i+1]]] = reg;
i++;
break;
case 'R':
//cout << program[i+1] << "," << memory[program[i+1]] << "," << memory[memory[program[i+1]]] << endl;
reg = memory[memory[program[i+1]]];
i++;
break;
case '1':
reg++;
break;
case '2':
reg--;
break;
case '+':
if(debug) cout << "\treg=" << reg << ", memory(" << program[i+1] << ")=" << memory[program[i+1]] << ", add=" << reg + memory[program[i+1]] << endl;
reg = reg + memory[program[i+1]];
i++;
break;
case '-':
if(debug) cout << "\treg=" << reg << ", memory(" << program[i+1] << ")=" << memory[program[i+1]] << ", subtract=" << reg - memory[program[i+1]] << endl;
reg = reg - memory[program[i+1]];
i++;
break;
case '/':
if(debug) cout << "\treg=" << reg << ", memory(" << program[i+1] << ")=" << memory[program[i+1]] << ", divide=" << reg / memory[program[i+1]] << endl;
reg = reg / memory[program[i+1]];
i++;
break;
case '*':
if(debug) cout << "\treg=" << reg << ", memory(" << program[i+1] << ")=" << memory[program[i+1]] << ", multiply=" << reg * memory[program[i+1]] << endl;
reg = reg * memory[program[i+1]];
i++;
break;
case 'x':
reg = 0;
break;
case '=':
reg = program[i+1];
i++;
break;
case '?':
if(program[i+1] == '=')
{
if(reg == memory[program[i+2]]) ignore = false;
else ignore = true;
}
else if(program[i+1] == '!')
{
if(reg != memory[program[i+2]]) ignore = false;
else ignore = true;
}
else if(program[i+1] == '>')
{
if(reg > memory[program[i+2]]) ignore = false;
else ignore = true;
}
else if(program[i+1] == '<')
{
if(reg < memory[program[i+2]]) ignore = false;
else ignore = true;
}
if(debug) cout << "\tif reg " << program[i+1] << " memory(" << program[i+2] << ") --> " << ignore << endl;
i += 2;
break;
default:
break;
}
}
}
}

A simple and documented Guess the number:
Spoiler for Code:
t                            // Create random number
sa                            // Save it in a
lA                            // Label A
   rc                         // Get c (number of guesses)
   1                         // Increment c
   sc                         // Store c
   =Np=up=mp=bp=ep=rp=?p          // Print "Number?"
   I                         // Input number
   sb                         // Store it in b
   ?>a                      // register > a?
      =Sp=mp=ap=lpp=ep=rpn       // Print "Smaller"
      rb                      // Restore b
      jA                      // Repeat
   ;                         // If-End
   ?<a                      // register < a?
      =Bp=ip=gpp=ep=rpn          // Print "Bigger"
      rb                      // Restore b
      jA                      // Repeat
   ;                         // If-End
   ?=a                      // register == a?
      =Cp=op=rpp=ep=cp=tp=!p       // Print "Correct!"
      n                      // new line
      =Tp=rp=ip=ep=sp=:p          // Print "Tries:"
      rc                      // Get c (number of guesses)
      P                      // Print number of guesses
   ;                         // If-End


Resulting program:
tsalArc1sc=Np=up=mp=bp=ep=rp=?pIsb?>a=Sp=mp=ap=lpp=ep=rpnrbjA;?<a=Bp=ip=gpp=ep=rpnrbjA;?=a=Cp=op=rpp=ep=cp=tp=!pn=Tp=rp=ip=ep=sp=:prcP;

And a brainfuck interpreter Grin (won't work with nested loops)
Spoiler for Code:
=d // 100
sA // A = instruction pointer, points to 100

=! // 33
sB
*B // 33 * 33 = 1089
sB // memory pointer, points to 1089

=A // 65
sC
=N // 78
-C // 78 - 65 = 13, CR
sC // C holds CR

lA // Program read loop
k // Read char
p // Local echo
?!C // Char = CR?
   SA // Store in instruction pointer target
   rA
   1 // Increment insctruction pointer
   sA
   jA // loop end
; // End of program read loop

n

=d
sA // Reset instruction pointer
lB // Main loop start

=> // Brainfuck: Increments Pointer.
sE // Opcode buffer
RA // Get instruction
?=E
   rB
   1
   sB
;

=< // Brainfuck: Decrements Pointer.
sE
RA
?=E
   rB
   2
   sB
;

=+ // Brainfuck: Increments Pointer Target.
sE
RA
?=E
   RB
   1
   SB
;

=- // Brainfuck: Decrements Pointer Target.
sE
RA
?=E
   RB
   2
   SB
;

=. // Brainfuck: Prints Pointer Target.
sE
RA
?=E
   RB
   p
;

=, // Brainfuck: Reads char.
sE
RA
?=E
   k
   p // Local echo
   SB
;

=[ // Brainfuck: Jumps after "]" if pointer target is 0
sE
RA
?=E
   RB // Get pointer target
   ?=D // = 0?
      lC // Increment instruction pointer until ] appears
      =] // Load ]
      sa
      rA
      1
      sA
      RA
      ?!a
         jC
      ;
   ;
;

=] // Brainfuck: Jumps back to "[" if pointer target nonzero
sE
RA
?=E
   RB
   ?!D // != 0?
      lD // Decrement instruction pointer until [ appears
      =[
      sa
      rA
      2
      sA
      RA
      ?!a
         jD
      ;
   ;
;

rA
1 // Increment instruction pointer
sA
RA
?!D // D should be 0
   jB
;


Resulting program:
=dsA=!sB*BsB=AsC=N-CsClAkp?!CSArA1sAjA;n=dsAlB=>sERA?=ErB1sB;=<sERA?=ErB2sB;=+sERA?=ERB1SB;=-sERA?=ERB2SB;=.sERA?=ERBp;=,sERA?=EkpSB;=[sERA?=ERB?=DlC=]sarA1sARA?!ajC;;;=]sERA?=ERB?!DlD=[sarA2sARA?!ajD;;;rA1sARA?!DjB;

Brainfuck "Hello World":
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.

* interpreter.exe (36.41 KB - downloaded 16 times.)
Logged

Nspire I/O Discussion|Website - cross-compatible with Prizm!
TI-Nspire Programming Statistics
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Topic starter
Total Post Ratings: +59

View Profile WWW
« Reply #9 on: 12 January, 2012, 22:22:41 »
0

wow that's cool Big frown
Maybe I should re-do Spyrodecimal in Python (since I know python better)
Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.455 seconds with 33 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.