1 /*-------------------------------------------------------------------------
3 _muluint.c :- routine for unsigned int (16 bit) multiplication
5 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 In other words, you are welcome to use, share and improve this program.
22 You are forbidden to forbid anyone else to use, share and improve
23 what you give them. Help stamp out software-hoarding!
24 -------------------------------------------------------------------------*/
26 #ifdef SDCC_MODEL_FLAT24
28 unsigned int _muluint (unsigned int a, unsigned int b)
30 a*b; // hush the compiler
32 // muluint=(int)(lsb_a*lsb_b) + (char)(msb_a*msb_b)<<8
38 mov dptr,#__muluint_PARM_2
57 struct { unsigned short lo,hi ;} s;
61 unsigned int _muluint (unsigned int a, unsigned int b)
63 #ifdef SDCC_MODEL_LARGE
67 x = (union uu _xdata *)&a;
68 y = (union uu _xdata *)&b;
70 register union uu _near *x;
71 register union uu _near *y;
73 x = (union uu _near *)&a;
74 y = (union uu _near *)&b;
77 t.t = x->s.lo * y->s.lo;
78 t.s.hi += (x->s.lo * y->s.hi) + (x->s.hi * y->s.lo);