1/* 2Copyright (c) 1990 The Regents of the University of California. 3All rights reserved. 4 5Redistribution and use in source and binary forms are permitted 6provided that the above copyright notice and this paragraph are 7duplicated in all such forms and that any documentation, 8and/or other materials related to such 9distribution and use acknowledge that the software was developed 10by the University of California, Berkeley. The name of the 11University may not be used to endorse or promote products derived 12from this software without specific prior written permission. 13THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17/* convert psi to si inplace 18 19Note that `fp' below isn't a segment register. 20It's r6, the frame pointer. */ 21 22#if __CODE__==32 23#define RET prts 24#else 25#define RET rts 26#endif 27 28#define EXTPSISI_SN(r_msw,r_lsw,sp) ; \ 29 .global __extpsisi##r_msw ; \ 30__extpsisi##r_msw: ; \ 31 mov r_msw,r_lsw ; \ 32 stc sp,r_msw ; \ 33 RET 34 35 EXTPSISI_SN(r2,r3,dp) 36 EXTPSISI_SN(r4,r5,ep) 37 38 39#define ADDPSI_AR_RN(sr,an,r_msw,r_lsw) \ 40 .global __addpsi##an##r_msw ; \ 41__addpsi##an##r_msw: ; \ 42 stc sr,@-sp ; \ 43 add an,r_lsw ; \ 44 addx @sp+,r_msw ; \ 45 RET 46 47 ADDPSI_AR_RN(dp,r2,r0,r1) 48 ADDPSI_AR_RN(dp,r2,r3,r4) 49 ADDPSI_AR_RN(ep,r4,r0,r1) 50 ADDPSI_AR_RN(ep,r4,r1,r2) 51 ADDPSI_AR_RN(ep,r4,r3,r4) 52 ADDPSI_AR_RN(ep,r4,r5,fp) 53 54 ADDPSI_AR_RN(tp,fp,r0,r1) 55 56 57#define ADDPSI_RN_AR(r_msw,r_lsw,sr,an,t_msw,t_lsw) \ 58 .global __addpsi##r_msw##an ; \ 59__addpsi##r_msw##an: ; \ 60 mov.w t_msw,@-sp ; \ 61 mov.w t_lsw,@-sp ; \ 62 stc sr,t_msw ; \ 63 mov an,t_lsw ; \ 64 add r_lsw,t_lsw ; \ 65 addx r_msw,t_msw ; \ 66 ldc t_msw,sr ; \ 67 mov.w t_lsw,an ; \ 68 mov.w @sp+,t_lsw ; \ 69 mov.w @sp+,t_msw ; \ 70 RET 71 72 ADDPSI_RN_AR(r0,r1,dp,r2,r4,r5) 73 ADDPSI_RN_AR(r0,r1,ep,r4,r2,r3) 74 75 76 77#define EXTPSIHI_RN_RN(rm,r_msw,r_lsw) ; \ 78 .global __extpsihi##rm##r_msw ; \ 79__extpsihi##rm##r_msw: ; \ 80 mov rm,r_lsw ; \ 81 clr.w r_msw ; \ 82 RET 83 84 EXTPSIHI_RN_RN(r3,r0,r1) 85 EXTPSIHI_RN_RN(r4,r0,r1) 86 EXTPSIHI_RN_RN(r5,r0,r1) 87 EXTPSIHI_RN_RN(r2,r0,r1) 88 89 90 91/* ifdefed out, because gcc doesn't like the # character in the above 92 macro. The macro expands into an assembly languange comment anyways, 93 so it serves no useful purpose. */ 94#if 0 95#define EXTPSIHI_RN_SN(rm,r_msw,r_lsw) ; \ 96 .global __extpsihi##rm##r_lsw ; \ 97__extpsihi##rm##r_lsw: ; \ 98 mov rm,r_lsw ; \ 99 ldc \#0,r_msw ; \ 100 RET 101 102 EXTPSIHI_RN_SN(r0,dp,r2) 103 EXTPSIHI_RN_SN(r0,ep,r4) 104 EXTPSIHI_RN_SN(r1,dp,r2) 105 EXTPSIHI_RN_SN(r1,ep,r4) 106 EXTPSIHI_RN_SN(r3,dp,r2) 107 EXTPSIHI_RN_SN(r3,ep,r4) 108 EXTPSIHI_RN_SN(r5,dp,r2) 109 EXTPSIHI_RN_SN(r5,ep,r4) 110 EXTPSIHI_RN_SN(r2,ep,r4) 111#endif 112 113 114#define EXTPSISI_RN(r_msw,r_lsw) ; \ 115 .global __extpsisi##r_msw ; \ 116__extpsisi##r_msw: ; \ 117 RET 118 119 EXTPSISI_RN(r0,r1) 120 121 122 123#define ADDPSI_SA_SB(sa,ra,sb,rb) ; \ 124 .global __addpsi##ra##rb ; \ 125__addpsi##ra##rb: ; \ 126 mov.w r0,@-sp ; \ 127 mov.w r1,@-sp ; \ 128 stc sa,r0 ; \ 129 stc sb,r1 ; \ 130 add.w ra,rb ; \ 131 addx r0,r1 ; \ 132 ldc r1,sb ; \ 133 mov.w @sp+,r1 ; \ 134 mov.w @sp+,r0 ; \ 135 RET 136 137 138 ADDPSI_SA_SB(dp,r2,ep,r4) 139 ADDPSI_SA_SB(ep,r4,dp,r2) 140 ADDPSI_SA_SB(tp,fp,dp,r2) 141 ADDPSI_SA_SB(tp,fp,ep,r4) 142 143 ADDPSI_SA_SB(dp,r2,dp,r2) 144 145 146 147 .global __addpsir0r0 148__addpsir0r0: 149 add.w r1,r1 150 addx r0,r0 151 RET 152 153