Commit 55480af80e9ed58b11e9a99da25602468b17ff45
1 parent
7d13299d
added bcd test
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@26 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
74 additions
and
0 deletions
tests/test-i386.c
@@ -446,6 +446,8 @@ void test_bsx(void) | @@ -446,6 +446,8 @@ void test_bsx(void) | ||
446 | TEST_BSX(bsfl, "", 0x00340128); | 446 | TEST_BSX(bsfl, "", 0x00340128); |
447 | } | 447 | } |
448 | 448 | ||
449 | +/**********************************************/ | ||
450 | + | ||
449 | void test_fops(double a, double b) | 451 | void test_fops(double a, double b) |
450 | { | 452 | { |
451 | printf("a=%f b=%f a+b=%f\n", a, b, a + b); | 453 | printf("a=%f b=%f a+b=%f\n", a, b, a + b); |
@@ -540,6 +542,77 @@ void test_floats(void) | @@ -540,6 +542,77 @@ void test_floats(void) | ||
540 | test_fbcd(-123451234567890); | 542 | test_fbcd(-123451234567890); |
541 | } | 543 | } |
542 | 544 | ||
545 | +/**********************************************/ | ||
546 | + | ||
547 | +#define TEST_BCD(op, op0, cc_in, cc_mask)\ | ||
548 | +{\ | ||
549 | + int res, flags;\ | ||
550 | + res = op0;\ | ||
551 | + flags = cc_in;\ | ||
552 | + asm ("push %3\n\t"\ | ||
553 | + "popf\n\t"\ | ||
554 | + #op "\n\t"\ | ||
555 | + "pushf\n\t"\ | ||
556 | + "popl %1\n\t"\ | ||
557 | + : "=a" (res), "=g" (flags)\ | ||
558 | + : "0" (res), "1" (flags));\ | ||
559 | + printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n",\ | ||
560 | + #op, op0, res, cc_in, flags & cc_mask);\ | ||
561 | +} | ||
562 | + | ||
563 | +void test_bcd(void) | ||
564 | +{ | ||
565 | + TEST_BCD(daa, 0x12340503, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
566 | + TEST_BCD(daa, 0x12340506, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
567 | + TEST_BCD(daa, 0x12340507, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
568 | + TEST_BCD(daa, 0x12340559, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
569 | + TEST_BCD(daa, 0x12340560, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
570 | + TEST_BCD(daa, 0x1234059f, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
571 | + TEST_BCD(daa, 0x123405a0, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
572 | + TEST_BCD(daa, 0x12340503, 0, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
573 | + TEST_BCD(daa, 0x12340506, 0, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
574 | + TEST_BCD(daa, 0x12340503, CC_C, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
575 | + TEST_BCD(daa, 0x12340506, CC_C, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
576 | + TEST_BCD(daa, 0x12340503, CC_C | CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
577 | + TEST_BCD(daa, 0x12340506, CC_C | CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
578 | + | ||
579 | + TEST_BCD(das, 0x12340503, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
580 | + TEST_BCD(das, 0x12340506, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
581 | + TEST_BCD(das, 0x12340507, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
582 | + TEST_BCD(das, 0x12340559, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
583 | + TEST_BCD(das, 0x12340560, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
584 | + TEST_BCD(das, 0x1234059f, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
585 | + TEST_BCD(das, 0x123405a0, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
586 | + TEST_BCD(das, 0x12340503, 0, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
587 | + TEST_BCD(das, 0x12340506, 0, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
588 | + TEST_BCD(das, 0x12340503, CC_C, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
589 | + TEST_BCD(das, 0x12340506, CC_C, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
590 | + TEST_BCD(das, 0x12340503, CC_C | CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
591 | + TEST_BCD(das, 0x12340506, CC_C | CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_A)); | ||
592 | + | ||
593 | + TEST_BCD(aaa, 0x12340205, CC_A, (CC_C | CC_A)); | ||
594 | + TEST_BCD(aaa, 0x12340306, CC_A, (CC_C | CC_A)); | ||
595 | + TEST_BCD(aaa, 0x1234040a, CC_A, (CC_C | CC_A)); | ||
596 | + TEST_BCD(aaa, 0x123405fa, CC_A, (CC_C | CC_A)); | ||
597 | + TEST_BCD(aaa, 0x12340205, 0, (CC_C | CC_A)); | ||
598 | + TEST_BCD(aaa, 0x12340306, 0, (CC_C | CC_A)); | ||
599 | + TEST_BCD(aaa, 0x1234040a, 0, (CC_C | CC_A)); | ||
600 | + TEST_BCD(aaa, 0x123405fa, 0, (CC_C | CC_A)); | ||
601 | + | ||
602 | + TEST_BCD(aas, 0x12340205, CC_A, (CC_C | CC_A)); | ||
603 | + TEST_BCD(aas, 0x12340306, CC_A, (CC_C | CC_A)); | ||
604 | + TEST_BCD(aas, 0x1234040a, CC_A, (CC_C | CC_A)); | ||
605 | + TEST_BCD(aas, 0x123405fa, CC_A, (CC_C | CC_A)); | ||
606 | + TEST_BCD(aas, 0x12340205, 0, (CC_C | CC_A)); | ||
607 | + TEST_BCD(aas, 0x12340306, 0, (CC_C | CC_A)); | ||
608 | + TEST_BCD(aas, 0x1234040a, 0, (CC_C | CC_A)); | ||
609 | + TEST_BCD(aas, 0x123405fa, 0, (CC_C | CC_A)); | ||
610 | + | ||
611 | + TEST_BCD(aam, 0x12340547, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_O | CC_A)); | ||
612 | + TEST_BCD(aad, 0x12340407, CC_A, (CC_C | CC_P | CC_Z | CC_S | CC_O | CC_A)); | ||
613 | +} | ||
614 | + | ||
615 | + | ||
543 | static void *call_end __init_call = NULL; | 616 | static void *call_end __init_call = NULL; |
544 | 617 | ||
545 | int main(int argc, char **argv) | 618 | int main(int argc, char **argv) |
@@ -557,5 +630,6 @@ int main(int argc, char **argv) | @@ -557,5 +630,6 @@ int main(int argc, char **argv) | ||
557 | test_jcc(); | 630 | test_jcc(); |
558 | test_lea(); | 631 | test_lea(); |
559 | test_floats(); | 632 | test_floats(); |
633 | + test_bcd(); | ||
560 | return 0; | 634 | return 0; |
561 | } | 635 | } |