should have fixed big endian issues with embryo now. it works on sparc,

shoudl work on ppc and works on alpha and x86. i shoudl test opteron i guess...


SVN revision: 10248
This commit is contained in:
Carsten Haitzler 2004-05-15 17:24:56 +00:00
parent 6567775653
commit 74c61becdf
2 changed files with 104 additions and 25 deletions

View File

@ -16,31 +16,80 @@ main()
{
printf("Testing switch and case statements...\n");
new var = 4;
switch (var) {
case 0:
printf("It's 0\n");
case 1:
printf("It's 1\n");
case 2:
printf("It's 2\n");
case 3:
printf("It's 3\n");
case 4:
printf("It's 4\n");
case 5:
printf("It's 5\n");
case 6:
printf("It's 6\n");
case 7:
printf("It's 7\n");
default:
printf("It's something else\n");
}
new var;
for (var = 1; var < 5; var++)
{
switch (var)
{
case 0:
printf("It's 0\n");
case 1:
printf("It's 1\n");
case 2:
printf("It's 2\n");
case 3:
printf("It's 3\n");
case 4:
printf("It's 4\n");
case 5:
printf("It's 5\n");
case 6:
printf("It's 6\n");
case 7:
printf("It's 7\n");
default:
printf("It's something else\n");
}
}
printf("\n\n");
printf("Testing for loops...\n");
for (var = 0; var < 10; var++)
{
printf("Var = %i\n", var);
}
printf("\n\n");
printf("Testing recursion...\n");
var = recurse(3);
printf("var = %i\n", var);
printf("\n\n");
printf("Testing while loops...\n");
var = 7;
while (var > 1)
{
printf("var = %i\n", var);
var--;
}
printf("\n\n");
printf("Testing Float Math...\n");
new Float:a;
new Float:b;
new Float:c;
c = 10.5;
printf("c = %f (should be 10.5)\n", c);
a = 5.0;
b = 2.345;
c = a + b;
printf("a = %f (should be 5.0)\n", a);
printf("b = %f (should be 2.345)\n", b);
printf("a + b = %f (should be 7.345)\n", c);
a = 2.5;
b = 3.5;
c = a * b;
printf("a = %f (should be 2.5)\n", a);
printf("b = %f (should be 3.5)\n", b);
printf("a 8 b = %f (should be 8.75)\n", c);
a = 5.5;
b = 1.5;
c = a / b;
printf("a = %f (should be 5.5)\n", a);
printf("b = %f (should be 1.5)\n", b);
printf("a / b = %f (should be 3.666666667)\n", c);
printf("The printf() call is a native exported function. This should work\n");
printf("Calling testfn()...\n");
@ -53,6 +102,13 @@ main()
return 7;
}
recurse(val)
{
printf("Recurse: val = %i\n", val);
if (val >= 10) return val;
return recurse(val + 1);
}
tester(arg1=0, str[]="", arg2=0)
{
if (arg1 == 7) printf("arg1 == 7!!!\n");

View File

@ -192,7 +192,7 @@ _embryo_program_init(Embryo_Program *ep, void *code)
code_size = hdr->dat - hdr->cod;
code = (Embryo_Cell *)((unsigned char *)ep->code + (int)hdr->cod);
for (cip = 0; cip < code_size; cip++) embryo_swap_32(&(code[cip]));
for (cip = 0; cip < (code_size / sizeof(Embryo_Cell)); cip++) embryo_swap_32(&(code[cip]));
}
#endif
/* init native api for handling floating point - default in embryo */
@ -595,7 +595,20 @@ embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst)
dst[0] = 0;
return;
}
for (i = 0; str_cell[i] != 0; i++) dst[i] = str_cell[i];
for (i = 0; str_cell[i] != 0; i++)
{
#ifdef WORDS_BIGENDIAN
{
Embryo_Cell tmp;
tmp = str_cell[i];
_embryo_byte_swap_32(&tmp);
dst[i] = tmp;
}
#else
dst[i] = str_cell[i];
#endif
}
dst[i] = 0;
}
@ -625,7 +638,17 @@ embryo_data_string_set(Embryo_Program *ep, char *src, Embryo_Cell *str_cell)
str_cell[i] = 0;
return;
}
#ifdef WORDS_BIGENDIAN
{
Embryo_Cell tmp;
tmp = src[i];
_embryo_byte_swap_32(&tmp);
str_cell[i] = tmp;
}
#else
str_cell[i] = src[i];
#endif
}
str_cell[i] = 0;
}