📄 lib1funcs.asm
字号:
/* libgcc routines for NEC V850. Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option) anylater version.In addition to the permissions in the GNU General Public License, theFree Software Foundation gives you unlimited permission to link thecompiled version of this file into combinations with other programs,and to distribute those combinations without any restriction comingfrom the use of this file. (The General Public License restrictionsdo apply in other respects; for example, they cover modification ofthe file, and distribution when not linked into a combineexecutable.)This file is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; see the file COPYING. If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA. */#ifdef L_mulsi3 .text .globl ___mulsi3 .type ___mulsi3,@function___mulsi3:#ifdef __v850__ /* #define SHIFT 12 #define MASK ((1 << SHIFT) - 1) #define STEP(i, j) \ ({ \ short a_part = (a >> (i)) & MASK; \ short b_part = (b >> (j)) & MASK; \ int res = (((int) a_part) * ((int) b_part)); \ res; \ }) int __mulsi3 (unsigned a, unsigned b) { return STEP (0, 0) + ((STEP (SHIFT, 0) + STEP (0, SHIFT)) << SHIFT) + ((STEP (0, 2 * SHIFT) + STEP (SHIFT, SHIFT) + STEP (2 * SHIFT, 0)) << (2 * SHIFT)); }*/ mov r6, r14 movea lo(32767), r0, r10 and r10, r14 mov r7, r15 and r10, r15 shr 15, r6 mov r6, r13 and r10, r13 shr 15, r7 mov r7, r12 and r10, r12 shr 15, r6 shr 15, r7 mov r14, r10 mulh r15, r10 mov r14, r11 mulh r12, r11 mov r13, r16 mulh r15, r16 mulh r14, r7 mulh r15, r6 add r16, r11 mulh r13, r12 shl 15, r11 add r11, r10 add r12, r7 add r6, r7 shl 30, r7 add r7, r10 jmp [r31]#endif /* __v850__ */#if defined(__v850e__) || defined(__v850ea__) /* This routine is almost unneccesarry because gcc generates the MUL instruction for the RTX mulsi3. But if someone wants to link his application with previsously compiled v850 objects then they will need this function. */ /* It isn't good to put the inst sequence as below; mul r7, r6, mov r6, r10, r0 In this case, there is a RAW hazard between them. MUL inst takes 2 cycle in EX stage, then MOV inst must wait 1cycle. */ mov r7, r10 mul r6, r10, r0 jmp [r31]#endif /* __v850e__ */ .size ___mulsi3,.-___mulsi3#endif /* L_mulsi3 */#ifdef L_udivsi3 .text .global ___udivsi3 .type ___udivsi3,@function___udivsi3:#ifdef __v850__ mov 1,r12 mov 0,r10 cmp r6,r7 bnl .L12 movhi hi(-2147483648),r0,r13 cmp r0,r7 blt .L12.L4: shl 1,r7 shl 1,r12 cmp r6,r7 bnl .L12 cmp r0,r12 be .L8 mov r7,r19 and r13,r19 be .L4 br .L12.L9: cmp r7,r6 bl .L10 sub r7,r6 or r12,r10.L10: shr 1,r12 shr 1,r7.L12: cmp r0,r12 bne .L9.L8: jmp [r31]#else /* defined(__v850e__) */ /* See comments at end of __mulsi3. */ mov r6, r10 divu r7, r10, r0 jmp [r31] #endif /* __v850e__ */ .size ___udivsi3,.-___udivsi3#endif#ifdef L_divsi3 .text .globl ___divsi3 .type ___divsi3,@function___divsi3:#ifdef __v850__ add -8,sp st.w r31,4[sp] st.w r22,0[sp] mov 1,r22 tst r7,r7 bp .L3 subr r0,r7 subr r0,r22.L3: tst r6,r6 bp .L4 subr r0,r6 subr r0,r22.L4: jarl ___udivsi3,r31 cmp r0,r22 bp .L7 subr r0,r10.L7: ld.w 0[sp],r22 ld.w 4[sp],r31 add 8,sp jmp [r31]#else /* defined(__v850e__) */ /* See comments at end of __mulsi3. */ mov r6, r10 div r7, r10, r0 jmp [r31]#endif /* __v850e__ */ .size ___divsi3,.-___divsi3#endif#ifdef L_umodsi3 .text .globl ___umodsi3 .type ___umodsi3,@function___umodsi3:#ifdef __v850__ add -12,sp st.w r31,8[sp] st.w r7,4[sp] st.w r6,0[sp] jarl ___udivsi3,r31 ld.w 4[sp],r7 mov r10,r6 jarl ___mulsi3,r31 ld.w 0[sp],r6 subr r6,r10 ld.w 8[sp],r31 add 12,sp jmp [r31]#else /* defined(__v850e__) */ /* See comments at end of __mulsi3. */ divu r7, r6, r10 jmp [r31]#endif /* __v850e__ */ .size ___umodsi3,.-___umodsi3#endif /* L_umodsi3 */#ifdef L_modsi3 .text .globl ___modsi3 .type ___modsi3,@function___modsi3:#ifdef __v850__ add -12,sp st.w r31,8[sp] st.w r7,4[sp] st.w r6,0[sp] jarl ___divsi3,r31 ld.w 4[sp],r7 mov r10,r6 jarl ___mulsi3,r31 ld.w 0[sp],r6 subr r6,r10 ld.w 8[sp],r31 add 12,sp jmp [r31]#else /* defined(__v850e__) */ /* See comments at end of __mulsi3. */ div r7, r6, r10 jmp [r31]#endif /* __v850e__ */ .size ___modsi3,.-___modsi3#endif /* L_modsi3 */#ifdef L_save_2 .text .align 2 .globl __save_r2_r29 .type __save_r2_r29,@function /* Allocate space and save registers 2, 20 .. 29 on the stack */ /* Called via: jalr __save_r2_r29,r10 */__save_r2_r29: mov ep,r1 addi -44,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] sst.w r23,24[ep] sst.w r22,28[ep] sst.w r21,32[ep] sst.w r20,36[ep] sst.w r2,40[ep] mov r1,ep jmp [r10] .size __save_r2_r29,.-__save_r2_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r2_r29 */ .align 2 .globl __return_r2_r29 .type __return_r2_r29,@function__return_r2_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 sld.w 24[ep],r23 sld.w 28[ep],r22 sld.w 32[ep],r21 sld.w 36[ep],r20 sld.w 40[ep],r2 addi 44,sp,sp mov r1,ep jmp [r31] .size __return_r2_r29,.-__return_r2_r29#endif /* L_save_2 */#ifdef L_save_20 .text .align 2 .globl __save_r20_r29 .type __save_r20_r29,@function /* Allocate space and save registers 20 .. 29 on the stack */ /* Called via: jalr __save_r20_r29,r10 */__save_r20_r29: mov ep,r1 addi -40,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] sst.w r23,24[ep] sst.w r22,28[ep] sst.w r21,32[ep] sst.w r20,36[ep] mov r1,ep jmp [r10] .size __save_r20_r29,.-__save_r20_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r20_r29 */ .align 2 .globl __return_r20_r29 .type __return_r20_r29,@function__return_r20_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 sld.w 24[ep],r23 sld.w 28[ep],r22 sld.w 32[ep],r21 sld.w 36[ep],r20 addi 40,sp,sp mov r1,ep jmp [r31] .size __return_r20_r29,.-__return_r20_r29#endif /* L_save_20 */#ifdef L_save_21 .text .align 2 .globl __save_r21_r29 .type __save_r21_r29,@function /* Allocate space and save registers 21 .. 29 on the stack */ /* Called via: jalr __save_r21_r29,r10 */__save_r21_r29: mov ep,r1 addi -36,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] sst.w r23,24[ep] sst.w r22,28[ep] sst.w r21,32[ep] mov r1,ep jmp [r10] .size __save_r21_r29,.-__save_r21_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r21_r29 */ .align 2 .globl __return_r21_r29 .type __return_r21_r29,@function__return_r21_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 sld.w 24[ep],r23 sld.w 28[ep],r22 sld.w 32[ep],r21 addi 36,sp,sp mov r1,ep jmp [r31] .size __return_r21_r29,.-__return_r21_r29#endif /* L_save_21 */#ifdef L_save_22 .text .align 2 .globl __save_r22_r29 .type __save_r22_r29,@function /* Allocate space and save registers 22 .. 29 on the stack */ /* Called via: jalr __save_r22_r29,r10 */__save_r22_r29: mov ep,r1 addi -32,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] sst.w r23,24[ep] sst.w r22,28[ep] mov r1,ep jmp [r10] .size __save_r22_r29,.-__save_r22_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r22_r29 */ .align 2 .globl __return_r22_r29 .type __return_r22_r29,@function__return_r22_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 sld.w 24[ep],r23 sld.w 28[ep],r22 addi 32,sp,sp mov r1,ep jmp [r31] .size __return_r22_r29,.-__return_r22_r29#endif /* L_save_22 */#ifdef L_save_23 .text .align 2 .globl __save_r23_r29 .type __save_r23_r29,@function /* Allocate space and save registers 23 .. 29 on the stack */ /* Called via: jalr __save_r23_r29,r10 */__save_r23_r29: mov ep,r1 addi -28,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] sst.w r23,24[ep] mov r1,ep jmp [r10] .size __save_r23_r29,.-__save_r23_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r23_r29 */ .align 2 .globl __return_r23_r29 .type __return_r23_r29,@function__return_r23_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 sld.w 24[ep],r23 addi 28,sp,sp mov r1,ep jmp [r31] .size __return_r23_r29,.-__return_r23_r29#endif /* L_save_23 */#ifdef L_save_24 .text .align 2 .globl __save_r24_r29 .type __save_r24_r29,@function /* Allocate space and save registers 24 .. 29 on the stack */ /* Called via: jalr __save_r24_r29,r10 */__save_r24_r29: mov ep,r1 addi -24,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] sst.w r24,20[ep] mov r1,ep jmp [r10] .size __save_r24_r29,.-__save_r24_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r24_r29 */ .align 2 .globl __return_r24_r29 .type __return_r24_r29,@function__return_r24_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 sld.w 20[ep],r24 addi 24,sp,sp mov r1,ep jmp [r31] .size __return_r24_r29,.-__return_r24_r29#endif /* L_save_24 */#ifdef L_save_25 .text .align 2 .globl __save_r25_r29 .type __save_r25_r29,@function /* Allocate space and save registers 25 .. 29 on the stack */ /* Called via: jalr __save_r25_r29,r10 */__save_r25_r29: mov ep,r1 addi -20,sp,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] sst.w r25,16[ep] mov r1,ep jmp [r10] .size __save_r25_r29,.-__save_r25_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r25_r29 */ .align 2 .globl __return_r25_r29 .type __return_r25_r29,@function__return_r25_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 sld.w 16[ep],r25 addi 20,sp,sp mov r1,ep jmp [r31] .size __return_r25_r29,.-__return_r25_r29#endif /* L_save_25 */#ifdef L_save_26 .text .align 2 .globl __save_r26_r29 .type __save_r26_r29,@function /* Allocate space and save registers 26 .. 29 on the stack */ /* Called via: jalr __save_r26_r29,r10 */__save_r26_r29: mov ep,r1 add -16,sp mov sp,ep sst.w r29,0[ep] sst.w r28,4[ep] sst.w r27,8[ep] sst.w r26,12[ep] mov r1,ep jmp [r10] .size __save_r26_r29,.-__save_r26_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r26_r29 */ .align 2 .globl __return_r26_r29 .type __return_r26_r29,@function__return_r26_r29: mov ep,r1 mov sp,ep sld.w 0[ep],r29 sld.w 4[ep],r28 sld.w 8[ep],r27 sld.w 12[ep],r26 addi 16,sp,sp mov r1,ep jmp [r31] .size __return_r26_r29,.-__return_r26_r29#endif /* L_save_26 */#ifdef L_save_27 .text .align 2 .globl __save_r27_r29 .type __save_r27_r29,@function /* Allocate space and save registers 27 .. 29 on the stack */ /* Called via: jalr __save_r27_r29,r10 */__save_r27_r29: add -12,sp st.w r29,0[sp] st.w r28,4[sp] st.w r27,8[sp] jmp [r10] .size __save_r27_r29,.-__save_r27_r29
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -