3 <title>Command syntax of µCsim</title>
10 <ul><li><a href="#syntax">Syntax</a>
11 <li><a href="#expr">Expressions</a>
12 <li><a href="#redir">Redirection</a>
16 <a name="syntax"><h2>Command syntax of µCsim</h2></a>
18 µCsim uses a very simple command interpreter. Command can be entered
19 after µ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.
24 <p>Syntacticaly parameters can be a string, bit name, array, number or
25 symbol. Interpretation of these syntactical elements depends on actual
28 <p>If the command line can not be recognized as a known command,
29 µ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.
34 <a name="command_name"><h3>Command names</h3></a>
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:
41 > <font color="green">help run</font>
43 Names of command: <b>go r run</b>
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:
52 > <font color="green">help set</font>
53 set <b>subcommand</b> Set, see `set' command for more help
56 > <font color="green">set</font>
57 "set" must be followed by the name of a subcommand
59 <b>set option</b> name|nr value
60 Set value of an option
61 <b>set error</b> on|off|unset
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
71 <h3>Type of parameters</h3>
73 <a name="string_type"><h4>String type</h4></a>
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
82 0> <font color="green">set opt 7 <b>s51></b></font>
83 0s51><font color="green">set opt 7 <b>".s51> "</b></font>
88 <a name="bit_type"><h4>Bit type</h4></a>
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.
95 0> <font color="green">dump <b>p1.1</b></font>
97 0> <font color="green">dump <b>0x80.1</b></font>
103 <a name="array_type"><h4>Array type</h4></a>
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:
110 0> <font color="green">info hw <b>port[0]</b></font>
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)
119 <a name="number_type"><h4>Number type</h4></a>
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.
129 <a name="symbol_type"><h4>Symbol type</h4></a>
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
137 <h3>Interpretation of parameters</h3>
140 <a name="address_param"><h4>Address parameters</h4></a>
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.
148 <a name="number_param"><h4>Number, data parameters</h4></a>
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!
155 <a name="string_param"><h4>String parameters</h4></a>
157 Strings can be entered without quotes if they are recognized as
158 srtings (see above) and do not contain spaces.
161 <a name="data_list_param"><h4>Data list parameters</h4></a>
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.
168 > <font color="green">where xram "ab" 0x43</font>
174 <a name="memory_param"><h4>Memory parameters</h4></a>
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.
181 <a name="hw_param"><h4>Hardware element parameters</h4></a>
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
188 <a name="bit_param"><h4>Bit parameters</h4></a>
190 Bits can be specified by several ways. One way is using bit type of
194 0> <font color="green">dump 0.2</font>
196 0> <font color="green">dump 0xc3.2</font>
198 0> <font color="green">dump p2.3</font>
203 In this way, any IRAM or SFR location can be addressed as the above
206 <p>Other way is using bit address either by value or by symbolic name:
209 0> <font color="green">dump ea</font>
211 0> <font color="green">dump 34</font>
213 0> <font color="green">dump 0xc7</font>
218 Of course, only addressable bits can be accessed in this way.
223 <a name="expr"><h2>Expressions</h2></a>
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):
230 0> <font color="green">12*(34+56)</font>
238 Operands of the expressions can be
242 <li>memory (either address space, or memory chip);
247 <h4>Number operands</h4>
249 Numbers can be entered in decimal, octal (starting with 0 followed by
250 a number), or hexadecimal (started with 0x):
253 0> <font color="green">12</font>
255 0> <font color="green">012</font>
257 0> <font color="green">0x12</font>
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>.
266 <h4>Memory operands</h4>
268 Memory can be an address space location or a memory chip cell. It can
269 be specified in following form:
271 <pre>name[address]</pre>
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
277 <p>Registers in SFR address space can also be specified using
278 pre-defined names (symbols) of the registers.
281 0> <font color="green">xram[0x543]</font>
283 0> <font color="green">xram_chip[1347]</font>
285 0> <font color="green">rom[12*(34+56)]</font>
287 0> <font color="green">sp</font>
289 0> <font color="green">rom[256*dph+dpl]</font>
294 Value of the memory operand is always a positive integer number.
297 <h4>Bit operands</h4>
299 Bit operands are evaluated to 0 or 1. Any bit of any memory location
300 can be specified as bit using following form:
302 <pre>memory.bitnumber</pre>
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.
309 <p>Alternatively, name of the bit can be used to specify named SFR
313 0> <font color="green">p0.3</font>
315 0> <font color="green">xram[12*(34+56)].9-2</font>
317 0> <font color="green">it0</font>
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>- &</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>
334 Arithmetic operators and parenthesises work as usual.
336 <p>Assigment operator can be used to modify memory cells and bits of
337 the cells. Result will be the assigned value.
340 0> <font color="green">p0=23</font>
342 0> <font color="green">i h port[0]</font>
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>
349 0> <font color="green">i h p[0]</font>
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>
356 0> <font color="green">dump rom 0 0</font>
358 0> <font color="green">dump sfr dph dph</font>
360 0> <font color="green">dump sfr dpl dpl</font>
362 0> <font color="green">dump xram 0 0</font>
364 0> <font color="green">0x6c</font>
366 0> <font color="green">dump ea</font>
368 0> <font color="green">ea= 1111</font>
370 0> <font color="green">dump ea</font>
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.
380 0> <font color="green">dpl</font>
382 0> <font color="green">&dpl</font>
384 0> <font color="green">ea</font>
386 0> <font color="green">&ea</font>
388 0> <font color="green">256*dph+dpl</font>
390 0> <font color="green">&xram[256*dph+dpl]</font>
398 <a name="redir"><h2>Redirection</h2></a>
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 µCsim doesn't allow to put redirection at the beginning of the
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....