?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

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