gnupic: #v()


Previous by date: 11 Apr 2002 02:48:12 -0000 gputils-0.10.2, Craig Franklin
Next by date: 11 Apr 2002 02:48:12 -0000 recommended C compiler ??, Linas Vepstas
Previous in thread:
Next in thread: 11 Apr 2002 02:48:12 -0000 Re: #v(), Kevin Blain

Subject: #v()
From: Craig Franklin ####@####.####
Date: 11 Apr 2002 02:48:12 -0000
Message-Id: <3CB4F833.BBD1F3DA@attbi.com>

I have seen several examples of code that used #v() in a strange way.

number equ 0xf

  movlw #v(number + 1)

The #v() operator evaluates the expression within the parentheses and
outputs a decimal string representing its value.  It is useful for
automatically creating unique labels (mylabel_#v(1 + 2) = mylabel_3). 

The above expression will always be substituted with:

  movlw 16

The thing I don't understand is why someone would want to do this.  The
example below demonstrates what I mean.  

source file
-----------

  processor 16c74

number equ 0xf

  radix dec

  movlw #v(number + 1)
  movlw number + 1

  radix hex

  movlw #v(number + 1)
  movlw number + 1

  end

list file
---------
                      00001   processor 16c74
                      00002 
  0000000F            00003 number equ 0xf
                      00004 
                      00005   radix dec
                      00006 
0000   3010           00007   movlw 16
0001   3010           00008   movlw number + 1
                      00009 
                      00010   radix hex
                      00011 
0002   3016           00012   movlw 16
0003   3010           00013   movlw number + 1
                      00014 
                      00015   end

If the radix is decimal the #v() is unecessary.  With any other radix,
the 16 is interpretted as 16 in that radix.  In the example above, 15 +
1 = 22.

I intentionally never added gpasm support for this notation.  However, a
few users have reported the lack of support as a gpasm bug.  MPASM does
support this, so techically it is a bug.

I must be missing something.   Will someone send me an example where
this specific behavior is desired.

Thank you.

Previous by date: 11 Apr 2002 02:48:12 -0000 gputils-0.10.2, Craig Franklin
Next by date: 11 Apr 2002 02:48:12 -0000 recommended C compiler ??, Linas Vepstas
Previous in thread:
Next in thread: 11 Apr 2002 02:48:12 -0000 Re: #v(), Kevin Blain


Powered by ezmlm-browse 0.20.