1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-20 14:29:03 +00:00

add more checks that are related to recent fixes

This commit is contained in:
mrdudz 2022-11-18 01:52:55 +01:00
parent 965c1f5239
commit 705617cd5f
5 changed files with 55 additions and 1 deletions

View File

@ -74,13 +74,20 @@ void constconst(void)
printf("\nconstant - constant\n\n");
fp1 = 0.1f;
fp2 = 0.2f;
fp3 = 0.1f - 0.2f; //FIXME: Invalid operands for binary operator '-'
fp3 = 0.1f - 0.2f;
printf(" 0x%08lx [0x3dcccccd] %s (0.1)\n", *((uint32_t*)&fp1), _ftostr(buf, fp1));
printf(" 0x%08lx [0x3e4ccccd] %s (0.2)\n", *((uint32_t*)&fp2), _ftostr(buf, fp2));
printf("fp3:0x%08lx [0xbdcccccd] %s (-0.1)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "bdcccccd");
fp3 = 0.3f - 0.1f;
printf("fp3:0x%08lx [0xbdcccccd] %s (0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "3e4cccce");
fp3 = 0.1f - 0.3f;
printf("fp3:0x%08lx [0xbdcccccd] %s (-0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "be4cccce");
// multiplication
printf("\nconstant * constant\n\n");
fp1 = 0.1f;

View File

@ -72,6 +72,15 @@ void constvar(void)
printf(" fp3:0x%08lx [0xc0f80000] %s (-7.75)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "c0f80000");
fp1 = 0.1f;
fp2 = 0.3f;
fp3 = 0.3f - fp1;
printf("fp3:0x%08lx [0x3e4cccce] %s (0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "3e4cccce");
fp3 = 0.1f - fp2;
printf("fp3:0x%08lx [0xbe4cccce] %s (-0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "be4cccce");
fp2 = 2.25f;
fp3 = 16.25f * fp2;
printf("multiplication: %s*%s=%s\n", _ftostr(buf, 16.25f), _ftostr(buf2, fp2), _ftostr(buf3, fp3));
@ -83,6 +92,8 @@ void constvar(void)
printf("division: %s/%s=%s\n", _ftostr(buf, 16.2f), _ftostr(buf2, fp2), _ftostr(buf3, fp3));
printf(" fp3:0x%08lx [0x40cf5c2a] %s (6.48)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "40cf5c2a");
}
int main(void)

View File

@ -74,6 +74,15 @@ void varconst(void)
printf(" fp3:0x%08lx [0x40f80000] %s (exp:7.75)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "40f80000");
fp1 = 0.1f;
fp2 = 0.3f;
fp3 = fp2 - 0.1f;
printf("fp3:0x%08lx [0x3e4cccce] %s (0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "3e4cccce");
fp3 = fp1 - 0.3f;
printf("fp3:0x%08lx [0xbe4cccce] %s (-0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "be4cccce");
fp1 = 16.25f;
fp3 = fp1 * 2.5f;
printf("multiplication: %s*%s=%s\n", _ftostr(buf, fp1), _ftostr(buf2, 2.3f), _ftostr(buf3, fp3));

View File

@ -76,6 +76,16 @@ void varvar(void)
printf(" fp3:0x%08lx [0x423f0000] %s (exp:47.75)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "423f0000");
fp1 = 0.1f;
fp2 = 0.3f;
fp3 = fp2 - fp1;
printf("fp3:0x%08lx [0x3e4cccce] %s (0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "3e4cccce");
fp3 = fp1 - fp2;
printf("fp3:0x%08lx [0xbe4cccce] %s (-0.2)", *((uint32_t*)&fp3), _ftostr(buf, fp3));
test1(fp3, "be4cccce");
fp1 = 8.5f;
fp2 = 2.25f;
fp3 = fp1 * fp2;

View File

@ -159,6 +159,11 @@ void varvar(void)
WAIT();
printf("\nconversions (float variable to integer variable)\n");
fp1 = 12.3f;
var_schar = (signed char)fp1;
printf("fp1 0x%08lx %s (12.3) schar:%d (exp:12)", *((uint32_t*)&fp1), _ftostr(buf, fp1), (int)var_schar);
test2(var_schar, 12);
fp1 = -12.3f;
var_schar = (signed char)fp1;
printf("fp1 0x%08lx %s (-12.3) schar:%d (exp:-12)", *((uint32_t*)&fp1), _ftostr(buf, fp1), (int)var_schar);
@ -173,6 +178,12 @@ void varvar(void)
var_sint = (signed short)fp1;
printf("fp1 0x%08lx %s (1234.5) sint:%d (exp:1234)", *((uint32_t*)&fp1), _ftostr(buf, fp1), var_sint);
test2(var_sint, 1234);
fp1 = -1234.5f;
var_sint = (signed short)fp1;
printf("fp1 0x%08lx %s (-1234.5) sint:%d (exp:-1234)", *((uint32_t*)&fp1), _ftostr(buf, fp1), var_sint);
test2(var_sint, -1234);
fp2 = 1999.9f;
var_uint = (unsigned short)fp2;
printf("fp2 0x%08lx %s (1999.9) uint:%u (exp:1999)", *((uint32_t*)&fp2), _ftostr(buf, fp2), var_uint);
@ -182,6 +193,12 @@ void varvar(void)
var_slong = (signed long)fp1;
printf("fp1 0x%08lx %s (123456.5) slong:%ld (exp:123456)", *((uint32_t*)&fp1), _ftostr(buf, fp1), var_slong);
test2(var_slong, 123456);
fp1 = -123456.5f;
var_slong = (signed long)fp1;
printf("fp1 0x%08lx %s (-123456.5) slong:%ld (exp:-123456)", *((uint32_t*)&fp1), _ftostr(buf, fp1), var_slong);
test2(var_slong, -123456);
fp2 = 199988.9f;
var_ulong = (unsigned long)fp2;
printf("fp2 0x%08lx %s (199988.9) ulong:%lu (exp:199988)", *((uint32_t*)&fp2), _ftostr(buf, fp2), var_ulong);