Menu

#49 Extension of #v(<value>) construct

None
open
nobody
None
5
2019-12-11
2010-05-29
Anonymous
No

composing/merging definitions of other definitions (as possible in C). Extension of #v(<value>) construct
example:</value>

#define  REG_CONF1_SPEED_SHIFT    1
#define  REG_CONF1_SPEED_MASK    7

#define SETFIELD(reg,field,value)   ((value& REG_##reg##_##field##_MASK)<<REG_##reg##_##field##_SHIFT)


     movlw SETFIELD(CONF1,SPEED,13)            ; equal movlw 10

Discussion

  • Borut Ražem

    Borut Ražem - 2012-10-16
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,7 @@
     composing/merging definitions of other definitions (as possible in C). Extension of #v(<value>) construct
     example:
    +
    +~~~~~~
     #define  REG_CONF1_SPEED_SHIFT    1
     #define  REG_CONF1_SPEED_MASK    7
    
    @@ -7,7 +9,4 @@
    
    
          movlw SETFIELD(CONF1,SPEED,13)            ; equal movlw 10
    -
    -
    -
    -
    +~~~~~~
    
    • milestone: --> Next_Release_(example)
     
  • Anonymous

    Anonymous - 2019-12-11

    The #v(expr) outputs a decimal formatted string, e.g. #v(12+13) yields string '25'

    What I would love to see is :

    • h(expr) outputs a hexadecimal formatted string.

      Even better, #h(expr, 4) could output a 4-digit hex value, like #h(1023,4) yielding string '03FF'

    • likewise, #v(12+13, 5) could yield string '00025'

    • a(nn) to output ascii character nn.


    another wish of me is support for #v() constructs at the left side of the = character like:
    fc_#v($ >>11)0 = fc_#v($ >> 11)0 + 1
    to increment a variable called fc_00, fc_10 or fc_20 depending on #v() value.
    mpasm supports this way of variable assignments; gpasm not yet...

     
  • Anonymous

    Anonymous - 2019-12-11

    sorry; I mis-typed my post..
    please read #h(expr) for h(expr),
    and #a(nn) for a(nn)

     

Anonymous
Anonymous

Add attachments
Cancel