Syntactically 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.
0> help run run [start [stop]] Start execution in foreground Alternate name(s) of command: continue 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:
0> help set set subcommand Set value of different objects Alternate name(s) of command: 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 error_name on|off|unset Set value of an error set console interactive [on|off]|noninteractive|raw|edited Set console parameters set memory memory_type address data... | bit data Place list of data into memory OR set specified bit(s) to data set hardware category params... Set parameters of specified hardware element Long of set 0> 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 error_name on|off|unset Set value of an error set console interactive [on|off]|noninteractive|raw|edited Set console parameters set memory memory_type address data... | bit data Place list of data into memory OR set specified bit(s) to data set hardware category params... Set parameters of specified hardware element 0>
0> get opt prompt 47. prompt(by console0): "" - Prompt string of console0 48. prompt(by s51): (null) - String of prompt (-p) 0> set opt 47 s51> 0s51>set opt 47 ".s51> " 0.s51> get opt prompt 47. prompt(by console0): ".s51> " - Prompt string of console0 48. prompt(by s51): (null) - String of prompt (-p) 0.s51>
0> dump P1.1 0x90.1 0b------1- 0x01 '.' 1 0> dump 0x80.1 0x80.1 0b------1- 0x01 '.' 1 0> dump P2[5:2] 0xa0[5:2] 0b--1111-- 0x0f '.' 15 0>
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) Configuration memory of port 0x00 00000001 . Turn/get on/off state (bool, RW) 0x01 000000ff . Outside value of port pins (int, RW) 0x02 000000ff . Value of the port (int, RO) 0x03 000000ff . Value of output register (int, RW) 0>
0> set mem xram 0x100 0x61 0x62 0x63 0x0100 61 62 63 abc 0> where xram "ab" 0x63 0x0100 61 62 63 abc 0>
0> dump 0.2
0x00000.2 0
0> dump 0xc3.2
0x000c3.2 1
0> var a_reg rom[0x1000]
0> dump a_reg[7:0]
0x01000 a_reg 0b11110111 0xf7 '.' 247 ( -9)
0> dump a_reg[5:2]
0x01000[5:2] a_reg[5:2] 0b--1101-- 0x0d '.' 13 ( -3)
0> var some_bits rom[0x1000][5:2]
0> dump some_bits
0x01000[5:2] some_bits 0b--1101-- 0x0d '.' 13 ( -3)
0> dump some_bits[4:3]
0x01000[4:3] a_reg[4:3] 0b---10--- 0x02 '.' 2 ( -2)
0>
Note that in the above the [4:3] overrides the
[5:2] defined for the var and some_bits[4:3]means
bits 4 through 3 of the value stored at 0x1000. It does not mean
take the bits defined by the var and then take a subset of those
bits. Note also that the output does not tell us we are looking
at some_bit
(because we're not) but since we have a var set for the address as a whole
it does tell us that we are looking at a subset of a_reg.
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 can be evaluated by expression command. 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> expr /X xram[12*(34+56)] 0xd1 0>
0> 12 12 0> 012 10 0> 0x12 18 0> $12 18 0> 0b010101 21 0> 'A' 65 0>Numbers must be integers (floating point is not supported) and not bigger than the value which can be stored as long int. Numbers can be specified in ascii form too: 'a', result will be ascii code of the character. This form accepts C style escapes, for example: '\n' or '\033'.
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] 243 0> xram_chip[1347] 243 0> rom[12*(34+56)] 255 0> SP 7 0> rom[256*DPH+DPL] 255 0>
You can assign a symbol (name) to any memory location, this name is called variable (see var, and info var commands). To specify memory operand, you can use variable name as well:
0> var rom_loc rom[0x1234] 0> info var rom_loc rom_loc rom[0x1234] = 0xff,255U,255 0> rom_loc 255 0> rom_loc='A' 65 0> expr /c rom_loc 'A' 0>
Value of the memory operand is always a positive integer number.
memory.bitnumberwhere 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 1 0> IT0 0 0>
| Type | Operator | Meaning |
|---|---|---|
| Primary | ( ) | Group of sub-expressions |
| One operand | + - & ~ ! | Unary plus, minus, address of, bit negate, logical not |
| Arithmetic | * / % | Multiply, divide, modulo |
| + - | Add, subtract | |
| << >> | shift left, right | |
| Logical | < > <= >= == != | Comparison of two values |
| && || ^^ | Logical and, or, xor | |
| Bitwise | & | ^ | Bitwise and, or, xor |
| Assignment | = *= /= %= += -= <<= >>= &= |= ^= | Assign to |
| Increment, decrement | ++ -- | Can be used in prefix or postfix style |
| Conditional | ?: | Works as in C |
| Comma | , | Evaluates expression in order, results last |
Assignment operator can be used to modify memory cells and bits of the cells. Result will be the assigned value.
$ ucsim_51 remo.hex uCsim 0.9.10, Copyright (C) 1997 Daniel Drotos. 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. 0> P0=23 23 0> info hw 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) Configuration memory of port 0x00 00000001 . Turn/get on/off state (bool, RW) 0x01 000000ff . Outside value of port pins (int, RW) 0x02 00000017 . Value of the port (int, RO) 0x03 00000017 . Value of output register (int, RW) 0> P0.0=0 22 0> info hw 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) Configuration memory of port 0x00 00000001 . Turn/get on/off state (bool, RW) 0x01 000000ff . Outside value of port pins (int, RW) 0x02 00000016 . Value of the port (int, RO) 0x03 00000016 . Value of output register (int, RW) 0> dump EA 0xaf EA: 0b0 0x00 '.' 0 0> EA=1 1 0> expr EA 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> EA 0 0> &EA 175 0> DPH=0x12 18 0> DPL=0x34 52 0> expr /x 256*DPH+DPL 1234 0> expr /x &xram[256*DPH+DPL] 1234 0>
$ ucsim_51 remo.hex uCsim 0.9.10, Copyright (C) 1997 Daniel Drotos. 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. 0> dump /x rom >/tmp/rom.dump 0> quit 0> $ cat /tmp/rom.dump 0x0000 02 01 60 02 00 3c ff ff ..`..<.. 0x0008 ff ff ff 02 2f 74 ff ff ..../t.. 0x0010 ff ff ff 02 00 ac ff ff ........ 0x0018 ff ff ff ff ff ff ff ff ........ 0x0020 ff ff ff 02 01 1c ff ff ........ 0x0028 ff ff ff 32 ff ff ff ff ...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 $