Content:

Command syntax of µCsim

µCsim uses a very simple command interpreter. Command can be entered after µCsim displays the prompt and interpreted when ENTER key is pressed. Commands must start with the name of the command following parameters. Name of the command can be abbreviated if abbreviation is unique. Some commands have more than one names.

Syntacticaly parameters can be a string, bit name, array, number or symbol. Interpretation of these syntactical elements depends on actual command.

If the command line can not be recognized as a known command, µCsim tries to evaluate the command line as an expression. See below for information about operands and operators which can be used in expressions.

Command names

Name of the command must be the first word of the command line. It is not necessary to enter whole name if abbreviation is unique. Help command can be used to check out if a command has more names:
> help run
run [start [stop]] Go
Names of command: go r run
...
Some commands just groups other commands. These commands have a set of so-called sub-commands. Sub-command must be second word in the command line. For example:
> help set
set subcommand     Set, see `set' command for more help
Names of command: set
long help of set
> set
"set" must be followed by the name of a subcommand
List of subcommands:
set option name|nr value
                   Set value of an option
set error on|off|unset
                   Set value of an error
set memory memory_type address data...
                   Place list of data into memory
set bit addr 0|1   Set specified bit to 0 or 1
set hardware cathegory params...
                   Set parameters of specified hardware element

Type of parameters

String type

To distinguish strings and symbols, strings can be sorrounded by (double) quotes. Quotes can be omitted if command parameter is interpreted as string and actual parameter start with a letter (so it doesn't look to be a number) and doesn't contain space. Let's look an example:
0> set opt 7 s51>
0s51>set opt 7 ".s51> "
0.s51> 

Bit type

If parameter contains a dot (.) it is treated as bit specification. Part before the dot gives memory address and part after the dot means bit number in the specified data.
0> dump p1.1
      P1.1 0x90 ff 1
0> dump 0x80.1
      P4.1 0x80 ff 1
0> 

Array type

Parameters contain [ character are treated as arrays. Arrays can be used to specify hardware elements. Array index selects an object if more than one exists:
0> info hw port[0]
port[0]
P0    11111111 0xff 255 . (Value in SFR register)
Pin0  11111111 0xff 255 . (Output of outside circuits)
Port0 11111111 0xff 255 . (Value on the port pins)
0> 

Number type

Some commands accept parameters which in most cases can be numbers. Numbers can be entered in C-style form. If the number begins whith 0x or 0X it is interpreted as a hexadecimal number. If it begins with 0 followed by digits it is interpreted as octal number. In other cases it is interpreted as decimal number.

Symbol type

If a command parameter can not be classified in other ways (doesn't start with a digit or a quote, doesn't contain dot or [) then it will be treated as a symbol. Symbols can be interpreted in several ways.

Interpretation of parameters

Address parameters

Many commands requires memory addresses as parameters. Addresses can be specified using number or symbol type of parameters. Value of symbols depends on processor type. For example MCS52 family of controllers defines more symbols than MCS51 family.

Number, data parameters

When a command expects a number it should get a number. Note, that symbols is not converted to number they can be used as address only!

String parameters

Strings can be entered without quotes if they are recognized as srtings (see above) and do not contain spaces.

Data list parameters

Data list can be any space separated list of numbers and strings. If you include a string in the list, it is broken to list of bytes where every byte is ASCII code of a string's character.
> where xram "ab" 0x43
0xf961 61 62 63                abc
> 

Memory parameters

Where memory type is expected, name of the memory should be used. Most commands accept memory chip and address space too. See memory simulation for more information.

Hardware element parameters

Hardwer elements can be specified by using arrays, where array name is name of the element and the array index selects one if more than one exists.

Bit parameters

Bits can be specified by several ways. One way is using bit type of command parameter:
0> dump 0.2
    0x00.2 0x00 00 0
0> dump 0xc3.2
    0xc3.2 0xc3 00 0
0> dump p2.3
      P2.3 0xa0 ff 1
0>
In this way, any IRAM or SFR location can be addressed as the above example shows.

Other way is using bit address either by value or by symbolic name:

0> dump ea
     IE0.7 0xa8 00 0
0> dump 34
    0x24.2 0x24 24 1
0> dump 0xc7
   SCON1.7 0xc0 00 0
0> 
Of course, only addressable bits can be accessed in this way.

Expressions

If first word of the command line is not recognized as a known command, the command line will be evaluated as an expression and the result value printed (in decimal):
0> 12*(34+56)
1080
0> 

Operands

Operands of the expressions can be

Number operands

Numbers can be entered in decimal, octal (starting with 0 followed by a number), or hexadecimal (started with 0x):
0> 12
12
0> 012
10
0> 0x12
18
0> 
Numbers must be integers (floating point is not supported) and not bigger than the value which can be stored as long int.

Memory operands

Memory can be an address space location or a memory chip cell. It can be specified in following form:
name[address]
where name is the name of the address space or memory chip and address is an expression specifying location (index) of the cell.

Registers in SFR address space can also be specified using pre-defined names (symbols) of the registers.

0> xram[0x543]
67
0> xram_chip[1347]
67
0> rom[12*(34+56)]
56
0> sp
7
0> rom[256*dph+dpl]
88
0> 
Value of the memory operand is always a positive integer number.

Bit operands

Bit operands are evaluated to 0 or 1. Any bit of any memory location can be specified as bit using following form:
memory.bitnumber
where memory is a memory location as a memory operand and bitnumber is number of the bit within the specified memory cell specified as an expression. Note, that dot (.) is part of the syntax, not an operator.

Alternatively, name of the bit can be used to specify named SFR bits.

0> p0.3
1
0> xram[12*(34+56)].9-2
0
0> it0
0
0> 

Operators

Type Operator Meaning
Primary ( ) Group of sub-expressions
One operand - & Unary minus, address of
Arithmetic * / Multiply, divide
+ - Add, substract
Assignment = Assign to
Arithmetic operators and parenthesises work as usual.

Assigment operator can be used to modify memory cells and bits of the cells. Result will be the assigned value.

0> p0=23
23
0> i h port[0]
port[0]
P0    00010111 0x17  23 . (Value in SFR register)
Pin0  11111111 0xff 255 . (Output of outside circuits)
Port0 00010111 0x17  23 . (Value on the port pins)
0> p0.0= 0
0
0> i h p[0]
port[0]
P0    00010110 0x16  22 . (Value in SFR register)
Pin0  11111111 0xff 255 . (Output of outside circuits)
Port0 00010110 0x16  22 . (Value on the port pins)
0> xram[256*dph+dpl]= rom[0]
108
0> dump rom 0 0
0x0000 6c                      l
0> dump sfr dph dph
0x83 00                      .
0> dump sfr dpl dpl
0x82 00                      .
0> dump xram 0 0
0x0000 6c                      l
0> 0x6c
108
0> dump ea
     IE0.7 0xa8 00 0
0> ea= 1111
1
0> dump ea
     IE0.7 0xa8 80 1
0> 
When a symbolic name of the SFR is used, it results value of the named register not the value of the symbol. "Address of" operator can be used to get value of the symbol.
0> dpl
0
0> &dpl
130
0> ea
1
0> &ea
175
0> 256*dph+dpl
46630
0> &xram[256*dph+dpl]
46630
0> 

Redirection

Output of any command can be redirected to a file. Same syntax can be used for this as for UNIX shell. The only difference is that µCsim doesn't allow to put redirection at the beginning of the command!
$ s51 remo.hex
uCsim 0.5.0-pre3, Copyright (C) 1997 Daniel Drotos, Talker Bt.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
55470 words read from remo.hex
0> dump >/tmp/rom.dump rom
0> quit
$ cat /tmp/rom.dump
0x0000 02 01 60 02 00 3c 06 07 ..`..<..
0x0008 08 09 0a 02 2f 6b 0e 0f ..../k..
0x0010 10 11 12 02 00 ac 16 17 ........
0x0018 18 19 1a 1b 1c 1d 1e 1f ........
0x0020 20 21 22 02 01 1c 26 27  !"...&'
0x0028 28 29 2a 32 2c 2d 2e 2f ()*2,-./
0x0030 02 0f a7 02 0e 9c 02 0d ........
0x0038 d2 02 08 41 c0 82 c0 83 ...A....
0x0040 c0 d0 c0 e0 c0 00 a2 90 ........
0x0048 c0 d0 c2 90 78 18 06 30 ....x..0
$ s51 remo.hex
uCsim 0.5.0-pre3, Copyright (C) 1997 Daniel Drotos, Talker Bt.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
55470 words read from remo.hex
0> dump rom 0x50 >>/tmp/rom.dump
0> quit
$ cat /tmp/rom.dump
0x0000 02 01 60 02 00 3c 06 07 ..`..<..
0x0008 08 09 0a 02 2f 6b 0e 0f ..../k..
0x0010 10 11 12 02 00 ac 16 17 ........
0x0018 18 19 1a 1b 1c 1d 1e 1f ........
0x0020 20 21 22 02 01 1c 26 27  !"...&'
0x0028 28 29 2a 32 2c 2d 2e 2f ()*2,-./
0x0030 02 0f a7 02 0e 9c 02 0d ........
0x0038 d2 02 08 41 c0 82 c0 83 ...A....
0x0040 c0 d0 c0 e0 c0 00 a2 90 ........
0x0048 c0 d0 c2 90 78 18 06 30 ....x..0
0x0050 03 4b 20 92 48 30 07 05 .K .H0..
0x0058 c2 07 02 00 9d 30 08 05 .....0..
0x0060 20 93 3a c2 08 90 08 60  .:....`
0x0068 e0 b4 ff 03 02 00 9d 04 ........
0x0070 f0 14 f8 03 03 03 54 1f ......T.
0x0078 90 08 62 25 82 f5 82 e5 ..b%....
0x0080 83 34 00 f5 83 e8 54 07 .4....T.
0x0088 f8 08 74 80 23 d8 fd f8 ..t.#...
0x0090 e0 30 93 07 c8 f4 58 f0 .0....X.
0x0098 02 00 9d 48 f0 d0 d0 92 ...H....
$