Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / doc / syntax.html
1 <html>
2 <head>
3 <title>Command syntax of &micro;Csim</title>
4 </head>
5
6 <body bgcolor="white">
7
8 Content:
9
10 <ul><li><a href="#syntax">Syntax</a>
11 <li><a href="#expr">Expressions</a>
12 <li><a href="#redir">Redirection</a>
13 </ul>
14
15
16 <a name="syntax"><h2>Command syntax of &micro;Csim</h2></a>
17
18 &micro;Csim uses a very simple command interpreter. Command can be entered
19 after &micro;Csim displays the prompt and interpreted when ENTER key is
20 pressed. Commands must start with the name of the command following
21 parameters. Name of the command can be abbreviated if abbreviation is
22 unique. Some commands have more than one names.
23
24 <p>Syntacticaly parameters can be a string, bit name, array, number or
25 symbol. Interpretation of these syntactical elements depends on actual
26 command.
27
28 <p>If the command line can not be recognized as a known command,
29 &micro;Csim tries to evaluate the command line as an
30 <i>expression</i>. <a href="#expr">See below</a> for information about
31 operands and operators which can be used in expressions.
32
33
34 <a name="command_name"><h3>Command names</h3></a>
35
36 Name of the command must be the first word of the command line. It is
37 not necessary to enter whole name if abbreviation is unique. Help
38 command can be used to check out if a command has more names:
39
40 <pre>
41 > <font color="green">help run</font>
42 run [start [stop]] Go
43 Names of command: <b>go r run</b>
44 ...
45 </pre>
46
47 Some commands just groups other commands. These commands have a set of
48 so-called <i>sub-commands</i>. Sub-command must be second word in the
49 command line. For example:
50
51 <pre>
52 > <font color="green">help set</font>
53 set <b>subcommand</b>     Set, see `set' command for more help
54 Names of command: set
55 long help of set
56 > <font color="green">set</font>
57 "set" must be followed by the name of a subcommand
58 List of subcommands:
59 <b>set option</b> name|nr value
60                    Set value of an option
61 <b>set error</b> on|off|unset
62                    Set value of an error
63 <b>set memory</b> memory_type address data...
64                    Place list of data into memory
65 <b>set bit</b> addr 0|1   Set specified bit to 0 or 1
66 <b>set hardware</b> cathegory params...
67                    Set parameters of specified hardware element
68 </pre>
69
70
71 <h3>Type of parameters</h3>
72
73 <a name="string_type"><h4>String type</h4></a>
74
75 To distinguish strings and symbols, strings can be sorrounded by
76 (double) quotes. Quotes can be omitted if command parameter is
77 interpreted as string and actual parameter start with a letter (so it
78 doesn't look to be a number) and doesn't contain space. Let's look an
79 example:
80
81 <pre>
82 0> <font color="green">set opt 7 <b>s51&gt;</b></font>
83 0s51><font color="green">set opt 7 <b>".s51&gt; "</b></font>
84 0.s51> 
85 </pre>
86
87
88 <a name="bit_type"><h4>Bit type</h4></a>
89
90 If parameter contains a dot (.) it is treated as bit
91 specification. Part before the dot gives memory address and part after
92 the dot means bit number in the specified data.
93
94 <pre>
95 0> <font color="green">dump <b>p1.1</b></font>
96       P1.1 0x90 ff 1
97 0> <font color="green">dump <b>0x80.1</b></font>
98       P4.1 0x80 ff 1
99 0> 
100 </pre>
101
102
103 <a name="array_type"><h4>Array type</h4></a>
104
105 Parameters contain [ character are treated as arrays. Arrays can be
106 used to specify hardware elements. Array index selects an object if
107 more than one exists:
108
109 <pre>
110 0> <font color="green">info hw <b>port[0]</b></font>
111 port[0]
112 P0    11111111 0xff 255 . (Value in SFR register)
113 Pin0  11111111 0xff 255 . (Output of outside circuits)
114 Port0 11111111 0xff 255 . (Value on the port pins)
115 0> 
116 </pre>
117
118
119 <a name="number_type"><h4>Number type</h4></a>
120
121 Some commands accept parameters which in most cases can be
122 numbers. Numbers can be entered in C-style form. If the number begins
123 whith <tt><b>0x</b></tt> or <tt><b>0X</b></tt> it is interpreted as a
124 hexadecimal number. If it begins with <tt><b>0</b></tt> followed by
125 digits it is interpreted as octal number. In other cases it is
126 interpreted as decimal number.
127
128
129 <a name="symbol_type"><h4>Symbol type</h4></a>
130
131 If a command parameter can not be classified in other ways (doesn't
132 start with a digit or a quote, doesn't contain dot or [) then it will
133 be treated as a <b>symbol</b>. Symbols can be interpreted in several
134 ways.
135
136
137 <h3>Interpretation of parameters</h3>
138
139
140 <a name="address_param"><h4>Address parameters</h4></a>
141
142 Many commands requires memory addresses as parameters. Addresses can
143 be specified using number or symbol type of parameters. Value of
144 symbols depends on processor type. For example MCS52 family of
145 controllers defines more symbols than MCS51 family.
146
147
148 <a name="number_param"><h4>Number, data parameters</h4></a>
149
150 When a command expects a number it should get a number. <font
151 color="red">Note</font>, that symbols is not converted to number they
152 can be used as address only!
153
154
155 <a name="string_param"><h4>String parameters</h4></a>
156
157 Strings can be entered without quotes if they are recognized as
158 srtings (see above) and do not contain spaces.
159
160
161 <a name="data_list_param"><h4>Data list parameters</h4></a>
162
163 Data list can be any space separated list of numbers and strings. If
164 you include a string in the list, it is broken to list of bytes where
165 every byte is ASCII code of a string's character.
166
167 <pre>
168 > <font color="green">where xram "ab" 0x43</font>
169 0xf961 61 62 63                abc
170
171 </pre>
172
173
174 <a name="memory_param"><h4>Memory parameters</h4></a>
175
176 Where memory type is expected, name of the memory should be
177 used. Most commands accept memory chip and address space too. See
178 <a href="memory.html">memory simulation</a> for more information.
179
180
181 <a name="hw_param"><h4>Hardware element parameters</h4></a>
182
183 Hardwer elements can be specified by using arrays, where array name is
184 name of the element and the array index selects one if more than one
185 exists.
186
187
188 <a name="bit_param"><h4>Bit parameters</h4></a>
189
190 Bits can be specified by several ways. One way is using bit type of
191 command parameter:
192
193 <pre>
194 0> <font color="green">dump 0.2</font>
195     0x00.2 0x00 00 0
196 0> <font color="green">dump 0xc3.2</font>
197     0xc3.2 0xc3 00 0
198 0> <font color="green">dump p2.3</font>
199       P2.3 0xa0 ff 1
200 0>
201 </pre>
202
203 In this way, any IRAM or SFR location can be addressed as the above
204 example shows.
205
206 <p>Other way is using bit address either by value or by symbolic name:
207
208 <pre>
209 0> <font color="green">dump ea</font>
210      IE0.7 0xa8 00 0
211 0> <font color="green">dump 34</font>
212     0x24.2 0x24 24 1
213 0> <font color="green">dump 0xc7</font>
214    SCON1.7 0xc0 00 0
215 0> 
216 </pre>
217
218 Of course, only addressable bits can be accessed in this way.
219
220 <hr>
221
222
223 <a name="expr"><h2>Expressions</h2></a>
224
225 If first word of the command line is not recognized as a known
226 command, the command line will be evaluated as an expression and the
227 result value printed (in decimal):
228
229 <pre>
230 0> <font color="green">12*(34+56)</font>
231 1080
232 0> 
233 </pre>
234
235
236 <h3>Operands</h3>
237
238 Operands of the expressions can be
239
240 <ul><li>number;
241
242 <li>memory (either address space, or memory chip);
243
244 <li>or bit</ul>
245
246
247 <h4>Number operands</h4>
248
249 Numbers can be entered in decimal, octal (starting with 0 followed by
250 a number), or hexadecimal (started with 0x):
251
252 <pre>
253 0> <font color="green">12</font>
254 12
255 0> <font color="green">012</font>
256 10
257 0> <font color="green">0x12</font>
258 18
259 0> 
260 </pre>
261
262 Numbers must be integers (floating point is not supported) and not
263 bigger than the value which can be stored as <b>long int</b>.
264
265
266 <h4>Memory operands</h4>
267
268 Memory can be an address space location or a memory chip cell. It can
269 be specified in following form:
270
271 <pre>name[address]</pre>
272
273 where <i>name</i> is the name of the address space or memory chip and
274 <i>address</i> is an expression specifying location (index) of the
275 cell.
276
277 <p>Registers in SFR address space can also be specified using
278 pre-defined names (symbols) of the registers.
279
280 <pre>
281 0> <font color="green">xram[0x543]</font>
282 67
283 0> <font color="green">xram_chip[1347]</font>
284 67
285 0> <font color="green">rom[12*(34+56)]</font>
286 56
287 0> <font color="green">sp</font>
288 7
289 0> <font color="green">rom[256*dph+dpl]</font>
290 88
291 0> 
292 </pre>
293
294 Value of the memory operand is always a positive integer number.
295
296
297 <h4>Bit operands</h4>
298
299 Bit operands are evaluated to 0 or 1. Any bit of any memory location
300 can be specified as bit using following form:
301
302 <pre>memory.bitnumber</pre>
303
304 where <i>memory</i> is a memory location as a memory operand and
305 <i>bitnumber</i> is number of the bit within the specified memory
306 cell specified as an expression. Note, that dot (.) is part of the
307 syntax, not an operator.
308
309 <p>Alternatively, name of the bit can be used to specify named SFR
310 bits.
311
312 <pre>
313 0> <font color="green">p0.3</font>
314 1
315 0> <font color="green">xram[12*(34+56)].9-2</font>
316 0
317 0> <font color="green">it0</font>
318 0
319 0> 
320 </pre>
321
322
323 <h3>Operators</h3>
324
325 <table border="1">
326 <tr><th>Type</th> <th>Operator</th> <th>Meaning</th></tr>
327 <tr><td>Primary</td> <td>( )</td> <td>Group of sub-expressions</td></tr>
328 <tr><td>One operand</td> <td>- &amp;</td> <td>Unary minus, address of</td></tr>
329 <tr><td rowspan="2">Arithmetic</td> <td>* /</td> <td>Multiply, divide</td></tr>
330 <tr> <td>+ -</td> <td>Add, substract</td></tr>
331 <tr><td>Assignment</td> <td>=</td> <td>Assign to</td></tr>
332 </table>
333
334 Arithmetic operators and parenthesises work as usual.
335
336 <p>Assigment operator can be used to modify memory cells and bits of
337 the cells. Result will be the assigned value.
338
339 <pre>
340 0> <font color="green">p0=23</font>
341 23
342 0> <font color="green">i h port[0]</font>
343 port[0]
344 P0    00010111 0x17  23 . (Value in SFR register)
345 Pin0  11111111 0xff 255 . (Output of outside circuits)
346 Port0 00010111 0x17  23 . (Value on the port pins)
347 0> <font color="green">p0.0= 0</font>
348 0
349 0> <font color="green">i h p[0]</font>
350 port[0]
351 P0    00010110 0x16  22 . (Value in SFR register)
352 Pin0  11111111 0xff 255 . (Output of outside circuits)
353 Port0 00010110 0x16  22 . (Value on the port pins)
354 0> <font color="green">xram[256*dph+dpl]= rom[0]</font>
355 108
356 0> <font color="green">dump rom 0 0</font>
357 0x0000 6c                      l
358 0> <font color="green">dump sfr dph dph</font>
359 0x83 00                      .
360 0> <font color="green">dump sfr dpl dpl</font>
361 0x82 00                      .
362 0> <font color="green">dump xram 0 0</font>
363 0x0000 6c                      l
364 0> <font color="green">0x6c</font>
365 108
366 0> <font color="green">dump ea</font>
367      IE0.7 0xa8 00 0
368 0> <font color="green">ea= 1111</font>
369 1
370 0> <font color="green">dump ea</font>
371      IE0.7 0xa8 80 1
372 0> 
373 </pre>
374
375 When a symbolic name of the SFR is used, it results value of the named
376 register not the value of the symbol. "Address of" operator can be
377 used to get value of the symbol.
378
379 <pre>
380 0> <font color="green">dpl</font>
381 0
382 0> <font color="green">&amp;dpl</font>
383 130
384 0> <font color="green">ea</font>
385 1
386 0> <font color="green">&amp;ea</font>
387 175
388 0> <font color="green">256*dph+dpl</font>
389 46630
390 0> <font color="green">&amp;xram[256*dph+dpl]</font>
391 46630
392 0> 
393 </pre>
394
395 <hr>
396
397
398 <a name="redir"><h2>Redirection</h2></a>
399
400 Output of any command can be redirected to a file. Same syntax can be
401 used for this as for UNIX shell. The only difference is that
402 &micro;Csim doesn't allow to put redirection at the beginning of the
403 command!
404
405 <pre>
406 $ <font color="#118811">s51 remo.hex</font>
407 uCsim 0.5.0-pre3, Copyright (C) 1997 Daniel Drotos, Talker Bt.
408 uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
409 This is free software, and you are welcome to redistribute it
410 under certain conditions; type `show c' for details.
411 55470 words read from remo.hex
412 0> <font color="#118811">dump >/tmp/rom.dump rom</font>
413 0> <font color="#118811">quit</font>
414 $ <font color="#118811">cat /tmp/rom.dump</font>
415 0x0000 02 01 60 02 00 3c 06 07 ..`..<..
416 0x0008 08 09 0a 02 2f 6b 0e 0f ..../k..
417 0x0010 10 11 12 02 00 ac 16 17 ........
418 0x0018 18 19 1a 1b 1c 1d 1e 1f ........
419 0x0020 20 21 22 02 01 1c 26 27  !"...&'
420 0x0028 28 29 2a 32 2c 2d 2e 2f ()*2,-./
421 0x0030 02 0f a7 02 0e 9c 02 0d ........
422 0x0038 d2 02 08 41 c0 82 c0 83 ...A....
423 0x0040 c0 d0 c0 e0 c0 00 a2 90 ........
424 0x0048 c0 d0 c2 90 78 18 06 30 ....x..0
425 $ <font color="#118811">s51 remo.hex</font>
426 uCsim 0.5.0-pre3, Copyright (C) 1997 Daniel Drotos, Talker Bt.
427 uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
428 This is free software, and you are welcome to redistribute it
429 under certain conditions; type `show c' for details.
430 55470 words read from remo.hex
431 0> <font color="#118811">dump rom 0x50 >>/tmp/rom.dump</font>
432 0> <font color="#118811">quit</font>
433 $ <font color="#118811">cat /tmp/rom.dump</font>
434 0x0000 02 01 60 02 00 3c 06 07 ..`..<..
435 0x0008 08 09 0a 02 2f 6b 0e 0f ..../k..
436 0x0010 10 11 12 02 00 ac 16 17 ........
437 0x0018 18 19 1a 1b 1c 1d 1e 1f ........
438 0x0020 20 21 22 02 01 1c 26 27  !"...&'
439 0x0028 28 29 2a 32 2c 2d 2e 2f ()*2,-./
440 0x0030 02 0f a7 02 0e 9c 02 0d ........
441 0x0038 d2 02 08 41 c0 82 c0 83 ...A....
442 0x0040 c0 d0 c0 e0 c0 00 a2 90 ........
443 0x0048 c0 d0 c2 90 78 18 06 30 ....x..0
444 0x0050 03 4b 20 92 48 30 07 05 .K .H0..
445 0x0058 c2 07 02 00 9d 30 08 05 .....0..
446 0x0060 20 93 3a c2 08 90 08 60  .:....`
447 0x0068 e0 b4 ff 03 02 00 9d 04 ........
448 0x0070 f0 14 f8 03 03 03 54 1f ......T.
449 0x0078 90 08 62 25 82 f5 82 e5 ..b%....
450 0x0080 83 34 00 f5 83 e8 54 07 .4....T.
451 0x0088 f8 08 74 80 23 d8 fd f8 ..t.#...
452 0x0090 e0 30 93 07 c8 f4 58 f0 .0....X.
453 0x0098 02 00 9d 48 f0 d0 d0 92 ...H....
454
455 </pre>
456
457
458 <hr>
459
460
461 </body>
462 </html>