instruction set
category: general [glöplog]
Following up on casey reas' talk that 0rel posted earlier; he talked there a bit about how he went on to define his work via abstract methods of constructions/specifications; well here is "instruction set":
http://instructionset.org
http://instructionset.org
Quote:
Every month some instructions appear on instructionset.org.
Instructions may be vague or specific. Your challenge is to write software to carry out the instruction.
You may pick any programming or patching language you wish, and may stretch the definition of 'programming language' and 'software' if you like.
You are encouraged to provide sourcecode under a free license of your choosing, but this is not mandatory.
If you have an idea for an instruction, please suggest it, it will have a high chance of being used.
The first set of instruction is:
Quote:
Draw a straight line and follow it
"Composition 1960 #10" by La Monte Young consists of the single instruction "draw a straight line and follow it". A fitting minimal starting point to instructionset. Please contribute your implementations.
and here is my "instruction set" for my toy-VM which I use as a test-backend for my new JIT compiler :D
0000: movic i0, <8190>
0006: movii i1, i0
0009: movic i2, <0>
0015: movii i3, i2
0018: movoc o4, <$00127F28>
0024: movoo o5, o4
0027: movii i6, i2
0030: cmpi i6, i1
0033: bgt 0062
0037: bra 0041
0041: movic i7, <1>
0047: astorei ia5, i6, i7
0051: addi i6, i6, i7
0055: cmpi i6, i1
0058: ble 0041
0062: movii i6, i2
0065: cmpi i6, i1
0068: bgt 0167
0072: bra 0076
0076: aloadi i7, ia5, i6
0080: movic i8, <1>
0086: cmpi i7, i8
0089: bne 0156
0093: movic i7, <3>
0099: addi i9, i6, i7
0103: addi i10, i6, i9
0107: addi i9, i6, i10
0111: movii i11, i9
0114: cmpi i11, i1
0117: bgt 0140
0121: bra 0125
0125: astorei ia5, i11, i2
0129: addi i11, i11, i10
0133: cmpi i11, i1
0136: ble 0125
0140: addi i3, i3, i8
0144: storesic sp[4], i3
0148: storesic sp[24], i10
0152: storesic sp[32], i11
0156: addi i6, i6, i8
0160: cmpi i6, i1
0163: ble 0076
0167: storei [0x0012FF28], i3
0173: halt
(Eratosthenes sieve prime number calculation)
JSYK.
p.s.: there seems to be a bug in the pouet "code" tag..could not use it with that code..
p.p.s: just got it working so I could not resist posting it when seeing the topic :D
0000: movic i0, <8190>
0006: movii i1, i0
0009: movic i2, <0>
0015: movii i3, i2
0018: movoc o4, <$00127F28>
0024: movoo o5, o4
0027: movii i6, i2
0030: cmpi i6, i1
0033: bgt 0062
0037: bra 0041
0041: movic i7, <1>
0047: astorei ia5, i6, i7
0051: addi i6, i6, i7
0055: cmpi i6, i1
0058: ble 0041
0062: movii i6, i2
0065: cmpi i6, i1
0068: bgt 0167
0072: bra 0076
0076: aloadi i7, ia5, i6
0080: movic i8, <1>
0086: cmpi i7, i8
0089: bne 0156
0093: movic i7, <3>
0099: addi i9, i6, i7
0103: addi i10, i6, i9
0107: addi i9, i6, i10
0111: movii i11, i9
0114: cmpi i11, i1
0117: bgt 0140
0121: bra 0125
0125: astorei ia5, i11, i2
0129: addi i11, i11, i10
0133: cmpi i11, i1
0136: ble 0125
0140: addi i3, i3, i8
0144: storesic sp[4], i3
0148: storesic sp[24], i10
0152: storesic sp[32], i11
0156: addi i6, i6, i8
0160: cmpi i6, i1
0163: ble 0076
0167: storei [0x0012FF28], i3
0173: halt
(Eratosthenes sieve prime number calculation)
JSYK.
p.s.: there seems to be a bug in the pouet "code" tag..could not use it with that code..
p.p.s: just got it working so I could not resist posting it when seeing the topic :D
glBegin(GL_LINES);
glVertex3F(0,0,0);
glVertex3F(1,0,0);
glEnd();
glVertex3F(0,0,0);
glVertex3F(1,0,0);
glEnd();
Code:
#define STRAIGHT 0
class Thing
{
public:
Thing( int a ) : attribute( a ) {}
virtual bool draw() = 0;
virtual Thing * follow() = 0;
protected:
int attribute;
};
class Line : public Thing
{
public:
Line( int a ) : Thing( a ) {}
virtual bool draw()
{
// todo
return true;
}
virtual Thing * follow()
{
// todo
return this;
}
};
int main()
{
Thing *the = new Line( STRAIGHT ) ;
while( the && the->draw() )
{
the = the->follow();
}
if( the ) delete the;
return 0;
}
[[-]>[-]<++++++++++[>++++++++++<-]+.[-]+]
stefan what does that say? that's completely fucked.
It can be BrainFuck .... or just look like brainfuck