Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help to translation code ASM to C

Status
Not open for further replies.

thientanvt

Newbie level 4
Joined
Jan 21, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
i have a code ASM and I can't understand this code ASM

:sad::sad::sad::

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
so please help me to transfer in C

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

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



+++
 

it write by Proton BASIC - MPLAB IDE v8.46 Amicus18 IDE
thanks .:razz::razz::razz:
 

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

Why not just write your own routine in C?

BigDog
 

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 .
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top