Commit c5e9815da4e67d42d2a0f8dce4282e8e6d691b88
1 parent
9d8e9c09
added bcd tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@22 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
17 additions
and
4 deletions
tests/Makefile
... | ... | @@ -2,7 +2,7 @@ CC=gcc |
2 | 2 | CFLAGS=-Wall -O2 -g |
3 | 3 | LDFLAGS= |
4 | 4 | |
5 | -TESTS=hello test1 test2 sha1 test-i386 | |
5 | +TESTS=hello test2 sha1 test-i386 | |
6 | 6 | TESTS+=op-i386.o #op-i386.o op-ppc.o op-arm.o op-mips.o op-sparc.o |
7 | 7 | |
8 | 8 | GEMU=../gemu |
... | ... | @@ -12,9 +12,6 @@ all: $(TESTS) |
12 | 12 | hello: hello.c |
13 | 13 | $(CC) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $< |
14 | 14 | |
15 | -test1: test1.c | |
16 | - $(CC) $(CFLAGS) -static $(LDFLAGS) -o $@ $< | |
17 | - | |
18 | 15 | test2: test2.c |
19 | 16 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< |
20 | 17 | ... | ... |
tests/test-i386.c
... | ... | @@ -490,6 +490,9 @@ void test_fcvt(double a) |
490 | 490 | la = a; |
491 | 491 | printf("(float)%f = %f\n", a, fa); |
492 | 492 | printf("(long double)%f = %Lf\n", a, la); |
493 | + printf("a=%016Lx\n", *(long long *)&a); | |
494 | + printf("la=%016Lx %04x\n", *(long long *)&la, | |
495 | + *(unsigned short *)((char *)(&la) + 8)); | |
493 | 496 | printf("a=%f floor(a)=%f\n", a, floor(a)); |
494 | 497 | printf("a=%f ceil(a)=%f\n", a, ceil(a)); |
495 | 498 | printf("a=%f rint(a)=%f\n", a, rint(a)); |
... | ... | @@ -511,6 +514,17 @@ void test_fconst(void) |
511 | 514 | TEST(z); |
512 | 515 | } |
513 | 516 | |
517 | +void test_fbcd(double a) | |
518 | +{ | |
519 | + unsigned short bcd[5]; | |
520 | + double b; | |
521 | + | |
522 | + asm("fbstp %0" : "=m" (bcd[0]) : "t" (a) : "st"); | |
523 | + asm("fbld %1" : "=t" (b) : "m" (bcd[0])); | |
524 | + printf("a=%f bcd=%04x%04x%04x%04x%04x b=%f\n", | |
525 | + a, bcd[4], bcd[3], bcd[2], bcd[1], bcd[0], b); | |
526 | +} | |
527 | + | |
514 | 528 | void test_floats(void) |
515 | 529 | { |
516 | 530 | test_fops(2, 3); |
... | ... | @@ -522,6 +536,8 @@ void test_floats(void) |
522 | 536 | test_fcvt(-1.0/9.0); |
523 | 537 | test_fcvt(1e30); |
524 | 538 | test_fconst(); |
539 | + test_fbcd(1234567890123456); | |
540 | + test_fbcd(-123451234567890); | |
525 | 541 | } |
526 | 542 | |
527 | 543 | static void *call_end __init_call = NULL; | ... | ... |