📄 lib1funcs.asm
字号:
/* libgcc1 routines for NEC V850. Copyright (C) 1996, 1997 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 with other programs, and to distributethose programs without any restriction coming from the use of thisfile. (The General Public License restrictions do apply in otherrespects; for example, they cover modification of the file, anddistribution when not linked into another program.)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. *//* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */#ifdef L_mulsi3 .text .globl ___mulsi3 .type ___mulsi3,@function/* * In order to not deal with negative numbers (mulh is a signed multiply * and we want an unsigned multiply, code the multiplication as a series * of 7 bit multiplies). * * int __mulsi3 (unsigned a, unsigned b) * { * int i, j; * int ret = 0; * * for (i = 0; i < 32; i += 7) * { * short a_part = a & 0x7f; * unsigned b_tmp = b; * a >>= 7; * * for (j = 0; (i+j) < 32; j += 7) * { * short b_part = b_tmp & 0x7f; * ret += (((int)a_part) * ((int)b_part)) << (i+j); * b_tmp >>= 7; * } * } * * return ret; * } */___mulsi3: mov 0,r10 /* total */ mov 0,r14 /* i = 0, index for multiply a's part */ movea lo(31),r0,r16 /* upper bounds for loop */.L5: mov r7,r13 /* b_tmp = b */ andi 0x7f,r6,r15 /* a_part = (a & 127) */ shr 7,r6 /* a >>= 7 */ mov r14,r12 /* i+j = i */.L9: andi 0x7f,r13,r11 /* b_part = (b_tmp & 127) */ mulh r15,r11 /* ((int)a_part) * ((int)b_part) */ shr 7,r13 /* b_tmp >>= 7 */ shl r12,r11 /* (((int)a_part) * ((int)b_part)) << (i+j) */ add r11,r10 /* ret += (((int)a_part) * ((int)b_part)) << (i+j) */ add 7,r12 /* i+j += 7 */ cmp r16,r12 /* i+j < 32 */ ble .L9 add 7,r14 /* i += 7 */ cmp r16,r14 /* i < 32 */ ble .L5 jmp [r31] /* return */ .size ___mulsi3,.-___mulsi3#endif#ifdef L_udivsi3 .text .global ___udivsi3 .type ___udivsi3,@function___udivsi3: 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] .size ___udivsi3,.-___udivsi3#endif#ifdef L_divsi3 .text .globl ___divsi3 .type ___divsi3,@function___divsi3: 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] .size ___divsi3,.-___divsi3#endif#ifdef L_umodsi3 .text .globl ___umodsi3 .type ___umodsi3,@function___umodsi3: 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] .size ___umodsi3,.-___umodsi3#endif /* L_umodsi3 */#ifdef L_modsi3 .text .globl ___modsi3 .type ___modsi3,@function___modsi3: 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] .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 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r27_r29 */ .align 2 .globl __return_r27_r29 .type __return_r27_r29,@function__return_r27_r29: ld.w 0[sp],r29 ld.w 4[sp],r28 ld.w 8[sp],r27 add 12,sp jmp [r31] .size __return_r27_r29,.-__return_r27_r29#endif /* L_save_27 */#ifdef L_save_28 .text .align 2 .globl __save_r28_r29 .type __save_r28_r29,@function /* Allocate space and save registers 28,29 on the stack */ /* Called via: jalr __save_r28_r29,r10 */__save_r28_r29: add -8,sp st.w r29,0[sp] st.w r28,4[sp] jmp [r10] .size __save_r28_r29,.-__save_r28_r29 /* Restore saved registers, deallocate stack and return to the user */ /* Called via: jr __return_r28_r29 */ .align 2 .globl __return_r28_r29 .type __return_r28_r29,@function__return_r28_r29: ld.w 0[sp],r29 ld.w 4[sp],r28 add 8,sp jmp [r31] .size __return_r28_r29,.-__return_r28_r29#endif /* L_save_28 */#ifdef L_save_29 .text .align 2 .globl __save_r29 .type __save_r29,@function /* Allocate space and save register 29 on the stack */ /* Called via: jalr __save_r29,r10 */__save_r29: add -4,sp st.w r29,0[sp] jmp [r10] .size __save_r29,.-__save_r29 /* Restore saved register 29, deallocate stack and return to the user */ /* Called via: jr __return_r29 */ .align 2 .globl __return_r29 .type __return_r29,@function__return_r29: ld.w 0[sp],r29 add 4,sp jmp [r31]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -