From b5e11ed3a3eae719a04674f050d3c2173e65e8b3 Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 31 Jan 2001 16:35:30 +0000 Subject: [PATCH] I smoked too much pot lately... git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@552 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/lib/_muluint.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/device/lib/_muluint.c b/device/lib/_muluint.c index fdb261a6..13ac40e7 100644 --- a/device/lib/_muluint.c +++ b/device/lib/_muluint.c @@ -29,22 +29,35 @@ unsigned int _muluint (unsigned int a, unsigned int b) { a*b; // hush the compiler - // muluint=(int)(lsb_a*lsb_b) + (char)(msb_a*msb_b)<<8 - // ^^^ + /* muluint= + (int)(lsb_a*lsb_b) + + (char)(msb_a*lsb_b)<<8 + + (char)(lsb_a*msb_b)<<8 + */ _asm - push dph ; msb_a - mov b,dpl ; lsb_a + mov r2,dph ; msb_a + mov r3,dpl ; lsb_a + + mov b,r3 ; lsb_a mov dptr,#__muluint_PARM_2 movx a,@dptr ; lsb_b - mul ab + mul ab ; lsb_a*lsb_b mov r0,a mov r1,b - pop b ; msb_a + + mov b,r2 ; msb_a + movx a,@dptr ; lsb_b + mul ab ; msb_a*lsb_b + add a,r1 + mov r1,a + + mov b,r3 ; lsb_a inc dptr movx a,@dptr ; msb_b - mul ab + mul ab ; lsb_a*msb_b add a,r1 + mov dph,a mov dpl,r0 ret -- 2.47.2