Skip to content

Instantly share code, notes, and snippets.

@erique
Created September 14, 2022 18:48
Show Gist options
  • Save erique/f5aa608f6e4a6d987a4e1d423f9b890f to your computer and use it in GitHub Desktop.
Save erique/f5aa608f6e4a6d987a4e1d423f9b890f to your computer and use it in GitHub Desktop.
testing ___floatundidf
// m68k-amigaos-gcc -O0 -m68060 -mhard-float casttest.c -o casttest
#include <stdio.h>
int main()
{
printf("GCC %s\n", __VERSION__);
uint64_t i = 1;
double d = i;
printf("d = %f ; %s\n", d, (d == 1.0) ? "PASS" : "FAIL");
return 0;
}
@erique
Copy link
Author

erique commented Sep 15, 2022

Using m68k-amigaos-objdump -d casttest

     258:       4eb9 0000 8a7c  jsr 8a7c 8a7c ___floatundidf
     25e:       508f            addq.l #8,sp
     260:       2f01            move.l d1,-(sp)
     262:       2f00            move.l d0,-(sp)
     264:       f21f 5444       fdmoved (sp)+,fp0

PASS:

00008ba0 00008ba0 ___floatundidf:
    8ba0:       2f03            move.l d3,-(sp)
    8ba2:       202f 0008       move.l 8(sp),d0
    8ba6:       222f 000c       move.l 12(sp),d1
    8baa:       2600            move.l d0,d3
    8bac:       f203 4044       fdmove.l d3,fp0
    8bb0:       4a83            tst.l d3
    8bb2:       6c08            bge.s 8bbc 8bbc ___floatundidf+0x1c
    8bb4:       f23c 4466 4f80  fdadd.s #0e4.29497e+09,fp0
    8bba:       0000 
    8bbc:       f23c 4467 4f80  fdmul.s #0e4.29497e+09,fp0
    8bc2:       0000 
    8bc4:       f201 40c4       fdmove.l d1,fp1
    8bc8:       4a81            tst.l d1
    8bca:       6c08            bge.s 8bd4 8bd4 ___floatundidf+0x34
    8bcc:       f23c 44e6 4f80  fdadd.s #0e4.29497e+09,fp1
    8bd2:       0000 
    8bd4:       f200 00e6       fdaddx fp0,fp1
    8bd8:       f227 7480       fmoved fp1,-(sp)
    8bdc:       201f            move.l (sp)+,d0
    8bde:       221f            move.l (sp)+,d1
    8be0:       261f            move.l (sp)+,d3
    8be2:       4e75            rts

FAIL:

00008ba0 00008ba0 ___floatundidf:
    8ba0:       2f03            move.l d3,-(sp)
    8ba2:       202f 0008       move.l 8(sp),d0
    8ba6:       222f 000c       move.l 12(sp),d1
    8baa:       2600            move.l d0,d3
    8bac:       f203 4044       fdmove.l d3,fp0
    8bb0:       4a83            tst.l d3
    8bb2:       6c08            bge.s 8bbc 8bbc ___floatundidf+0x1c
    8bb4:       f23c 4466 4f80  fdadd.s #0e4.29497e+09,fp0
    8bba:       0000 
    8bbc:       f23c 4467 4f80  fdmul.s #0e4.29497e+09,fp0
    8bc2:       0000 
    8bc4:       f201 40c4       fdmove.l d1,fp1
    8bc8:       4a81            tst.l d1
    8bca:       6c08            bge.s 8bd4 8bd4 ___floatundidf+0x34
    8bcc:       f23c 44e6 4f80  fdadd.s #0e4.29497e+09,fp1
    8bd2:       0000 
    8bd4:       f200 0466       fdaddx fp1,fp0
    8bd8:       261f            move.l (sp)+,d3
    8bda:       4e75            rts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment