-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new code test files, adds new interpreter (32bit only right now)
- Loading branch information
Showing
14 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* div and mod ==> d := a mod b */ | ||
int a; | ||
int b; | ||
int c; | ||
int d; | ||
|
||
/* int a; 25*/ | ||
/* int b; 3*/ | ||
/* int c; */ | ||
int x; | ||
int y; | ||
|
||
int mod; | ||
int div; | ||
|
||
/* 25 */ | ||
read(a); | ||
/* 3*/ | ||
read(b); | ||
if (a < 0) { a = -a; print(a);} else{}; | ||
if (b < 0) { b = -b; print(b);} else{}; | ||
c = a / b; | ||
d = a - (c * b); | ||
|
||
print (d); | ||
print(1); | ||
|
||
/* */ | ||
/* */ | ||
/* Teil II */ | ||
/* */ | ||
/* */ | ||
|
||
/* berechnet a^b % c | ||
|
||
int a; | ||
int b; | ||
int c; | ||
int x; | ||
int y; | ||
|
||
int mod; | ||
int div; */ | ||
|
||
/* 33 */ | ||
read(a); | ||
/* 5 */ | ||
read(b); | ||
/*127*/ | ||
read(c); | ||
|
||
x=1; | ||
y=a; | ||
while(0 < b){ | ||
/* b % 2 */ | ||
div = b/2; | ||
mod = b - (div * 2); | ||
if (mod = 1){ | ||
/* (x*y)%c */ | ||
div = (x*y)/c; | ||
mod = (x*y) - (div * c); | ||
x = mod; | ||
} else {}; | ||
/* (y*y)%c */ | ||
div = (y*y)/c; | ||
mod = (y*y) - (div * c); | ||
y = mod; /* squaring the base*/ | ||
b = b / 2; | ||
}; | ||
/* x % c */ | ||
div = x/c; | ||
mod = x - (div * c); | ||
|
||
print(mod); | ||
print(89); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* ggt (a,b) */ | ||
int a; | ||
int b; | ||
int c; | ||
int d; | ||
|
||
int x; | ||
int y; | ||
int ggt; | ||
|
||
int r0; | ||
int r1; | ||
|
||
int p0; | ||
int p1; | ||
|
||
int q0; | ||
int q1; | ||
|
||
int u; | ||
|
||
|
||
/* 1045 */ | ||
read(a); | ||
/* 335 */ | ||
read(b); | ||
if (a < 0) a = -a else{}; | ||
if (b < 0) b = -b else{}; | ||
|
||
while ( 0 < b ){ | ||
d = a / b; | ||
c = a - (d * b); /* c = a mod b */ | ||
a = b; | ||
b = c; | ||
}; | ||
print (a); | ||
print (5); | ||
|
||
|
||
|
||
/* Teil II */ | ||
/* x*a + y*b = ggt(a,b) */ | ||
|
||
/* 1045 */ | ||
read(a); | ||
if (a < 0) { | ||
a = -a; | ||
print(a); | ||
}else{}; | ||
|
||
/* 335 */ | ||
read(b); | ||
if (b < 0) { | ||
b = -b; | ||
print(b); | ||
}else{}; | ||
|
||
r0 = a; | ||
r1 = b; | ||
p0 = 0; | ||
p1 = 1; | ||
q0 = 1; | ||
q1 = 0; | ||
|
||
while ( (0 < r0) & (0 < r1) ){ | ||
print(r0); | ||
print(r1); | ||
u = r0 / r1; | ||
r0 = r0 - (u * r1); /* r0 = r0 mod r1 */ | ||
p0 = (u * p1) + p0; | ||
q0 = (u * q1) + q0; | ||
|
||
if ( 0 < r0 ) { | ||
u = r1 / r0; | ||
r1 = r1 - (u * r0); /* r0 = r0 mod r1 */ | ||
p1 = (u * p0) + p1; | ||
q1 = (u * q0) + q1; | ||
} else {}; | ||
}; | ||
|
||
if (r0 = 0){ | ||
ggt = r1; | ||
x = -q1; | ||
y = p1; | ||
} else { | ||
ggt = r0; | ||
x = q0; | ||
y = -p0; | ||
}; | ||
|
||
|
||
print(ggt); | ||
print(5); | ||
print(x); | ||
print(-25); | ||
print(y); | ||
print(78); | ||
print(((-25) * 1045) + (78 * 335)); | ||
print(5); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* div and mod ==> d := a mod b */ | ||
int a; | ||
int b; | ||
int c; /* test *//* asd */ | ||
int d; | ||
|
||
/* int a; 25 */ | ||
/* int b; 3 */ | ||
/* int c; */ | ||
int x; | ||
int y; | ||
|
||
int mod; | ||
int div; | ||
|
||
/* 25 */ | ||
read(a); | ||
/* 3*/ | ||
read(b); | ||
if (a < 0) { a = -a; print(a);} else{}; | ||
if (b < 0) { b = -b; print(b);} else{}; | ||
c = a / b; | ||
d = a - (c * b); | ||
|
||
print (d); | ||
print(1); | ||
|
||
/* */ | ||
/* */ | ||
/* Teil II */ | ||
/* */ | ||
/* */ | ||
|
||
/* berechnet a^b % c | ||
|
||
int a; | ||
int b; | ||
int c; | ||
int x; | ||
int y; | ||
|
||
int mod; | ||
int div; */ | ||
|
||
/* 33 */ | ||
read(a); | ||
/* 5 */ | ||
read(b); | ||
/*127*/ | ||
read(c); | ||
|
||
x=1; | ||
y=a; | ||
while(0 < b){ | ||
/* b % 2 */ | ||
div = b/2; | ||
mod = b - (div * 2); | ||
if (mod = 1){ | ||
/* (x*y)%c */ | ||
div = (x*y)/c; | ||
mod = (x*y) - (div * c); | ||
x = mod; | ||
} else {}; | ||
/* (y*y)%c */ | ||
div = (y*y)/c; | ||
mod = (y*y) - (div * c); | ||
y = mod; /* squaring the base*/ | ||
b = b / 2; | ||
}; | ||
/* x % c */ | ||
div = x/c; | ||
mod = x - (div * c); | ||
|
||
print(mod); | ||
print(89); | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
int i; | ||
int d; | ||
int r; | ||
int args; | ||
|
||
print(r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
int a; | ||
int b; | ||
int c; | ||
int d; | ||
|
||
|
||
a = 2; | ||
b = 4; | ||
d = 2; | ||
c = (a * b) - d; | ||
d = b / a; | ||
|
||
c = c + (b / a); | ||
print(c); | ||
print(d); | ||
|
||
/* | ||
a = 0; | ||
b = 0; | ||
c = 1000; | ||
|
||
while( (a < 10) & (b < 10)) | ||
{ | ||
print(a); | ||
print(b); | ||
a = a + 1; | ||
b = b + 1; | ||
}; | ||
|
||
print(c); | ||
|
||
|
||
a = 10; | ||
b = 0; | ||
|
||
if( 0 < a) | ||
{ | ||
print(a); | ||
}; | ||
|
||
|
||
*/ |
Binary file not shown.