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#include <picolibc.h> 23 24#if __CODE__==32 25#define RET prts 26#else 27#define RET rts 28#endif 29 30#define EXTPSISI_SN(r_msw,r_lsw,sp) ; \ 31 .global __extpsisi##r_msw ; \ 32__extpsisi##r_msw: ; \ 33 mov r_msw,r_lsw ; \ 34 stc sp,r_msw ; \ 35 RET 36 37 EXTPSISI_SN(r2,r3,dp) 38 EXTPSISI_SN(r4,r5,ep) 39 40 41#define ADDPSI_AR_RN(sr,an,r_msw,r_lsw) \ 42 .global __addpsi##an##r_msw ; \ 43__addpsi##an##r_msw: ; \ 44 stc sr,@-sp ; \ 45 add an,r_lsw ; \ 46 addx @sp+,r_msw ; \ 47 RET 48 49 ADDPSI_AR_RN(dp,r2,r0,r1) 50 ADDPSI_AR_RN(dp,r2,r3,r4) 51 ADDPSI_AR_RN(ep,r4,r0,r1) 52 ADDPSI_AR_RN(ep,r4,r1,r2) 53 ADDPSI_AR_RN(ep,r4,r3,r4) 54 ADDPSI_AR_RN(ep,r4,r5,fp) 55 56 ADDPSI_AR_RN(tp,fp,r0,r1) 57 58 59#define ADDPSI_RN_AR(r_msw,r_lsw,sr,an,t_msw,t_lsw) \ 60 .global __addpsi##r_msw##an ; \ 61__addpsi##r_msw##an: ; \ 62 mov.w t_msw,@-sp ; \ 63 mov.w t_lsw,@-sp ; \ 64 stc sr,t_msw ; \ 65 mov an,t_lsw ; \ 66 add r_lsw,t_lsw ; \ 67 addx r_msw,t_msw ; \ 68 ldc t_msw,sr ; \ 69 mov.w t_lsw,an ; \ 70 mov.w @sp+,t_lsw ; \ 71 mov.w @sp+,t_msw ; \ 72 RET 73 74 ADDPSI_RN_AR(r0,r1,dp,r2,r4,r5) 75 ADDPSI_RN_AR(r0,r1,ep,r4,r2,r3) 76 77 78 79#define EXTPSIHI_RN_RN(rm,r_msw,r_lsw) ; \ 80 .global __extpsihi##rm##r_msw ; \ 81__extpsihi##rm##r_msw: ; \ 82 mov rm,r_lsw ; \ 83 clr.w r_msw ; \ 84 RET 85 86 EXTPSIHI_RN_RN(r3,r0,r1) 87 EXTPSIHI_RN_RN(r4,r0,r1) 88 EXTPSIHI_RN_RN(r5,r0,r1) 89 EXTPSIHI_RN_RN(r2,r0,r1) 90 91 92 93/* ifdefed out, because gcc doesn't like the # character in the above 94 macro. The macro expands into an assembly languange comment anyways, 95 so it serves no useful purpose. */ 96#if 0 97#define EXTPSIHI_RN_SN(rm,r_msw,r_lsw) ; \ 98 .global __extpsihi##rm##r_lsw ; \ 99__extpsihi##rm##r_lsw: ; \ 100 mov rm,r_lsw ; \ 101 ldc \#0,r_msw ; \ 102 RET 103 104 EXTPSIHI_RN_SN(r0,dp,r2) 105 EXTPSIHI_RN_SN(r0,ep,r4) 106 EXTPSIHI_RN_SN(r1,dp,r2) 107 EXTPSIHI_RN_SN(r1,ep,r4) 108 EXTPSIHI_RN_SN(r3,dp,r2) 109 EXTPSIHI_RN_SN(r3,ep,r4) 110 EXTPSIHI_RN_SN(r5,dp,r2) 111 EXTPSIHI_RN_SN(r5,ep,r4) 112 EXTPSIHI_RN_SN(r2,ep,r4) 113#endif 114 115 116#define EXTPSISI_RN(r_msw,r_lsw) ; \ 117 .global __extpsisi##r_msw ; \ 118__extpsisi##r_msw: ; \ 119 RET 120 121 EXTPSISI_RN(r0,r1) 122 123 124 125#define ADDPSI_SA_SB(sa,ra,sb,rb) ; \ 126 .global __addpsi##ra##rb ; \ 127__addpsi##ra##rb: ; \ 128 mov.w r0,@-sp ; \ 129 mov.w r1,@-sp ; \ 130 stc sa,r0 ; \ 131 stc sb,r1 ; \ 132 add.w ra,rb ; \ 133 addx r0,r1 ; \ 134 ldc r1,sb ; \ 135 mov.w @sp+,r1 ; \ 136 mov.w @sp+,r0 ; \ 137 RET 138 139 140 ADDPSI_SA_SB(dp,r2,ep,r4) 141 ADDPSI_SA_SB(ep,r4,dp,r2) 142 ADDPSI_SA_SB(tp,fp,dp,r2) 143 ADDPSI_SA_SB(tp,fp,ep,r4) 144 145 ADDPSI_SA_SB(dp,r2,dp,r2) 146 147 148 149 .global __addpsir0r0 150__addpsir0r0: 151 add.w r1,r1 152 addx r0,r0 153 RET 154 155