# Help to translation code ASM to C

Status
Not open for further replies.

#### thientanvt

##### Newbie level 4
i have a code ASM and I can't understand this code ASM

this code :
Code:
Dim FXPM_wPROD As PRODL.Word                        ' Make a 16-bit variable from PRODL\H

$define Fixed_Multiply(pMultiplier, pMultiplicand, pResult) ' If pMultiplicand = 0 Then ' pResult = 0 ' ElseIf pMultiplier = 0 Then ' pResult = 0 ' Else ' Movf pMultiplier,w,0 ' Mulwf pMultiplicand,0 ' Btfsc pMultiplicand,7,0 ' Subwf PRODH,f,0 ' Btfss pMultiplier,7,0 ' Bra$ + 6                   '
Movf pMultiplicand,w,0      '
Subwf  PRODH,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Movlw  3                    '
Andwf  PRODH,f,0            '
WREG = PRODL & 1            '
Bcf    STATUS,C,0           '
Rrcf   PRODH,f,0            '
Rrcf   PRODL,f,0            '
Btfsc  PRODH,6,0            '
Bsf    PRODH,7,0            '
pResult = FXPM_wPROD + WREG '
EndIf

I just learned and not write code by ASM only C

thanks so much :lol::lol::lol::

#### andre_luis

##### Super Moderator
Staff member
This code seems to have mixed both languages.
Give us more detail about from where did you take it.

+++

#### thientanvt

##### Newbie level 4
it write by Proton BASIC - MPLAB IDE v8.46 Amicus18 IDE
thanks .:razz::razz::razz:

#### bigdogguru

It appears to be a fixed point 16-bit multiplier routine.

Why not just write your own routine in C?

BigDog

#### thientanvt

##### Newbie level 4
like this :
Code:
    int   Fix_my (int a , int b){
long c = (a*B)>>6;
a        = (c>>1) + (c&1);
return a;
}

but it for unlike results .

#### bigdogguru

What C compiler are you currently using? What is the version number?

BigDog

#### thientanvt

##### Newbie level 4
i using CCS compiler v4.xx

#### thientanvt

##### Newbie level 4
some body help

Status
Not open for further replies.