| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: unimpl_emul.S,v 1.4 2017/05/22 16:53:05 ragge Exp $ */ | | 1 | /* $NetBSD: unimpl_emul.S,v 1.5 2024/04/16 00:03:30 kalvisd Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Brandon Creighton. All rights reserved. | | 4 | * Copyright (c) 2001 Brandon Creighton. All rights reserved. |
5 | * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. | | 5 | * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -673,27 +673,27 @@ emodd: bsbw touser | | | @@ -673,27 +673,27 @@ emodd: bsbw touser |
673 | * If this is the case, set V in PSL. | | 673 | * If this is the case, set V in PSL. |
674 | */ | | 674 | */ |
675 | cmpl %r8, $0x20 | | 675 | cmpl %r8, $0x20 |
676 | blss 3f | | 676 | blss 3f |
677 | bisl2 $PSL_V, S_PSL | | 677 | bisl2 $PSL_V, S_PSL |
678 | 3: | | 678 | 3: |
679 | cmpl %r8, $0x38 | | 679 | cmpl %r8, $0x38 |
680 | blss 1f | | 680 | blss 1f |
681 | /* | | 681 | /* |
682 | * In the case where we have more than 55 bits in the integer, | | 682 | * In the case where we have more than 55 bits in the integer, |
683 | * there aren't any bits left for the fraction. Therefore we're | | 683 | * there aren't any bits left for the fraction. Therefore we're |
684 | * done here; TMPFRAC1 is equal to TMPFRACTGT and TMPFRAC2 is 0. | | 684 | * done here; TMPFRAC1 is equal to TMPFRACTGT and TMPFRAC2 is 0. |
685 | */ | | 685 | */ |
686 | movq $0f0.0, TMPFRAC2 | | 686 | movq $0d0.0, TMPFRAC2 |
687 | jmp 9f /* we're done, move on */ | | 687 | jmp 9f /* we're done, move on */ |
688 | 1: | | 688 | 1: |
689 | /* | | 689 | /* |
690 | * We do the mod by using ASHQ to shift and truncate the bits. | | 690 | * We do the mod by using ASHQ to shift and truncate the bits. |
691 | * Before that happens, we have to arrange the bits in a quadword such | | 691 | * Before that happens, we have to arrange the bits in a quadword such |
692 | * that the significance increases from start to finish. | | 692 | * that the significance increases from start to finish. |
693 | */ | | 693 | */ |
694 | | | 694 | |
695 | movab TMPFRACTGT, %r0 | | 695 | movab TMPFRACTGT, %r0 |
696 | movab TMPFRAC1, %r1 | | 696 | movab TMPFRAC1, %r1 |
697 | movb (%r0), 7(%r1) | | 697 | movb (%r0), 7(%r1) |
698 | bisb2 $0x80, 7(%r1) | | 698 | bisb2 $0x80, 7(%r1) |
699 | movw 2(%r0), 5(%r1) | | 699 | movw 2(%r0), 5(%r1) |
| @@ -717,27 +717,27 @@ emodd: bsbw touser | | | @@ -717,27 +717,27 @@ emodd: bsbw touser |
717 | movw 5(%r0), 2(%r1) | | 717 | movw 5(%r0), 2(%r1) |
718 | movw 3(%r0), 4(%r1) | | 718 | movw 3(%r0), 4(%r1) |
719 | movw 1(%r0), 6(%r1) | | 719 | movw 1(%r0), 6(%r1) |
720 | | | 720 | |
721 | # we have the integer in TMPFRAC1, now get the fraction in TMPFRAC2 | | 721 | # we have the integer in TMPFRAC1, now get the fraction in TMPFRAC2 |
722 | subd3 TMPFRAC1, TMPFRACTGT, TMPFRAC2 | | 722 | subd3 TMPFRAC1, TMPFRACTGT, TMPFRAC2 |
723 | jmp 9f | | 723 | jmp 9f |
724 | | | 724 | |
725 | 8: | | 725 | 8: |
726 | /* | | 726 | /* |
727 | * We are less than 1.0; TMPFRAC1 should be 0, and TMPFRAC2 should | | 727 | * We are less than 1.0; TMPFRAC1 should be 0, and TMPFRAC2 should |
728 | * be equal to TMPFRACTGT. | | 728 | * be equal to TMPFRACTGT. |
729 | */ | | 729 | */ |
730 | movd $0f0.0, TMPFRAC1 | | 730 | movd $0d0.0, TMPFRAC1 |
731 | movd TMPFRACTGT, TMPFRAC2 | | 731 | movd TMPFRACTGT, TMPFRAC2 |
732 | 9: | | 732 | 9: |
733 | /* | | 733 | /* |
734 | * We're done. We can use CVTDL here, since EMODD is supposed to | | 734 | * We're done. We can use CVTDL here, since EMODD is supposed to |
735 | * truncate. | | 735 | * truncate. |
736 | */ | | 736 | */ |
737 | cvtdl TMPFRAC1, %r4 | | 737 | cvtdl TMPFRAC1, %r4 |
738 | bsbw getaddr_byte | | 738 | bsbw getaddr_byte |
739 | movl %r4, (%r0) | | 739 | movl %r4, (%r0) |
740 | | | 740 | |
741 | bsbw getaddr_byte | | 741 | bsbw getaddr_byte |
742 | movq TMPFRAC2, (%r0) | | 742 | movq TMPFRAC2, (%r0) |
743 | movd TMPFRAC2, %r0 /* move this here so we can test it later */ | | 743 | movd TMPFRAC2, %r0 /* move this here so we can test it later */ |
| @@ -753,27 +753,27 @@ emodd: bsbw touser | | | @@ -753,27 +753,27 @@ emodd: bsbw touser |
753 | * negative; if it is, set N. | | 753 | * negative; if it is, set N. |
754 | */ | | 754 | */ |
755 | tstd %r0 | | 755 | tstd %r0 |
756 | bgeq 1f /* branch if N == 0 */ | | 756 | bgeq 1f /* branch if N == 0 */ |
757 | bisl2 $PSL_N, S_PSL | | 757 | bisl2 $PSL_N, S_PSL |
758 | 1: | | 758 | 1: |
759 | brw goback | | 759 | brw goback |
760 | zeroexit: | | 760 | zeroexit: |
761 | /* Z == 1, everything else has been cleared already */ | | 761 | /* Z == 1, everything else has been cleared already */ |
762 | bisl2 $PSL_Z, S_PSL | | 762 | bisl2 $PSL_Z, S_PSL |
763 | bsbw getaddr_byte | | 763 | bsbw getaddr_byte |
764 | movl $0x0, (%r0) | | 764 | movl $0x0, (%r0) |
765 | bsbw getaddr_byte | | 765 | bsbw getaddr_byte |
766 | movd $0f0, (%r0) | | 766 | movd $0d0, (%r0) |
767 | brw goback | | 767 | brw goback |
768 | | | 768 | |
769 | | | 769 | |
770 | | | 770 | |
771 | /* | | 771 | /* |
772 | * bitcnt: counts significant bits backwards in a quadword | | 772 | * bitcnt: counts significant bits backwards in a quadword |
773 | * returns number of bits, unless there aren't any; | | 773 | * returns number of bits, unless there aren't any; |
774 | * in that case it will return $0xffffffff | | 774 | * in that case it will return $0xffffffff |
775 | */ | | 775 | */ |
776 | bitcnt: | | 776 | bitcnt: |
777 | .word 0xffe /* %r1-%r12 */ | | 777 | .word 0xffe /* %r1-%r12 */ |
778 | | | 778 | |
779 | /* | | 779 | /* |