File: picasm.doc

package info (click to toggle)
picasm 1.6-0.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 200 kB
  • ctags: 365
  • sloc: ansic: 3,628; asm: 150; makefile: 70
file content (218 lines) | stat: -rw-r--r-- 7,882 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

  Assembler for Microchip PIC16Cxx microcontrollers
  -------------------------------------------------

                  version 1.06


  Copyright 1995-1998 by Timo Rossi.  All rights reserved.
  See the file "LICENSE" for more information about redistribution
  conditions.

  Suggestions and bug reports are welcome.
 
    Timo Rossi
    email: trossi@iki.fi
    www: http://www.iki.fi/trossi/pic/
 

  The code is (mostly) ANSI-C, and should compile with most
  platforms (It does assume that negative integers are
  stored in two's complement representation) And it
  uses the strcasecmp() or stricmp() function)


 Command line usage:
    picasm [-o<objname>] [-l<listfile>] [-ihx8m] [-ihx16]
           [-pic<device>] <filename>
 
 Options:
    -o<filename>  Define output file name.
                  Default is <source_without_ext>.hex

    -l<listfile>  Enable listing. Default listing
                  file name is <source_without_ext>.lst

    -s            Includes symbol table in listing.
                  Does nothing if listing is not enabled.

    -w<warnlevel> Give more warnings. If <warnlevel> is omitted,
                  one is assumed. Level two warns also
		  about tris/option instructions on 14-bit PICs.
		  

    -ihx8m        IHX8M output format (default).
    -ihx16        IHX16 output format.

    -pic<device>  select PIC device
     (12c508, 12c509, 12c671, 12c672, 16c52, 16c54(a), 16c55, 16c56, 16c57,
      16c58a, 16c61, 16c62(a), 16c63, 16c64(a), 16c65(a), 16c66, 16c67,
      16c71, 16c710, 16c711, 16c715, 16c72, 16c73(a), 16c74(a), 16c83, 16c84,
      16f84 16c620, 16c621, 16c622, 16c554(a), 16c556a, 16c558(a), 14000)


  This is a single-pass assembler, forward gotos/calls are patched
  at the end of the assembly (only single labels are accepted in
  that case, otherwise expressions can be used too)

  In current versions forward references can also be used
  with movlw, addlw and retlw (only the low 8 bits of an address are used)

  Expressions can have the following elements:
  (from highest precedence to the lowest)

   integer constants
   symbols
   (<expression>)
   . (or $)   current location

   defined(symbol)      -- TRUE (-1) if symbol is defined else FALSE (0)

   streq("str1","str2") -- TRUE if strings are identical.

   isstr(arg)           -- TRUE is argument is a quoted string

   chrval("str", pos)   -- Returns ASCII character code from the string.
                           position range is from 0 to string length-1.
                           If position is out of range, returns -1.

   [expr1 expr2 ... exprn] -- the same as (1<<expr1) | (1<<expr2) ...
			(builds a number by setting individual bits)

   -   unary minus
   ~   bitwise not
 
   *   multiply
   /   divide
   %   modulo/remainder
   &   bitwise and

   +   add
   -   subtract
   |   bitwise or
   ^   bitwise exclusive or
   <<  shift left
   >>  shift right

   ==     equal
   != <>  not equal
   <      less than
   <= =<  less or equal than
   >      greater than
   >= =>  greater or equal than

  The compare operators return TRUE (-1) or FALSE (0)
  (they are useful with conditional assembly)

  Expressions are evaluated as 32-bit integers (or whatever size 'long' is).

  hex numbers: 0x<digits>, h'<digits>', $<digits>
               or <digits>h (must begin with 0..9)
  octal numbers:  <digits>o, o'<digits>'
  binary numbers: 0b<digits>, b'<digits>' or <digits>b
  decimal numbers without prefix or d'<digits>'

  Directives:
  (square brackets denote optional parameters)

<label>   equ   <expr>   - Define a constant
<label>   set   <expr>   - Define a variable (similar to equ but
                           can be redefined with another set-directive)

  org <address>
  org <address>,<mode>
  org <mode>
    - Specify origin for program code, register file or data EEPROM.

    <mode> is 'code' for program code, 'reg' for register file
    and 'edata' for data EEPROM. If mode is not given, it is
    determined automatically from first instruction that generates
    output to the hex file. After that the mode cannot be changed
    without another ORG statement. When ORG is used with only
    the mode parameter, the address continues from the last value
    for that mode.


  include <filename>   - Include another source file. includes can be nested.

  end                  - End assembly. anything after this is ignored.

<label>  ds     <expr>   - Reserve <expr> number of file register (RAM)
                           locations. ORG must be set for this to work.
 
<label>  edata  <expr>[, <expr>...]
                         - Define data EEPROM contents (only with PIC16C84 / 16C83 / 16F84)

         if     <expr>   - Conditional assembly. If <expr> is non-zero,
        <code1>            <code1> after the if-directive is assembled,
        [else              and the optional <code2> is skipped. If <expr>
        <code2>]           is zero, <code1> is skipped and optional
         endif             <code2> is assembled.

<macroname> macro        - Define a macro.
            <macro definition>
            endm

   Macro parameters are \1...\9, \# is the number of parameters.
   \@ (or \0) is an number that is different  for each macro
   expansion (it can be used to generate unique labels inside macros).
   Macros can be recursive.

         exitm          - Exit macro (can only be used inside a macro
                          definition. Useful with conditional assembly)

	 local		- Begin and end a local label/symbol block.
	 endlocal         Local symbols must be prefixed with '='
                          and their name scope is only
                          the current local symbol block.
                          Local symbol blocks can be nested
                          but only the symbols in the currently
                          active block can be used (the symbols
                          in the inner and outer blocks are not visible)
 
         config <config_param>[, <config_param>...]
                        - Define PIC configuration fuse data.
                          <config_param> can be:

                          CP=<on_off>      - code protection (default off,
                                             partial protection not supported)

                          PWRT=<on_off>    - powerup timer (default varies
                                             with PIC models, not valid
                                             with 12-bit PICs)

                          WDT=<on_off>     - watchdog (default on)

                          BOD=<on_off>     - brown-out detect. only valid
                                             with some PIC models.

                          OSC=<osctype>    - oscillator type (typically HS,XT,LP,RC,
					     some PIC models have different options)

                          The <on_off> parameter can be:
                            on, yes, enabled  - on
                            off, no, disabled - off

                          The fuses are located in address 0xfff with
                          12-bit PICs and 0x2007 with 14-bit PICs.


         picid <id1>,<id2>,<id3>,<id4>
                         - Define PIC ID values.
			   The ID is located in the hex file at the address
                           following program memory end with 12-bit PICs,
                           and at 0x2000 with 14-bit PICs.

 
         device <device> - select PIC device type
                         Valid values are listed in the command line
                         option section (the -pic<type> option).


         opt    <option> - set assembly options
                         Currently only implemented:
                           list or l     - turn listing on
                           nolist or nol - turn listing off

         error           - causes an assembly error