📄 lib1funcs.asm
字号:
; Low level integer divide, multiply, remainder, etc routines for the HPPA.; Copyright (C) 1995 Free Software Foundation, Inc.; This file is part of GNU CC.; GNU CC is free software; you can redistribute it and/or modify; it under the terms of the GNU General Public License as published by; the Free Software Foundation; either version 2, or (at your option); any later version.; In addition to the permissions in the GNU General Public License, the; Free Software Foundation gives you unlimited permission to link the; compiled version of this file with other programs, and to distribute; those programs without any restriction coming from the use of this; file. (The General Public License restrictions do apply in other; respects; for example, they cover modification of the file, and; distribution when not linked into another program.); GNU CC is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.; You should have received a copy of the GNU General Public License; along with GNU CC; see the file COPYING. If not, write to; the Free Software Foundation, 59 Temple Place - Suite 330,; Boston, MA 02111-1307, USA.#ifdef L_dyncall .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .export $$dyncall$$dyncall .proc .callinfo frame=0,no_calls .entry bb,>=,n %r22,30,L$1 ; branch if not plabel address depi 0,31,2,%r22 ; clear the two least significant bits ldw 4(%sr0,%r22),%r19 ; load new LTP value ldw 0(%sr0,%r22),%r22 ; load address of targetL$1 ldsid (%sr0,%r22),%r1 ; get the "space ident" selected by r22 mtsp %r1,%sr0 ; move that space identifier into sr0 be 0(%sr0,%r22) ; branch to the real target stw %r2,-24(%sr0,%r30) ; save return address into frame marker .exit .procend#endif#ifdef L_multiply#define op0 %r26#define op1 %r25#define res %r29#define ret %r31#define tmp %r1 .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .align 4 .export $$mulU .export $$mulI$$mulU$$mulI .proc .callinfo frame=0,no_calls .entry addi,tr 0,%r0,res ; clear out res, skip next insnL$loop zdep op1,26,27,op1 ; shift up op1 by 5L$lo zdep op0,30,5,tmp ; extract next 5 bits and shift up blr tmp,%r0 extru op0,26,27,op0 ; shift down op0 by 5L$0 comib,<> 0,op0,L$lo zdep op1,26,27,op1 ; shift up op1 by 5 bv %r0(ret) nopL$1 b L$loop addl op1,res,res nop nopL$2 b L$loop sh1addl op1,res,res nop nopL$3 sh1addl op1,op1,tmp ; 3x b L$loop addl tmp,res,res nopL$4 b L$loop sh2addl op1,res,res nop nopL$5 sh2addl op1,op1,tmp ; 5x b L$loop addl tmp,res,res nopL$6 sh1addl op1,op1,tmp ; 3x b L$loop sh1addl tmp,res,res nopL$7 zdep op1,28,29,tmp ; 8x sub tmp,op1,tmp ; 7x b L$loop addl tmp,res,resL$8 b L$loop sh3addl op1,res,res nop nopL$9 sh3addl op1,op1,tmp ; 9x b L$loop addl tmp,res,res nopL$10 sh2addl op1,op1,tmp ; 5x b L$loop sh1addl tmp,res,res nopL$11 sh2addl op1,op1,tmp ; 5x sh1addl tmp,op1,tmp ; 11x b L$loop addl tmp,res,resL$12 sh1addl op1,op1,tmp ; 3x b L$loop sh2addl tmp,res,res nopL$13 sh1addl op1,op1,tmp ; 3x sh2addl tmp,op1,tmp ; 13x b L$loop addl tmp,res,resL$14 zdep op1,28,29,tmp ; 8x sub tmp,op1,tmp ; 7x b L$loop sh1addl tmp,res,resL$15 zdep op1,27,28,tmp ; 16x sub tmp,op1,tmp ; 15x b L$loop addl tmp,res,resL$16 zdep op1,27,28,tmp ; 16x b L$loop addl tmp,res,res nopL$17 zdep op1,27,28,tmp ; 16x addl tmp,op1,tmp ; 17x b L$loop addl tmp,res,resL$18 sh3addl op1,op1,tmp ; 9x b L$loop sh1addl tmp,res,res nopL$19 sh3addl op1,op1,tmp ; 9x sh1addl tmp,op1,tmp ; 19x b L$loop addl tmp,res,resL$20 sh2addl op1,op1,tmp ; 5x b L$loop sh2addl tmp,res,res nopL$21 sh2addl op1,op1,tmp ; 5x sh2addl tmp,op1,tmp ; 21x b L$loop addl tmp,res,resL$22 sh2addl op1,op1,tmp ; 5x sh1addl tmp,op1,tmp ; 11x b L$loop sh1addl tmp,res,resL$23 sh1addl op1,op1,tmp ; 3x sh3addl tmp,res,res ; += 8x3 b L$loop sub res,op1,res ; -= xL$24 sh1addl op1,op1,tmp ; 3x b L$loop sh3addl tmp,res,res ; += 8x3 nopL$25 sh2addl op1,op1,tmp ; 5x sh2addl tmp,tmp,tmp ; 25x b L$loop addl tmp,res,resL$26 sh1addl op1,op1,tmp ; 3x sh2addl tmp,op1,tmp ; 13x b L$loop sh1addl tmp,res,res ; += 2x13L$27 sh1addl op1,op1,tmp ; 3x sh3addl tmp,tmp,tmp ; 27x b L$loop addl tmp,res,resL$28 zdep op1,28,29,tmp ; 8x sub tmp,op1,tmp ; 7x b L$loop sh2addl tmp,res,res ; += 4x7L$29 sh1addl op1,op1,tmp ; 3x sub res,tmp,res ; -= 3x b L$foo zdep op1,26,27,tmp ; 32xL$30 zdep op1,27,28,tmp ; 16x sub tmp,op1,tmp ; 15x b L$loop sh1addl tmp,res,res ; += 2x15L$31 zdep op1,26,27,tmp ; 32x sub tmp,op1,tmp ; 31xL$foo b L$loop addl tmp,res,res .exit .procend#endif#ifdef L_divU#define dividend %r26#define divisor %r25#define tmp %r1#define quotient %r29#define ret %r31 .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .align 4 .export $$divU$$divU .proc .callinfo frame=0,no_calls .entry comb,< divisor,0,L$largedivisor sub %r0,divisor,%r1 ; clear cy as side-effect ds %r0,%r1,%r0 addc dividend,dividend,dividend ds %r0,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,quotient ds %r1,divisor,%r1 bv %r0(ret) addc quotient,quotient,quotientL$largedivisor comclr,<< dividend,divisor,quotient ldi 1,quotient bv,n %r0(ret) .exit .procend#endif#ifdef L_remU#define dividend %r26#define divisor %r25#define quotient %r29#define tmp %r1#define ret %r31 .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .align 4 .export $$remU$$remU .proc .callinfo frame=0,no_calls .entry comb,< divisor,0,L$largedivisor sub %r0,divisor,%r1 ; clear cy as side-effect ds %r0,%r1,%r0 addc dividend,dividend,dividend ds %r0,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,quotient ds %r1,divisor,%r1 comclr,>= %r1,%r0,%r0 addl %r1,divisor,%r1 bv %r0(ret) copy %r1,quotientL$largedivisor sub,>>= dividend,divisor,quotient copy dividend,quotient bv,n %r0(ret) .exit .procend#endif#ifdef L_divI#define dividend %r26#define divisor %r25#define quotient %r29#define tmp %r1#define ret %r31 .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .align 4 .export $$divI$$divI .proc .callinfo frame=0,no_calls .entry xor dividend,divisor,quotient ; result sign comclr,>= divisor,%r0,%r0 ; get absolute values sub %r0,divisor,divisor comclr,>= dividend,%r0,%r0 sub %r0,dividend,dividend comb,< divisor,0,L$largedivisor sub %r0,divisor,%r1 ; clear cy as side-effect ds %r0,%r1,%r0 addc dividend,dividend,dividend ds %r0,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend comclr,>= %r1,%r0,%r0 addl %r1,divisor,%r1 comclr,>= quotient,%r0,%r0 ; skip of no need to negate sub %r0,dividend,dividend bv %r0(ret) copy dividend,quotientL$largedivisor comclr,<< dividend,divisor,quotient ldi 1,quotient bv,n %r0(ret) .exit .procend#endif#ifdef L_remI#define dividend %r26#define divisor %r25#define quotient %r29#define tmp %r1#define ret %r31 .space $TEXT$ .subspa $MILLICODE$,quad=0,align=8,access=0x2c,sort=8 .align 4 .export $$remI$$remI .proc .callinfo frame=0,no_calls .entry xor dividend,%r0,quotient ; result sign comclr,>= divisor,%r0,%r0 ; get absolute values sub %r0,divisor,divisor comclr,>= dividend,%r0,%r0 sub %r0,dividend,dividend comb,< divisor,0,L$largedivisor sub %r0,divisor,%r1 ; clear cy as side-effect ds %r0,%r1,%r0 addc dividend,dividend,dividend ds %r0,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend ds %r1,divisor,%r1 addc dividend,dividend,dividend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -