lots of changes, created Disassembler class, removed a few globals etc.
This commit is contained in:
23
tests/initial_base/BENCHFN.C
Normal file
23
tests/initial_base/BENCHFN.C
Normal file
@@ -0,0 +1,23 @@
|
||||
/* benchfn - benchmark for function calls
|
||||
* Thomas Plum, Plum Hall Inc, 609-927-3770
|
||||
* Let T be the execution time in milliseconds
|
||||
* Then average time per operator = T/major usec
|
||||
* (Because the inner loop has exactly 1000 operations)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
f3() { ;}
|
||||
f2() { f3();f3();f3();f3();f3();f3();f3();f3();f3();f3();} /* 10 */
|
||||
f1() { f2();f2();f2();f2();f2();f2();f2();f2();f2();f2();} /* 10 */
|
||||
f0() { f1();f1();f1();f1();f1();f1();f1();f1();f1();} /* 9 */
|
||||
|
||||
main(int ac, char *av[])
|
||||
{ long d, major;
|
||||
|
||||
printf ("enter number of iterations ");
|
||||
scanf ("%ld", &major);
|
||||
printf("executing %ld iterations\n", major);
|
||||
for (d = 1; d <= major; ++d)
|
||||
f0(); /* executes 1000 calls */
|
||||
printf ("finished\n");
|
||||
}
|
||||
88
tests/initial_base/BENCHFN.b
Normal file
88
tests/initial_base/BENCHFN.b
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Input file : test\benchfn.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void proc_4 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void proc_3 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
proc_4 ();
|
||||
}
|
||||
|
||||
|
||||
void proc_2 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
proc_3 ();
|
||||
}
|
||||
|
||||
|
||||
void proc_1 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
proc_2 ();
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
long loc1;
|
||||
long loc2;
|
||||
|
||||
printf ("enter number of iterations ");
|
||||
scanf ("%ld", &loc0);
|
||||
printf ("executing %ld iterations\n", loc2);
|
||||
loc1 = 1;
|
||||
while ((loc1 <= loc2)) {
|
||||
proc_1 ();
|
||||
loc1 = (loc1 + 1);
|
||||
}
|
||||
printf ("finished\n");
|
||||
}
|
||||
|
||||
36
tests/initial_base/BENCHLNG.C
Normal file
36
tests/initial_base/BENCHLNG.C
Normal file
@@ -0,0 +1,36 @@
|
||||
/* benchlng - benchmark for long integers
|
||||
* Thomas Plum, Plum Hall Inc, 609-927-3770
|
||||
* If machine traps overflow, use an unsigned type
|
||||
* Let T be the execution time in milliseconds
|
||||
* Then average time per operator = T/major usec
|
||||
* (Because the inner loop has exactly 1000 operations)
|
||||
*/
|
||||
#define STOR_CL auto
|
||||
#define TYPE long
|
||||
#include <stdio.h>
|
||||
main(int ac, char *av[])
|
||||
{ TYPE a, b, c;
|
||||
long d, major;
|
||||
|
||||
scanf ("%ld", &major);
|
||||
printf("executing %ld iterations\n", major);
|
||||
scanf ("%ld", &a);
|
||||
scanf ("%ld", &b);
|
||||
for (d = 1; d <= major; ++d)
|
||||
{
|
||||
/* inner loop executes 1000 selected operations */
|
||||
for (c = 1; c <= 40; ++c)
|
||||
{
|
||||
a = a + b + c;
|
||||
b = a >> 1;
|
||||
a = b % 10;
|
||||
a = b == c;
|
||||
b = a | c;
|
||||
a = !b;
|
||||
b = a + c;
|
||||
a = b > c;
|
||||
}
|
||||
}
|
||||
printf("a=%d\n", a);
|
||||
}
|
||||
|
||||
153
tests/initial_base/BENCHLNG.b
Normal file
153
tests/initial_base/BENCHLNG.b
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Input file : test\benchlng.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
long LMOD@ (long arg0, int arg2int arg3)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* Runtime support routine of the compiler.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* Return value in registers dx:ax.
|
||||
* Pascal calling convention.
|
||||
*/
|
||||
{
|
||||
MOV cx, 2
|
||||
PUSH bp
|
||||
PUSH si
|
||||
PUSH di
|
||||
MOV bp, sp
|
||||
MOV di, cx
|
||||
MOV ax, [bp+0Ah]
|
||||
MOV dx, [bp+0Ch]
|
||||
MOV bx, [bp+0Eh]
|
||||
MOV cx, [bp+10h]
|
||||
CMP cx, 0
|
||||
JNE L1
|
||||
OR dx, dx
|
||||
JE L2
|
||||
OR bx, bx
|
||||
JE L2
|
||||
|
||||
L1: TEST di, 1
|
||||
JNE L3
|
||||
OR dx, dx
|
||||
JNS L4
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
OR di, 0Ch
|
||||
|
||||
L4: OR cx, cx
|
||||
JNS L3
|
||||
NEG cx
|
||||
NEG bx
|
||||
SBB cx, 0
|
||||
XOR di, 4
|
||||
|
||||
L3: MOV bp, cx
|
||||
MOV cx, 20h
|
||||
PUSH di
|
||||
XOR di, 0
|
||||
XOR si, 0
|
||||
|
||||
L5: SHL ax, 1
|
||||
RCL dx, 1
|
||||
RCL si, 1
|
||||
RCL di, 1
|
||||
CMP di, bp
|
||||
JB L6
|
||||
JA L7
|
||||
CMP si, bx
|
||||
JB L6
|
||||
|
||||
L7: SUB si, bx
|
||||
SBB di, bp
|
||||
INC ax
|
||||
|
||||
L6: LOOP L5
|
||||
POP bx
|
||||
TEST bx, 2
|
||||
JE L8
|
||||
MOV ax, si
|
||||
MOV dx, di
|
||||
SHR bx, 1
|
||||
|
||||
L8: TEST bx, 4
|
||||
JE L9
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
|
||||
L9: POP di
|
||||
POP si
|
||||
POP bp
|
||||
RETF 8
|
||||
|
||||
L2: MOV tmp, dx:ax ;Synthetic inst
|
||||
DIV bx
|
||||
MOD bx ;Synthetic inst
|
||||
TEST di, 2
|
||||
JE L10
|
||||
MOV ax, dx
|
||||
|
||||
L10: XOR dx, dx
|
||||
JMP L9
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
long loc1;
|
||||
long loc2;
|
||||
long loc3;
|
||||
long loc4;
|
||||
long loc5;
|
||||
int loc6; /* ax */
|
||||
|
||||
scanf ("%ld", &loc0);
|
||||
printf ("executing %ld iterations\n", loc5);
|
||||
scanf ("%ld", &loc2);
|
||||
scanf ("%ld", &loc3);
|
||||
loc3 = 1;
|
||||
while ((loc3 <= loc5)) {
|
||||
loc2 = 1;
|
||||
while ((loc2 <= 40)) {
|
||||
loc4 = ((loc4 + loc1) + loc2);
|
||||
loc1 = (loc4 >> 1);
|
||||
loc4 = LMOD@ (loc1, 10);
|
||||
if (loc1 == loc2) {
|
||||
loc6 = 1;
|
||||
}
|
||||
else {
|
||||
loc6 = 0;
|
||||
}
|
||||
loc4 = loc6;
|
||||
loc1 = (loc4 | loc2);
|
||||
if ((loc3 | loc9) == 0) {
|
||||
loc6 = 1;
|
||||
}
|
||||
else {
|
||||
loc6 = 0;
|
||||
}
|
||||
loc4 = loc6;
|
||||
loc1 = (loc4 + loc2);
|
||||
if (loc1 > loc2) {
|
||||
loc6 = 1;
|
||||
}
|
||||
else {
|
||||
loc6 = 0;
|
||||
}
|
||||
loc4 = loc6;
|
||||
loc2 = (loc2 + 1);
|
||||
}
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
printf ("a=%d\n", loc4);
|
||||
}
|
||||
|
||||
30
tests/initial_base/BENCHMUL.C
Normal file
30
tests/initial_base/BENCHMUL.C
Normal file
@@ -0,0 +1,30 @@
|
||||
/* benchmul - benchmark for int multiply
|
||||
* Thomas Plum, Plum Hall Inc, 609-927-3770
|
||||
* If machine traps overflow, use an unsigned type
|
||||
* Let T be the execution time in milliseconds
|
||||
* Then average time per operator = T/major usec
|
||||
* (Because the inner loop has exactly 1000 operations)
|
||||
*/
|
||||
#define STOR_CL auto
|
||||
#define TYPE int
|
||||
#include <stdio.h>
|
||||
main(int ac, char *av[])
|
||||
{ STOR_CL TYPE a, b, c;
|
||||
long d, major;
|
||||
|
||||
printf ("enter number of iterations\n");
|
||||
scanf ("%ld", &major);
|
||||
printf("executing %ld iterations\n", major);
|
||||
scanf ("%d", &a);
|
||||
scanf ("%d", &b);
|
||||
for (d = 1; d <= major; ++d)
|
||||
{
|
||||
/* inner loop executes 1000 selected operations */
|
||||
for (c = 1; c <= 40; ++c)
|
||||
{
|
||||
a = 3 *a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a; /* 25 * */
|
||||
}
|
||||
}
|
||||
printf("a=%d\n", a);
|
||||
}
|
||||
|
||||
36
tests/initial_base/BENCHMUL.b
Normal file
36
tests/initial_base/BENCHMUL.b
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Input file : test\benchmul.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
long loc3;
|
||||
long loc4;
|
||||
int loc5;
|
||||
|
||||
printf ("enter number of iterations\n");
|
||||
scanf ("%ld", &loc0);
|
||||
printf ("executing %ld iterations\n", loc4);
|
||||
scanf ("%d", &loc1);
|
||||
scanf ("%d", &loc2);
|
||||
loc3 = 1;
|
||||
while ((loc3 <= loc4)) {
|
||||
loc5 = 1;
|
||||
while ((loc5 <= 40)) {
|
||||
loc1 = (((((((((((((((((((((((((loc1 * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * loc1) * 3);
|
||||
loc5 = (loc5 + 1);
|
||||
}
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
printf ("a=%d\n", loc1);
|
||||
}
|
||||
|
||||
36
tests/initial_base/BENCHMUS.b
Normal file
36
tests/initial_base/BENCHMUS.b
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Input file : test\benchmus.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
long loc2;
|
||||
long loc3;
|
||||
int loc4;
|
||||
int loc5;
|
||||
|
||||
printf ("enter number of iterations\n");
|
||||
scanf ("%ld", &loc0);
|
||||
printf ("executing %ld iterations\n", loc3);
|
||||
loc4 = 20;
|
||||
loc1 = loc4;
|
||||
loc2 = 1;
|
||||
while ((loc2 <= loc3)) {
|
||||
loc5 = 1;
|
||||
while ((loc5 <= 40)) {
|
||||
loc4 = (((((((((((((((((((((((((loc4 * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * loc4) * 3);
|
||||
loc5 = (loc5 + 1);
|
||||
}
|
||||
loc2 = (loc2 + 1);
|
||||
}
|
||||
printf ("a=%d\n", loc4);
|
||||
}
|
||||
|
||||
37
tests/initial_base/BENCHSHO.C
Normal file
37
tests/initial_base/BENCHSHO.C
Normal file
@@ -0,0 +1,37 @@
|
||||
/* benchsho - benchmark for short integers
|
||||
* Thomas Plum, Plum Hall Inc, 609-927-3770
|
||||
* If machine traps overflow, use an unsigned type
|
||||
* Let T be the execution time in milliseconds
|
||||
* Then average time per operator = T/major usec
|
||||
* (Because the inner loop has exactly 1000 operations)
|
||||
*/
|
||||
#define STOR_CL auto
|
||||
#define TYPE short
|
||||
#include <stdio.h>
|
||||
|
||||
main(int ac, char *av[])
|
||||
{ STOR_CL TYPE a, b, c;
|
||||
long d, major;
|
||||
|
||||
scanf ("%ld", &major);
|
||||
printf("executing %ld iterations\n", major);
|
||||
scanf ("%ld", &a);
|
||||
scanf ("%ld", &b);
|
||||
for (d = 1; d <= major; ++d)
|
||||
{
|
||||
/* inner loop executes 1000 selected operations */
|
||||
for (c = 1; c <= 40; ++c)
|
||||
{
|
||||
a = a + b + c;
|
||||
b = a >> 1;
|
||||
a = b % 10;
|
||||
a = b == c;
|
||||
b = a | c;
|
||||
a = !b;
|
||||
b = a + c;
|
||||
a = b > c;
|
||||
}
|
||||
}
|
||||
printf("a=%d\n", a);
|
||||
}
|
||||
|
||||
55
tests/initial_base/BENCHSHO.b
Normal file
55
tests/initial_base/BENCHSHO.b
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Input file : test\benchsho.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
long loc4;
|
||||
long loc5;
|
||||
int loc6; /* ax */
|
||||
|
||||
scanf ("%ld", &loc0);
|
||||
printf ("executing %ld iterations\n", loc5);
|
||||
scanf ("%ld", &loc1);
|
||||
scanf ("%ld", &loc2);
|
||||
loc4 = 1;
|
||||
while ((loc4 <= loc5)) {
|
||||
loc3 = 1;
|
||||
while ((loc3 <= 40)) {
|
||||
loc1 = ((loc1 + loc2) + loc3);
|
||||
loc2 = (loc1 >> 1);
|
||||
loc1 = (loc2 % 10);
|
||||
if (loc2 == loc3) {
|
||||
loc6 = 1;
|
||||
}
|
||||
else {
|
||||
loc6 = 0;
|
||||
}
|
||||
loc1 = loc6;
|
||||
loc2 = (loc1 | loc3);
|
||||
loc1 = !loc2;
|
||||
loc2 = (loc1 + loc3);
|
||||
if (loc2 > loc3) {
|
||||
loc6 = 1;
|
||||
}
|
||||
else {
|
||||
loc6 = 0;
|
||||
}
|
||||
loc1 = loc6;
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
loc4 = (loc4 + 1);
|
||||
}
|
||||
printf ("a=%d\n", loc1);
|
||||
}
|
||||
|
||||
16
tests/initial_base/BYTEOPS.C
Normal file
16
tests/initial_base/BYTEOPS.C
Normal file
@@ -0,0 +1,16 @@
|
||||
#define TYPE unsigned char
|
||||
|
||||
main()
|
||||
{ TYPE a, b;
|
||||
|
||||
a = 255;
|
||||
b = 143;
|
||||
b = a + b;
|
||||
a = a - b;
|
||||
a = a * b;
|
||||
b = b / a;
|
||||
b = b % a;
|
||||
a = a << 5;
|
||||
b = b >> a;
|
||||
printf ("a = %d, b = %d\n", a, b);
|
||||
}
|
||||
28
tests/initial_base/BYTEOPS.b
Normal file
28
tests/initial_base/BYTEOPS.b
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Input file : test\byteops.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
|
||||
loc1 = 255;
|
||||
loc2 = 143;
|
||||
loc2 = (loc1 + loc2);
|
||||
loc1 = (loc1 - loc2);
|
||||
loc1 = (loc1 * loc2);
|
||||
loc2 = (loc2 / loc1);
|
||||
loc2 = (loc2 % loc1);
|
||||
loc1 = (loc1 << 5);
|
||||
loc2 = (loc2 >> loc1);
|
||||
printf ("a = %d, b = %d\n", loc1, loc2);
|
||||
}
|
||||
|
||||
223
tests/initial_base/DHAMP.C
Normal file
223
tests/initial_base/DHAMP.C
Normal file
@@ -0,0 +1,223 @@
|
||||
/* The dhampstone benchmark. Written by Jack purdum. */
|
||||
/* version 1.0, August 1,1985 */
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#define BELL 7 /* ASCII BELL code */
|
||||
#define FIB 24
|
||||
#define TINY 100
|
||||
#define MAXINT 179
|
||||
#define LITTLE 1000
|
||||
#define SMALL 9000
|
||||
#define PRECISION .000001
|
||||
#define FILENAME "zyxw.vut"
|
||||
#define NUMTEST 6
|
||||
|
||||
#ifndef ERR
|
||||
#define ERR -1
|
||||
#endif
|
||||
|
||||
struct
|
||||
{
|
||||
int cresult;
|
||||
int iresult;
|
||||
int cprsult;
|
||||
unsigned uresult;
|
||||
long lresult;
|
||||
double dresult;
|
||||
} results;
|
||||
|
||||
main()
|
||||
{
|
||||
char buf1[TINY], buf2[TINY];
|
||||
int i = 0;
|
||||
unsigned fib ();
|
||||
long square, sq ();
|
||||
double dmath, sroot (), dply ();
|
||||
|
||||
printf("Start...%c\n\n",BELL);
|
||||
while (i < NUMTEST)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case (0): /* Character test */
|
||||
results.cresult = stest (buf1,buf2);
|
||||
printf ("\ncresult = %d\n",results.cresult);
|
||||
break;
|
||||
case (1): /* Integer test */
|
||||
results.iresult = intest ();
|
||||
printf ("\niresult = %d\n",results.iresult);
|
||||
break;
|
||||
case (2): /* Unsigned test */
|
||||
results.uresult = fib (FIB);
|
||||
printf ("\nuresult = %u\n",results.uresult);
|
||||
break;
|
||||
case (3): /* Long test */
|
||||
square = 0L;
|
||||
results.lresult = sq (square);
|
||||
square = sq (results.lresult); /* Check the value */
|
||||
printf ("\nlresult = %ld",results.lresult);
|
||||
printf ("\n square = %ld\n",square);
|
||||
break;
|
||||
case (4): /* Double test */
|
||||
results.dresult = sroot ((double) results.lresult);
|
||||
printf ("\ndresult = %f\n",results.dresult);
|
||||
dmath = dply (results.dresult);
|
||||
printf (" dmath = %f\n",dmath);
|
||||
break;
|
||||
case (5): /* Disk copy */
|
||||
results.cprsult = mcopy ();
|
||||
printf ("\b copy = %d",results.cprsult);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
} /* End while i */
|
||||
printf ("\n\n...End%c",BELL);
|
||||
}
|
||||
|
||||
long sq (big) /* Function to square a number by iteration */
|
||||
long big;
|
||||
{
|
||||
int i;
|
||||
static long j = 1L;
|
||||
|
||||
if (!big)
|
||||
for (i = 0; i < SMALL; ++i)
|
||||
{
|
||||
big += j;
|
||||
j += 2;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < SMALL; ++i)
|
||||
{
|
||||
j -= 2;
|
||||
big -= j;
|
||||
}
|
||||
return (big);
|
||||
}
|
||||
|
||||
double sroot (num) /* Find square root of number */
|
||||
double num;
|
||||
{
|
||||
double temp1, temp2, abs ();
|
||||
|
||||
temp2 = num / 2.0;
|
||||
temp1 = num;
|
||||
while (temp1 > PRECISION * temp2)
|
||||
{
|
||||
temp1 = (num / temp2) - temp2;
|
||||
temp1 = abs (temp1);
|
||||
temp2 = ((num / temp2) + temp2) / 2.0;
|
||||
}
|
||||
return (temp2);
|
||||
}
|
||||
|
||||
double abs (x) /* Absolute value of a double */
|
||||
double x;
|
||||
{
|
||||
|
||||
return (x < 0 ? -x : x);
|
||||
}
|
||||
|
||||
double dply (x) /* Exercise some doubles */
|
||||
double x;
|
||||
{
|
||||
int i = TINY;
|
||||
double y;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
y = x * x * x * x * x * x * x;
|
||||
y = y / x / x / x / x / x / x;
|
||||
|
||||
y = y + x + x + x + x + x + x;
|
||||
y = y - x - x - x - x - x - x;
|
||||
}
|
||||
return (y);
|
||||
}
|
||||
|
||||
unsigned fib (x) /* Common Fibonacci function */
|
||||
int x;
|
||||
{
|
||||
|
||||
if (x > 2)
|
||||
return (fib (x-1) + fib (x-2));
|
||||
else
|
||||
return (1);
|
||||
}
|
||||
|
||||
int stest (b1,b2) /* String test using strcpy() and strcmp() */
|
||||
char *b1, *b2;
|
||||
{
|
||||
int i,j;
|
||||
void mstrcpy ();
|
||||
|
||||
for (i = 0, j = 0; i < SMALL; ++i)
|
||||
{
|
||||
mstrcpy (b1, "0123456789abcdef");
|
||||
mstrcpy (b2, "0123456789abcdee"); /* Note it's a different string. */
|
||||
j += mstrcmp (b1,b2);
|
||||
}
|
||||
return (j);
|
||||
}
|
||||
|
||||
int mstrcmp (c,d) /* External string compare */
|
||||
char *c, *d;
|
||||
{
|
||||
|
||||
while (*c == *d)
|
||||
{
|
||||
if (!*c)
|
||||
return (0);
|
||||
++c;
|
||||
++d;
|
||||
}
|
||||
return (*c - *d);
|
||||
}
|
||||
|
||||
void mstrcpy (c,d) /* External string copy */
|
||||
char *c, *d;
|
||||
{
|
||||
|
||||
while (*c++ = *d++)
|
||||
;
|
||||
}
|
||||
|
||||
int mcopy () /* Disk copy. Test assumes file doesn't exist */
|
||||
{
|
||||
FILE *fp, *fopen ();
|
||||
char buf[TINY];
|
||||
int i, j;
|
||||
|
||||
mstrcpy (buf, "Disk I/O test");
|
||||
if ((fp = fopen(FILENAME,"w")) == NULL)
|
||||
{
|
||||
printf ("Cannot open file");
|
||||
exit (ERR);
|
||||
}
|
||||
i = 0;
|
||||
while (++i < LITTLE)
|
||||
for (j = 0; buf[j]; ++j)
|
||||
putc (buf[j], fp);
|
||||
fclose (fp);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int intest () /* Square an integer by iteration */
|
||||
{
|
||||
int i, j, k, sum;
|
||||
|
||||
for (i = 0; i < LITTLE; ++i)
|
||||
{
|
||||
sum = 0;
|
||||
for (j = 0, k = 1; j < MAXINT; ++j)
|
||||
{
|
||||
sum += k;
|
||||
k += 2;
|
||||
}
|
||||
}
|
||||
return (sum);
|
||||
}
|
||||
|
||||
391
tests/initial_base/DHAMP.b
Normal file
391
tests/initial_base/DHAMP.b
Normal file
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* Input file : test\dhamp.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
int proc_2 (long arg0, long arg1)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
char loc1; /* al */
|
||||
int loc2; /* bx */
|
||||
|
||||
do {
|
||||
arg0 = (arg0 + 1);
|
||||
loc1 = es[bx];
|
||||
arg1 = (arg1 + 1);
|
||||
es[bx] = loc1;
|
||||
} while ((loc1 != 0));
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
int proc_3 (long arg0, long arg1)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1; /* ax */
|
||||
|
||||
while ((es[bx] == es[bx])) {
|
||||
if (es[bx] == 0) {
|
||||
loc1 = 0;
|
||||
return (loc1);
|
||||
}
|
||||
else {
|
||||
arg0 = (arg0 + 1);
|
||||
arg1 = (arg1 + 1);
|
||||
}
|
||||
}
|
||||
loc1 = (es[bx] - es[bx]);
|
||||
}
|
||||
|
||||
|
||||
int proc_1 (int arg0, int arg1, int arg2, int arg3)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
|
||||
loc1 = 0;
|
||||
loc2 = 0;
|
||||
while ((loc1 < 0x2328)) {
|
||||
proc_2 (arg1, arg0, 311);
|
||||
proc_2 (arg3, arg2, 328);
|
||||
loc2 = (loc2 + proc_3 (arg1, arg0, arg3, arg2));
|
||||
loc1 = (loc1 + 1);
|
||||
}
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
int proc_4 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
int loc4;
|
||||
|
||||
loc3 = 0;
|
||||
while ((loc3 < 0x3E8)) {
|
||||
loc1 = 0;
|
||||
loc4 = 0;
|
||||
loc2 = 1;
|
||||
while ((loc4 < 179)) {
|
||||
loc1 = (loc1 + loc2);
|
||||
loc2 = (loc2 + 2);
|
||||
loc4 = (loc4 + 1);
|
||||
}
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
return (loc1);
|
||||
}
|
||||
|
||||
|
||||
int proc_5 (int arg0)
|
||||
/* Takes 2 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2; /* ax */
|
||||
|
||||
loc1 = arg0;
|
||||
if (loc1 > 2) {
|
||||
loc2 = (proc_5 ((loc1 - 1)) + proc_5 ((loc1 + 0xFFFE)));
|
||||
}
|
||||
else {
|
||||
loc2 = 1;
|
||||
}
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
long proc_6 (int arg0, int arg1)
|
||||
/* Takes 4 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
long loc2;
|
||||
|
||||
if ((arg0 | arg1) == 0) {
|
||||
loc1 = 0;
|
||||
while ((loc1 < 0x2328)) {
|
||||
loc2 = (loc2 + [-862954250]);
|
||||
[-862954250] = ([-862954250] + 2);
|
||||
loc1 = (loc1 + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
loc1 = 0;
|
||||
while ((loc1 < 0x2328)) {
|
||||
[-862954250] = ([-862954250] - 2);
|
||||
loc2 = (loc2 - [-862954250]);
|
||||
loc1 = (loc1 + 1);
|
||||
}
|
||||
}
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
void proc_8 (int arg0)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* C calling convention.
|
||||
* Contains instructions not normally used by compilers.
|
||||
* Contains coprocessor instructions.
|
||||
*/
|
||||
{
|
||||
PUSH bp
|
||||
MOV bp, sp
|
||||
ESC qword ptr [126h]
|
||||
ESC qword ptr [bp+6]
|
||||
ESC FCOMPP
|
||||
ESC qword ptr [62Ch]
|
||||
INT 3Dh
|
||||
|
||||
MOV ah, [62Dh]
|
||||
SAHF
|
||||
JAE L1
|
||||
ESC qword ptr [bp+6]
|
||||
ESC FCHS
|
||||
|
||||
L2: POP bp
|
||||
RETF
|
||||
|
||||
L1: ESC qword ptr [bp+6]
|
||||
JMP L2 ;Synthetic inst
|
||||
}
|
||||
|
||||
|
||||
proc_7 (int arg0, int arg1, int arg2, int arg3)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* C calling convention.
|
||||
* Contains instructions not normally used by compilers.
|
||||
* Contains coprocessor instructions.
|
||||
*/
|
||||
{
|
||||
PUSH bp
|
||||
MOV bp, sp
|
||||
SUB sp, 10h
|
||||
ESC qword ptr [bp+6]
|
||||
ESC qword ptr [127h]
|
||||
ESC qword ptr [bp-8]
|
||||
INT 3Dh
|
||||
|
||||
MOV ax, [bp+0Ch]
|
||||
MOV [bp-0Ah], ax
|
||||
MOV ax, [bp+0Ah]
|
||||
MOV [bp-0Ch], ax
|
||||
MOV ax, [bp+8]
|
||||
MOV [bp-0Eh], ax
|
||||
MOV ax, [bp+6]
|
||||
MOV [bp-10h], ax
|
||||
|
||||
L3: ESC qword ptr [12Fh]
|
||||
ESC qword ptr [bp-8]
|
||||
ESC qword ptr [bp-10h]
|
||||
ESC qword ptr [62Ch]
|
||||
INT 3Dh
|
||||
|
||||
MOV ah, [62Dh]
|
||||
SAHF
|
||||
JB L4
|
||||
ESC qword ptr [bp-8]
|
||||
MOV sp, bp
|
||||
POP bp
|
||||
RETF
|
||||
|
||||
L4: ESC qword ptr [bp+6]
|
||||
ESC qword ptr [bp-8]
|
||||
ESC qword ptr [bp-8]
|
||||
ESC qword ptr [bp-10h]
|
||||
INT 3Dh
|
||||
|
||||
PUSH word ptr [bp-0Ah]
|
||||
PUSH word ptr [bp-0Ch]
|
||||
PUSH word ptr [bp-0Eh]
|
||||
PUSH word ptr [bp-10h]
|
||||
CALL far ptr proc_8
|
||||
ADD sp, 8
|
||||
ESC qword ptr [bp-10h]
|
||||
INT 3Dh
|
||||
|
||||
ESC qword ptr [bp+6]
|
||||
ESC qword ptr [bp-8]
|
||||
ESC qword ptr [bp-8]
|
||||
ESC qword ptr [127h]
|
||||
ESC qword ptr [bp-8]
|
||||
INT 3Dh
|
||||
|
||||
JMP L3 ;Synthetic inst
|
||||
}
|
||||
|
||||
|
||||
proc_9 (int arg0)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
* Contains instructions not normally used by compilers.
|
||||
* Contains coprocessor instructions.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3; /* ax */
|
||||
|
||||
loc2 = 100;
|
||||
loc3 = loc2;
|
||||
loc2 = (loc2 - 1);
|
||||
while (((loc3 | loc3) != 0)) {
|
||||
loc3 = loc2;
|
||||
loc2 = (loc2 - 1);
|
||||
}
|
||||
return (var06278);
|
||||
}
|
||||
|
||||
|
||||
int proc_10 ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* Return value in register ax.
|
||||
* Contains instructions not normally used by compilers.
|
||||
*/
|
||||
{
|
||||
PUSH bp
|
||||
MOV bp, sp
|
||||
SUB sp, 68h
|
||||
PUSH si
|
||||
PUSH di
|
||||
PUSH ds
|
||||
MOV ax, 159h
|
||||
PUSH ax
|
||||
PUSH ss
|
||||
LEA ax, [bp-64h]
|
||||
PUSH ax
|
||||
PUSH cs
|
||||
CALL near ptr proc_2
|
||||
ADD sp, 8
|
||||
PUSH ds
|
||||
MOV ax, 170h
|
||||
PUSH ax
|
||||
PUSH ds
|
||||
MOV ax, 167h
|
||||
PUSH ax
|
||||
CALL far ptr fopen
|
||||
ADD sp, 8
|
||||
MOV [bp-66h], dx
|
||||
MOV [bp-68h], ax
|
||||
OR dx, ax
|
||||
JNE L5
|
||||
PUSH ds
|
||||
MOV ax, 172h
|
||||
PUSH ax
|
||||
CALL far ptr printf
|
||||
POP cx
|
||||
POP cx
|
||||
MOV ax, 0FFFFh
|
||||
PUSH ax
|
||||
CALL far ptr exit
|
||||
POP cx
|
||||
|
||||
L5: XOR di, 0
|
||||
|
||||
L6: INC di
|
||||
MOV ax, di
|
||||
CMP ax, 3E8h
|
||||
JL L7
|
||||
PUSH word ptr [bp-66h]
|
||||
PUSH word ptr [bp-68h]
|
||||
CALL far ptr fclose
|
||||
POP cx
|
||||
POP cx
|
||||
MOV ax, di
|
||||
POP di
|
||||
POP si
|
||||
MOV sp, bp
|
||||
POP bp
|
||||
RETF
|
||||
|
||||
L7: XOR si, 0
|
||||
|
||||
L8: CMP byte ptr ss:[bp+si-64h], 0
|
||||
JNE L9
|
||||
|
||||
L9: LES bx, dword ptr [bp-68h]
|
||||
INC word ptr es:[bx]
|
||||
JGE L10
|
||||
MOV al, ss:[bp+si-64h]
|
||||
LES bx, dword ptr [bp-68h]
|
||||
INC word ptr es:[bx+0Ch]
|
||||
LES bx, dword ptr es:[bx+0Ch]
|
||||
DEC bx
|
||||
MOV es:[bx], al
|
||||
MOV ah, 0
|
||||
|
||||
L11: INC si
|
||||
JMP L8 ;Synthetic inst
|
||||
|
||||
L10: PUSH word ptr [bp-66h]
|
||||
PUSH word ptr [bp-68h]
|
||||
PUSH word ptr ss:[bp+si-64h]
|
||||
CALL far ptr _fputc
|
||||
ADD sp, 6
|
||||
JMP L11 ;Synthetic inst
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
* Contains instructions not normally used by compilers.
|
||||
* Contains coprocessor instructions.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
int loc4;
|
||||
int loc5;
|
||||
int loc6;
|
||||
int loc7;
|
||||
int loc8;
|
||||
int loc9;
|
||||
int loc10;
|
||||
int loc11;
|
||||
int loc12; /* ax */
|
||||
int loc13; /* bx */
|
||||
|
||||
loc11 = 0;
|
||||
printf ("Start...%c\n\n", 7);
|
||||
while ((loc11 < 6)) {
|
||||
loc12 = loc11;
|
||||
if (loc12 <= 5) {
|
||||
loc13 = (loc12 << 1);
|
||||
var06278 = proc_1 (&loc2, &loc1, , );
|
||||
printf ("\ncresult = %d\n", var06278);
|
||||
}
|
||||
loc11 = (loc11 + 1);
|
||||
}
|
||||
printf ("\n\n...End%c", 7);
|
||||
}
|
||||
|
||||
29
tests/initial_base/FIBO.C
Normal file
29
tests/initial_base/FIBO.C
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Fibonacci */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{ int i, numtimes, number;
|
||||
unsigned value, fib();
|
||||
|
||||
printf("Input number of iterations: ");
|
||||
scanf ("%d", &numtimes);
|
||||
for (i = 1; i <= numtimes; i++)
|
||||
{
|
||||
printf ("Input number: ");
|
||||
scanf ("%d", &number);
|
||||
value = fib(number);
|
||||
printf("fibonacci(%d) = %u\n", number, value);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
unsigned fib(x) /* compute fibonacci number recursively */
|
||||
int x;
|
||||
{
|
||||
if (x > 2)
|
||||
return (fib(x - 1) + fib(x - 2));
|
||||
else
|
||||
return (1);
|
||||
}
|
||||
|
||||
52
tests/initial_base/FIBOL.b
Normal file
52
tests/initial_base/FIBOL.b
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Input file : test\fibol.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
int proc_1 (int arg0)
|
||||
/* Takes 2 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2; /* ax */
|
||||
|
||||
loc1 = arg0;
|
||||
if (loc1 > 2) {
|
||||
loc2 = (proc_1 ((loc1 - 1)) + proc_1 ((loc1 + 0xFFFE)));
|
||||
}
|
||||
else {
|
||||
loc2 = 1;
|
||||
}
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
* Contains instructions not normally used by compilers.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
int loc4;
|
||||
|
||||
printf ("Input number of iterations: ");
|
||||
scanf ("%d", &loc1, );
|
||||
loc3 = 1;
|
||||
while ((loc3 <= loc1)) {
|
||||
printf ("Input number: ");
|
||||
scanf ("%d", &loc2, );
|
||||
loc4 = proc_1 (loc2);
|
||||
printf ("fibonacci(%d) = %u\n", loc2, loc4);
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
51
tests/initial_base/FIBOS.b
Normal file
51
tests/initial_base/FIBOS.b
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Input file : test\fibos.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
int proc_1 (int arg0)
|
||||
/* Takes 2 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2; /* ax */
|
||||
|
||||
loc1 = arg0;
|
||||
if (loc1 > 2) {
|
||||
loc2 = (proc_1 ((loc1 - 1)) + proc_1 ((loc1 + 0xFFFE)));
|
||||
}
|
||||
else {
|
||||
loc2 = 1;
|
||||
}
|
||||
return (loc2);
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
int loc4;
|
||||
|
||||
printf ("Input number of iterations: ");
|
||||
scanf ("%d", &loc1);
|
||||
loc3 = 1;
|
||||
while ((loc3 <= loc1)) {
|
||||
printf ("Input number: ");
|
||||
scanf ("%d", &loc2);
|
||||
loc4 = proc_1 (loc2);
|
||||
printf ("fibonacci(%d) = %u\n", loc2, loc4);
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
16
tests/initial_base/INTOPS.C
Normal file
16
tests/initial_base/INTOPS.C
Normal file
@@ -0,0 +1,16 @@
|
||||
#define TYPE int
|
||||
|
||||
main()
|
||||
{ TYPE a, b;
|
||||
|
||||
a = 255;
|
||||
b = 143;
|
||||
b = a + b;
|
||||
a = a - b;
|
||||
a = a * b;
|
||||
b = b / a;
|
||||
b = b % a;
|
||||
a = a << 5;
|
||||
b = b >> a;
|
||||
printf ("a = %d, b = %d\n", a, b);
|
||||
}
|
||||
33
tests/initial_base/INTOPS.b
Normal file
33
tests/initial_base/INTOPS.b
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Input file : test\intops.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
long loc3; /* dx:ax */
|
||||
int loc4; /* tmp */
|
||||
|
||||
loc1 = 255;
|
||||
loc2 = 143;
|
||||
loc2 = (loc1 + loc2);
|
||||
loc1 = (loc1 - loc2);
|
||||
loc1 = (loc1 * loc2);
|
||||
loc3 = loc2;
|
||||
loc2 = (loc4 / loc1);
|
||||
loc3 = loc2;
|
||||
LO(loc3) = (loc4 / loc1);
|
||||
loc2 = (loc4 % loc1);
|
||||
loc1 = (loc1 << 5);
|
||||
loc2 = (loc2 >> loc1);
|
||||
printf ("a = %d, b = %d\n", loc1, loc2);
|
||||
}
|
||||
|
||||
16
tests/initial_base/LONGOPS.C
Normal file
16
tests/initial_base/LONGOPS.C
Normal file
@@ -0,0 +1,16 @@
|
||||
#define TYPE long
|
||||
|
||||
main()
|
||||
{ TYPE a, b;
|
||||
|
||||
a = 255;
|
||||
b = 143;
|
||||
b = a + b;
|
||||
a = a - b;
|
||||
a = a * b;
|
||||
b = b / a;
|
||||
b = b % a;
|
||||
a = a << 5;
|
||||
b = b >> a;
|
||||
printf ("a = %ld, b = %ld\n", a, b);
|
||||
}
|
||||
295
tests/initial_base/LONGOPS.b
Normal file
295
tests/initial_base/LONGOPS.b
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Input file : test\longops.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
long LXMUL@ (long arg0, long arg1)
|
||||
/* Uses register arguments:
|
||||
* arg0 = dx:ax.
|
||||
* arg1 = cx:bx.
|
||||
* Runtime support routine of the compiler.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2; /* tmp */
|
||||
|
||||
loc2 = LO(arg0);
|
||||
LO(arg0) = loc1;
|
||||
loc1 = loc2;
|
||||
loc2 = LO(arg0);
|
||||
LO(arg0) = HI(arg0);
|
||||
if ((LO(arg0) & LO(arg0)) != 0) {
|
||||
LO(arg0) = (LO(arg0) * LO(arg1));
|
||||
}
|
||||
loc2 = LO(arg0);
|
||||
LO(arg0) = HI(arg1);
|
||||
HI(arg1) = loc2;
|
||||
if ((LO(arg0) & LO(arg0)) != 0) {
|
||||
LO(arg0) = (LO(arg0) * loc1);
|
||||
HI(arg1) = (HI(arg1) + LO(arg0));
|
||||
}
|
||||
loc2 = LO(arg0);
|
||||
LO(arg0) = loc1;
|
||||
loc1 = loc2;
|
||||
arg0 = (LO(arg0) * LO(arg1));
|
||||
HI(arg0) = (HI(arg0) + HI(arg1));
|
||||
return (arg0);
|
||||
}
|
||||
|
||||
|
||||
long LDIV@ (long arg0, long arg2)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* Runtime support routine of the compiler.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* Return value in registers dx:ax.
|
||||
* Pascal calling convention.
|
||||
*/
|
||||
{
|
||||
XOR cx, 0
|
||||
PUSH bp
|
||||
PUSH si
|
||||
PUSH di
|
||||
MOV bp, sp
|
||||
MOV di, cx
|
||||
MOV ax, [bp+0Ah]
|
||||
MOV dx, [bp+0Ch]
|
||||
MOV bx, [bp+0Eh]
|
||||
MOV cx, [bp+10h]
|
||||
CMP cx, 0
|
||||
JNE L1
|
||||
OR dx, dx
|
||||
JE L2
|
||||
OR bx, bx
|
||||
JE L2
|
||||
|
||||
L1: TEST di, 1
|
||||
JNE L3
|
||||
OR dx, dx
|
||||
JNS L4
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
OR di, 0Ch
|
||||
|
||||
L4: OR cx, cx
|
||||
JNS L3
|
||||
NEG cx
|
||||
NEG bx
|
||||
SBB cx, 0
|
||||
XOR di, 4
|
||||
|
||||
L3: MOV bp, cx
|
||||
MOV cx, 20h
|
||||
PUSH di
|
||||
XOR di, 0
|
||||
XOR si, 0
|
||||
|
||||
L5: SHL ax, 1
|
||||
RCL dx, 1
|
||||
RCL si, 1
|
||||
RCL di, 1
|
||||
CMP di, bp
|
||||
JB L6
|
||||
JA L7
|
||||
CMP si, bx
|
||||
JB L6
|
||||
|
||||
L7: SUB si, bx
|
||||
SBB di, bp
|
||||
INC ax
|
||||
|
||||
L6: LOOP L5
|
||||
POP bx
|
||||
TEST bx, 2
|
||||
JE L8
|
||||
MOV ax, si
|
||||
MOV dx, di
|
||||
SHR bx, 1
|
||||
|
||||
L8: TEST bx, 4
|
||||
JE L9
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
|
||||
L9: POP di
|
||||
POP si
|
||||
POP bp
|
||||
RETF 8
|
||||
|
||||
L2: MOV tmp, dx:ax ;Synthetic inst
|
||||
DIV bx
|
||||
MOD bx ;Synthetic inst
|
||||
TEST di, 2
|
||||
JE L10
|
||||
MOV ax, dx
|
||||
|
||||
L10: XOR dx, dx
|
||||
JMP L9
|
||||
}
|
||||
|
||||
|
||||
long LMOD@ (long arg0, long arg2)
|
||||
/* Takes 8 bytes of parameters.
|
||||
* Runtime support routine of the compiler.
|
||||
* Untranslatable routine. Assembler provided.
|
||||
* Return value in registers dx:ax.
|
||||
* Pascal calling convention.
|
||||
*/
|
||||
{
|
||||
MOV cx, 2
|
||||
PUSH bp
|
||||
PUSH si
|
||||
PUSH di
|
||||
MOV bp, sp
|
||||
MOV di, cx
|
||||
MOV ax, [bp+0Ah]
|
||||
MOV dx, [bp+0Ch]
|
||||
MOV bx, [bp+0Eh]
|
||||
MOV cx, [bp+10h]
|
||||
CMP cx, 0
|
||||
JNE L11
|
||||
OR dx, dx
|
||||
JE L12
|
||||
OR bx, bx
|
||||
JE L12
|
||||
|
||||
L11: TEST di, 1
|
||||
JNE L13
|
||||
OR dx, dx
|
||||
JNS L14
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
OR di, 0Ch
|
||||
|
||||
L14: OR cx, cx
|
||||
JNS L13
|
||||
NEG cx
|
||||
NEG bx
|
||||
SBB cx, 0
|
||||
XOR di, 4
|
||||
|
||||
L13: MOV bp, cx
|
||||
MOV cx, 20h
|
||||
PUSH di
|
||||
XOR di, 0
|
||||
XOR si, 0
|
||||
|
||||
L15: SHL ax, 1
|
||||
RCL dx, 1
|
||||
RCL si, 1
|
||||
RCL di, 1
|
||||
CMP di, bp
|
||||
JB L16
|
||||
JA L17
|
||||
CMP si, bx
|
||||
JB L16
|
||||
|
||||
L17: SUB si, bx
|
||||
SBB di, bp
|
||||
INC ax
|
||||
|
||||
L16: LOOP L15
|
||||
POP bx
|
||||
TEST bx, 2
|
||||
JE L18
|
||||
MOV ax, si
|
||||
MOV dx, di
|
||||
SHR bx, 1
|
||||
|
||||
L18: TEST bx, 4
|
||||
JE L19
|
||||
NEG dx
|
||||
NEG ax
|
||||
SBB dx, 0
|
||||
|
||||
L19: POP di
|
||||
POP si
|
||||
POP bp
|
||||
RETF 8
|
||||
|
||||
L12: MOV tmp, dx:ax ;Synthetic inst
|
||||
DIV bx
|
||||
MOD bx ;Synthetic inst
|
||||
TEST di, 2
|
||||
JE L20
|
||||
MOV ax, dx
|
||||
|
||||
L20: XOR dx, dx
|
||||
JMP L19
|
||||
}
|
||||
|
||||
|
||||
long LXLSH@ (long arg0, char arg1)
|
||||
/* Uses register arguments:
|
||||
* arg0 = dx:ax.
|
||||
* arg1 = cl.
|
||||
* Runtime support routine of the compiler.
|
||||
*/
|
||||
{
|
||||
int loc1; /* bx */
|
||||
|
||||
if (arg1 < 16) {
|
||||
loc1 = LO(arg0);
|
||||
LO(arg0) = (LO(arg0) << arg1);
|
||||
HI(arg0) = (HI(arg0) << arg1);
|
||||
HI(arg0) = (HI(arg0) | (loc1 >> (!arg1 + 16)));
|
||||
return (arg0);
|
||||
}
|
||||
else {
|
||||
HI(arg0) = LO(arg0);
|
||||
LO(arg0) = 0;
|
||||
HI(arg0) = (HI(arg0) << (arg1 - 16));
|
||||
return (arg0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long LXRSH@ (long arg0, char arg1)
|
||||
/* Uses register arguments:
|
||||
* arg0 = dx:ax.
|
||||
* arg1 = cl.
|
||||
* Runtime support routine of the compiler.
|
||||
*/
|
||||
{
|
||||
int loc1; /* bx */
|
||||
|
||||
if (arg1 < 16) {
|
||||
loc1 = HI(arg0);
|
||||
LO(arg0) = (LO(arg0) >> arg1);
|
||||
HI(arg0) = (HI(arg0) >> arg1);
|
||||
LO(arg0) = (LO(arg0) | (loc1 << (!arg1 + 16)));
|
||||
return (arg0);
|
||||
}
|
||||
else {
|
||||
arg0 = HI(arg0);
|
||||
LO(arg0) = (LO(arg0) >> (arg1 - 16));
|
||||
return (arg0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
long loc1;
|
||||
long loc2;
|
||||
|
||||
loc2 = 255;
|
||||
loc1 = 143;
|
||||
loc1 = (loc2 + loc1);
|
||||
loc2 = (loc2 - loc1);
|
||||
loc2 = LXMUL@ (loc2, loc1);
|
||||
loc1 = LDIV@ (loc1, loc2);
|
||||
loc1 = LMOD@ (loc1, loc2);
|
||||
loc2 = LXLSH@ (loc2, 5);
|
||||
loc1 = LXRSH@ (loc1, loc1);
|
||||
printf ("a = %ld, b = %ld\n", loc2, loc1);
|
||||
}
|
||||
|
||||
18
tests/initial_base/MATRIXMU.C
Normal file
18
tests/initial_base/MATRIXMU.C
Normal file
@@ -0,0 +1,18 @@
|
||||
#define n 5
|
||||
#define m 4
|
||||
|
||||
static void multMatrix (int a[n][m], int b[m][n], int c[n][n])
|
||||
{ int i,j,k;
|
||||
|
||||
for (i=0; i<n; i++)
|
||||
for (j=0; j<m; j++)
|
||||
for (k=0; k<m; k++)
|
||||
c[i][j] = a[i][k] * b[k][j] + c[i][j];
|
||||
}
|
||||
|
||||
main()
|
||||
{ int a[n][m], b[n][m], c[n][m];
|
||||
|
||||
multMatrix (a,b,c);
|
||||
}
|
||||
|
||||
46
tests/initial_base/MATRIXMU.b
Normal file
46
tests/initial_base/MATRIXMU.b
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Input file : test\matrixmu.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void proc_1 (int arg0, int arg1, int arg2)
|
||||
/* Takes 6 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
|
||||
loc2 = 0;
|
||||
while ((loc2 < 5)) {
|
||||
loc3 = 0;
|
||||
while ((loc3 < 4)) {
|
||||
loc1 = 0;
|
||||
while ((loc1 < 4)) {
|
||||
*((((loc2 * 10) + arg2) + (loc3 << 1))) = ((*((((loc2 << 3) + arg0) + (loc1 << 1))) * *((((loc1 * 10) + arg1) + (loc3 << 1)))) + *((((loc2 * 10) + arg2) + (loc3 << 1))));
|
||||
loc1 = (loc1 + 1);
|
||||
}
|
||||
loc3 = (loc3 + 1);
|
||||
}
|
||||
loc2 = (loc2 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
|
||||
proc_1 (&loc3, &loc2, &loc1);
|
||||
}
|
||||
|
||||
15
tests/initial_base/MAX.C
Normal file
15
tests/initial_base/MAX.C
Normal file
@@ -0,0 +1,15 @@
|
||||
main()
|
||||
{ int a, b;
|
||||
|
||||
printf ("Enter 2 numbers: ");
|
||||
scanf ("%d %d", &a, &b);
|
||||
if (a != b)
|
||||
printf ("Maximum: %d\n", max (a,b));
|
||||
}
|
||||
|
||||
max (int x, int y)
|
||||
{
|
||||
if (x > y)
|
||||
return (x);
|
||||
return (y);
|
||||
}
|
||||
41
tests/initial_base/MAX.b
Normal file
41
tests/initial_base/MAX.b
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Input file : test\max.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
int proc_1 (int arg0, int arg1)
|
||||
/* Takes 4 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1; /* ax */
|
||||
|
||||
if (arg0 > arg1) {
|
||||
loc1 = arg0;
|
||||
}
|
||||
else {
|
||||
loc1 = arg1;
|
||||
}
|
||||
return (loc1);
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
|
||||
printf ("Enter 2 numbers: ");
|
||||
scanf ("%d %d", &loc2, &loc1);
|
||||
if (loc2 != loc1) {
|
||||
printf ("Maximum: %d\n", proc_1 (loc2, loc1));
|
||||
}
|
||||
}
|
||||
|
||||
13
tests/initial_base/STRLEN.C
Normal file
13
tests/initial_base/STRLEN.C
Normal file
@@ -0,0 +1,13 @@
|
||||
main()
|
||||
{ char *s = "test";
|
||||
|
||||
strlen(s);
|
||||
}
|
||||
|
||||
strlen(char *s)
|
||||
{ int n = 0;
|
||||
|
||||
while (*s++)
|
||||
n++;
|
||||
return (n);
|
||||
}
|
||||
35
tests/initial_base/STRLEN.b
Normal file
35
tests/initial_base/STRLEN.b
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Input file : test\strlen.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void proc_1 (int arg0)
|
||||
/* Takes 2 bytes of parameters.
|
||||
* High-level language prologue code.
|
||||
* C calling convention.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
|
||||
loc1 = 0;
|
||||
arg0 = (arg0 + 1);
|
||||
while ((*arg0 != 0)) {
|
||||
loc1 = (loc1 + 1);
|
||||
arg0 = (arg0 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
|
||||
loc1 = 404;
|
||||
proc_1 (loc1);
|
||||
}
|
||||
|
||||
10
tests/initial_base/TESTLONG.C
Normal file
10
tests/initial_base/TESTLONG.C
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{ long a, d;
|
||||
|
||||
scanf ("%d", &d);
|
||||
scanf ("%d", &a);
|
||||
scanf ("%d %d", &a, &d);
|
||||
printf ("%ld %ld", a, d);
|
||||
}
|
||||
24
tests/initial_base/TESTLONG.b
Normal file
24
tests/initial_base/TESTLONG.b
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Input file : test\testlong.exe
|
||||
* File type : EXE
|
||||
*/
|
||||
|
||||
#include "dcc.h"
|
||||
|
||||
|
||||
void main ()
|
||||
/* Takes no parameters.
|
||||
* High-level language prologue code.
|
||||
*/
|
||||
{
|
||||
int loc1;
|
||||
int loc2;
|
||||
int loc3;
|
||||
int loc4;
|
||||
|
||||
scanf ("%d", &loc1);
|
||||
scanf ("%d", &loc2);
|
||||
scanf ("%d %d", &loc2, &loc1);
|
||||
printf ("%ld %ld", loc2, loc4, loc1, loc3);
|
||||
}
|
||||
|
||||
0
tests/inputs_base/BENCHFN.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHFN.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHLNG.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHLNG.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHMUL.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHMUL.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHMUS.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHMUS.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHSHO.EXE
Executable file → Normal file
0
tests/inputs_base/BENCHSHO.EXE
Executable file → Normal file
0
tests/inputs_base/BYTEOPS.EXE
Executable file → Normal file
0
tests/inputs_base/BYTEOPS.EXE
Executable file → Normal file
BIN
tests/inputs_base/DHAMP.EXE
Normal file
BIN
tests/inputs_base/DHAMP.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/FIBOL.EXE
Normal file
BIN
tests/inputs_base/FIBOL.EXE
Normal file
Binary file not shown.
0
tests/inputs_base/FIBOS.EXE
Executable file → Normal file
0
tests/inputs_base/FIBOS.EXE
Executable file → Normal file
BIN
tests/inputs_base/INTOPS.EXE
Normal file
BIN
tests/inputs_base/INTOPS.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/LONGOPS.EXE
Normal file
BIN
tests/inputs_base/LONGOPS.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/MATRIXMU.EXE
Normal file
BIN
tests/inputs_base/MATRIXMU.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/MAX.EXE
Normal file
BIN
tests/inputs_base/MAX.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/STRLEN.EXE
Normal file
BIN
tests/inputs_base/STRLEN.EXE
Normal file
Binary file not shown.
BIN
tests/inputs_base/TESTLONG.EXE
Normal file
BIN
tests/inputs_base/TESTLONG.EXE
Normal file
Binary file not shown.
Reference in New Issue
Block a user