Announcement

Collapse
No announcement yet.

C to Pb (again...)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C to Pb (again...)

    I need to translate some c code. The C code is:
    Code:
    Int      mask
    Int      seg
    Int      pcm_val
    unsigned char aval
     
    #define	QUANT_MASK	(0xf)
     
    aval|= (pcm_val >> (seg + 3)) & QUANT_MASK
    Is this the right translation:
    Code:
    shift right pcm_val, seg+3
    aval = (aval Or pcm_val) And %QUANT_MASK
    In the C code, is pcm_val itself shifted, or is only the result used and pcm_val itself unchanged?
    Is the default shift in C signed or unsigned?


    ------------------
    Regards,
    Peter

    [This message has been edited by Peter Lameijn (edited October 04, 2005).]
    Regards,
    Peter

  • #2
    Peter,
    is it not easier to write this code in PB from scratch?
    Actually, I think it may be even easier to write it in ASM.

    Check out one of the many references online. This one seems clear: http://www.epo.pucrs.br/~decastro/pdf/spra163a.pdf

    See pages 16 and 17 for the easy to understand tables and you'll see what your code needs to do.
    If nothing else, it might help you understand what the C code is doing so you can translate it more easily!

    Paul.


    ------------------

    Comment


    • #3
      That looks like a not equal rather than an equal operator in the
      original.

      ------------------
      Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

      Comment


      • #4
        That looks like a not equal rather than an equal operator in the original.
        No, x |= y is a compound assignment operator, translates as x = x or y
        (You probably mixed it up with x != y, which is not equal...)

        ------------------
        Regards,
        Peter
        Regards,
        Peter

        Comment

        Working...
        X