嵌入式 16x16 Unsigned Multiply

这里主要介绍一下ti 内嵌16x16 Unsigned Multiply乘法器使用。

简介说明:

//   Description: Hardware multiplier is used to multiply two numbers.
//   The calculation is automatically initiated after the second operand is
//   loaded. Results are stored in RESLO and RESHI.

这里的 RESHI 存放高16位,RESLO存放的是低16位;

MPY-----------// Load first operand -unsigned mult
OP2 ---------- // Load second operand

这两个参数分别存放乘数,注意其都是16位无符号类型。

例子如下:

    unsigned long lValue=0;
    MPY=400;
    OP2 = 300;
    
    lValue = RESHI;
    lValue<<=16;
    lValue+=RESLO;

lValue最后得120000.

使用硬件乘法器的好处是减少cpu负担,这部分运算由硬件完成。

以上就 是简单的介绍ti嵌入硬件乘法器的说明。

谢谢.

End.

原文地址:https://www.cnblogs.com/lumao1122-Milolu/p/12566897.html