Hi,

The hardware multiplier works as defined by С standard. 

As far as I understand the following code will do what you need:

uint16_t a,b,c;
.......
 a=((uint32_t)b*c)/0x7000;


 116 000a 9242 0000   mov &b, &__MPY
 116      3001 
 117 0010 9242 0000   mov &c, &__OP2
 117      3801 
 118 0016 1E42 3A01   mov &__RESLO, r14
 119 001a 1F42 3C01   mov &__RESHI, r15
 120 001e 3241        pop r2
 121 0020 0C4E        mov r14, r12
 122 0022 0D4F        mov r15, r13
 123 0024 3A40 0070   mov #llo(28672), r10
 124 0028 0B43        mov #lhi(28672), r11
 125 002a B012 0000   call #__udivmodsi4

All the best !
Oleg Skydan
http://skydan.in.ua/SOS/

  ----- Original Message ----- 
  From: penguinfly 
  To: mspgcc-users@lists.sourceforge.net 
  Sent: Sunday, April 30, 2006 10:55 AM
  Subject: Re: Re: [Mspgcc-users] How the hardware multiplier work in the 
mspgcc?


  Hi,Steven Johnson:

  I changed the type of varc to uint32_t, but it is also doing wrong.
  did you test it ?


  Steven Johnson <sjohn...@neurizon.net> 写道: 
    Hi

    It is a bug in your code. You are assigning the result to a 16 bit
    quantity, so it is doing the right job. Change the type of varc to uint32_t.

    Steven

    penguinfly wrote:

    > Hi,everybody:
    > Excuse me! English is not my first language. I'm chinese.
    > It is hard to express my meanings clearly with my poor english.
    > I lvoe the mspgcc, but there are some troubles When I useing
    > 16-bit multiplication in f147 and fe427. The result of the 16-bit
    > multiplication should be 32-bit, but the compiler only read
    > the register 0x013a(RESLO). Is this a bug or something wrong
    > when i useing the hardware multiplier?
    > By the way, is it necessary to add "#define __msp430_have_fll"
    > in msp430xE42x.h?
    > (mspgcc-20060407,win2000/xp)
    > mian.c:
    > uint16_t vara,varb,varc;
    > void dispLED(uint16_t);
    > ...
    > int main(void)
    > {
    > ...
    > vara=0x6000;
    > varb=0x5000;
    > varc = varb * vara / 0x7000;
    > dispLED(varc);
    > ...
    > }
    >
    > Part of the Assemble List:
    > vara=0x6000;
    >
    > 81bc: b2 40 00 60 mov #24576, &0x020c ;#0x6000
    > 81c0: 0c 02
    > varb=0x5000;
    >
    > 81c2: b2 40 00 50 mov #20480, &0x0208 ;#0x5000
    > 81c6: 08 02
    > varc = varb * vara / 0x7000;
    >
    > 81c8: 02 12 push r2 ;
    > 81ca: 32 c2 dint
    > 81cc: 03 43 nop
    > 81ce: b2 40 00 50 mov #20480, &0x0132 ;#0x5000
    > 81d2: 32 01
    > 81d4: b2 40 00 60 mov #24576, &0x0138 ;#0x6000
    > 81d8: 38 01
    > *81da: 1f 42 3a 01 mov &0x013a,r15 ;0x013a
    > * 81de: 32 41 pop r2 ;
    > 81e0: 0c 4f mov r15, r12 ;
    > 81e2: 3a 40 00 70 mov #28672, r10 ;#0x7000
    > 81e6: b0 12 dc 82 call #-32036 ;#0x82dc
    > 81ea: 0f 4c mov r12, r15 ;
    > 81ec: 82 4c 0a 02 mov r12, &0x020a ;
    > dispLED(varc);
    >
    > 81f0: b0 12 7a 81 call #-32390 ;#0x817a
    >
    > ------------------------------------------------------------------------
    > 雅虎1G免费邮箱百分百防垃圾信 
    > 雅虎助手-搜索、杀毒、防骚扰 




    -------------------------------------------------------
    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job 
easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
    http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    _______________________________________________
    Mspgcc-users mailing list
    Mspgcc-users@lists.sourceforge.net
    https://lists.sourceforge.net/lists/listinfo/mspgcc-users





------------------------------------------------------------------------------
  无限容量雅虎相册,原图等大下载,超快速度,赶快抢注! 

Reply via email to