Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
_sparc.s
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 7k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- !------------------------------------------------------------------------------
- ! assembler code for unsigned 32 bit multiplication
- ! taken from
- !
- ! "The SPARC Architecture Manual" (Appendix E.2)
- !
- !------------------------------------------------------------------------------
- !------------------------------------------------------------------------------
- ! extern "C" word Multiply_Words(word a, word b, word* high);
- ! (returns lower 32 bit of product, stores higher 32 bit in *high)
- !------------------------------------------------------------------------------
- .seg "text"
- .global _Multiply_Words
- _Multiply_Words:
- or %o0, %o1, %o4 !logical or of multiplier and miltiplicand
- mov %o0, %y !multiplier to Y register
- andncc %o4, 0xfff, %o5 !mask out lower 12 bits
- be mul_shortway !can do it the short way
- andcc %g0, %g0, %o4 !zero the partial product; clear N and V cond.
- ! long multiply
- mulscc %o4, %o1, %o4 !first of 33 iterations
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4 ! 32nd iteration;
- mulscc %o4, %g0, %o4 ! last iteration only shits
- tst %o1
- bge 1f
- nop
- add %o4, %o0, %o4
- 1:
- rd %y, %o0
- addcc %o4, %g0, %o1 ! set zero bit appropriately
- st %o1, [%o2] ! return high bits
- retl ! leaf-routine return
- nop
- ! short multiply
- mul_shortway:
- mulscc %o4, %o1, %o4 ! first iteration of 13
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4 ! 12nd iteration
- mulscc %o4, %g0, %o4 ! last iteration only shits
- rd %y, %o5
- sll %o4, 12, %o4 ! left shift partial product by 12 bits
- srl %o5, 20, %o5 ! right shift product by 12 bits
- or %o5, %o4, %o0 ! merge for true product
- addcc %g0, %g0, %o1
- st %o1, [%o2] ! return high bits
- retl ! leaf routine return
- nop
- !------------------------------------------------------------------------------
- ! extern "C" word Mult_Inner_Loop(word *p, word *a, word* a_stop, word B)
- !------------------------------------------------------------------------------
- ! %o0 p
- ! %o1 a
- ! %o2 a_stop
- ! %o3 B
- !
- .global _Mult_Inner_Loop
- _Mult_Inner_Loop:
- cmp %o1,%o2 ! if a >= a_stop return
- bge IMULT_L1
- mov 0, %g5 ! carry = 0
- IMULT_L0: ! Loop: while (a < a_stop)
- mov %o3, %y ! load B to Y register
- andcc %g0, %g0, %g3
- ld [%o1], %g2 ! A = *a
- ld [%o0], %g4 ! P = *p
- !
- ! compute 64 bit product A*B = (high,low)
- !
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g0, %g3
- tst %g2 ! sign correction
- bge IMULT_L2
- rd %y, %g2 ! low
- add %g3, %o3, %g3 ! sign correction
- IMULT_L2:
- addcc %g5, %g4, %g4 ! P += carry
- addx %g0, %g0, %g5 ! new carry from addition
- addcc %g2, %g4, %g2 ! low += P
- addx %g3, %g5, %g5 ! carry += high
- st %g2, [%o0] ! *p = low
- inc 4, %o1 ! a++
- cmp %o1, %o2 ! if (a < a_stop) goto IMULT_L0
- bl IMULT_L0 ! loop
- inc 4, %o0 ! p++
- IMULT_L1:
- st %g5, [%o0] ! *p = carry
- retl
- mov %g5, %o0 ! return carry
- !------------------------------------------------------------------------------
- ! extern "C" word Div_Inner_Loop(word *p, word *a, word* a_stop, word B)
- !------------------------------------------------------------------------------
- ! %o0 p
- ! %o1 a
- ! %o2 a_stop
- ! %o3 B
- !
- .global _Div_Inner_Loop
- _Div_Inner_Loop:
- cmp %o1,%o2 ! if a >= a_stop return
- bge IDIV_L1
- mov 0, %g5 ! carry = 0
- IDIV_L0: ! Loop: while (a < a_stop)
- mov %o3, %y ! load B to Y register
- andcc %g0, %g0, %g3
- ld [%o1], %g2 ! A = *a
- ld [%o0], %g4 ! P = *p
- !
- ! compute 64 bit product A*B = (high,low)
- !
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g2, %g3
- mulscc %g3, %g0, %g3
- tst %g2 ! sign correction
- bge IDIV_L2
- rd %y, %g2 ! low
- add %g3, %o3, %g3 ! sign correction
- IDIV_L2:
- subcc %g4, %g5, %g4 ! P -= carry
- addx %g0, %g0, %g5 ! new carry from subtraction
- subcc %g4, %g2, %g4 ! P -= low
- addx %g3, %g5, %g5 ! carry += high
- st %g4, [%o0] ! *p = P
- inc 4, %o1 ! a++
- cmp %o1, %o2 ! if (a < a_stop) goto IDIV_L0
- bl IDIV_L0 ! loop
- inc 4, %o0 ! p++
- IDIV_L1:
- ld [%o0], %g4 ! P = *p
- subcc %g4, %g5, %g4 ! P -= carry
- addx %g0, %g0, %g5 ! new carry
- retl
- mov %g5, %o0 ! return carry