URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [microblaze/] [muldi3_hard.S] - Rev 734
Compare with Previous | Blame | View Log
###################################-## Copyright 2009, 2010, 2011 Free Software Foundation, Inc.## Contributed by Michael Eager <eager@eagercon.com>.## This file 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 3, or (at your option) any# later version.## GCC 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.## Under Section 7 of GPL version 3, you are granted additional# permissions described in the GCC Runtime Library Exception, version# 3.1, as published by the Free Software Foundation.## You should have received a copy of the GNU General Public License and# a copy of the GCC Runtime Library Exception along with this program;# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see# <http://www.gnu.org/licenses/>.## muldi3_hard.S## Multiply operation for 64 bit integers, for devices with hard multiply# Input : Operand1[H] in Reg r5# Operand1[L] in Reg r6# Operand2[H] in Reg r7# Operand2[L] in Reg r8# Output: Result[H] in Reg r3# Result[L] in Reg r4## Explaination:## Both the input numbers are divided into 16 bit number as follows# op1 = A B C D# op2 = E F G H# result = D * H# + (C * H + D * G) << 16# + (B * H + C * G + D * F) << 32# + (A * H + B * G + C * F + D * E) << 48## Only 64 bits of the output are considered########################################.globl muldi3_hardproc.ent muldi3_hardprocmuldi3_hardproc:addi r1,r1,-40# Save the input operands on the caller's stackswi r5,r1,44swi r6,r1,48swi r7,r1,52swi r8,r1,56# Store all the callee saved registerssw r20,r1,r0swi r21,r1,4swi r22,r1,8swi r23,r1,12swi r24,r1,16swi r25,r1,20swi r26,r1,24swi r27,r1,28# Load all the 16 bit values for A thru Hlhui r20,r1,44 # Alhui r21,r1,46 # Blhui r22,r1,48 # Clhui r23,r1,50 # Dlhui r24,r1,52 # Elhui r25,r1,54 # Flhui r26,r1,56 # Glhui r27,r1,58 # H# D * H ==> LSB of the result on stack ==> Store1mul r9,r23,r27swi r9,r1,36 # Pos2 and Pos3# Hi (Store1) + C * H + D * G ==> Store2 ==> Pos1 and Pos2# Store the carry generated in position 2 for Pos 3lhui r11,r1,36 # Pos2mul r9,r22,r27 # C * Hmul r10,r23,r26 # D * Gadd r9,r9,r10addc r12,r0,r0add r9,r9,r11addc r12,r12,r0 # Store the Carryshi r9,r1,36 # Store Pos2swi r9,r1,32lhui r11,r1,32shi r11,r1,34 # Store Pos1# Hi (Store2) + B * H + C * G + D * F ==> Store3 ==> Pos0 and Pos1mul r9,r21,r27 # B * Hmul r10,r22,r26 # C * Gmul r7,r23,r25 # D * Fadd r9,r9,r11add r9,r9,r10add r9,r9,r7swi r9,r1,32 # Pos0 and Pos1# Hi (Store3) + A * H + B * G + C * F + D * E ==> Store3 ==> Pos0lhui r11,r1,32 # Pos0mul r9,r20,r27 # A * Hmul r10,r21,r26 # B * Gmul r7,r22,r25 # C * Fmul r8,r23,r24 # D * Eadd r9,r9,r11add r9,r9,r10add r9,r9,r7add r9,r9,r8sext16 r9,r9 # Sign extend the MSBshi r9,r1,32# Move results to r3 and r4lhui r3,r1,32add r3,r3,r12shi r3,r1,32lwi r3,r1,32 # Hi Partlwi r4,r1,36 # Lo Part# Restore Callee saved registerslw r20,r1,r0lwi r21,r1,4lwi r22,r1,8lwi r23,r1,12lwi r24,r1,16lwi r25,r1,20lwi r26,r1,24lwi r27,r1,28# Restore Frame and returnrtsd r15,8addi r1,r1,40.end muldi3_hardproc
