## General commands of μCsim

### analyze [addr]

Runs the analyzer to identify code. If an address is given it is taken as the starting point and the results added to any existing analysis. If no address is given or a file is loaded into memory using the file,load command any existing analysis is cleared and a new one created using all the known hardware vectors as starting points.

### conf

Conf command can be used to display different kind of information about μCsim. It can be followed by a subcommand:

conf
conf objects

> #### conf

> This command (without a subcommand) prints out configuration of the simulator:

>     0> conf
>     ucsim version 0.5.0-pre3
>     Type of microcontroller: 51 CMOS
>     Controller has 9 hardware element(s).
>       timer0[0]
>       timer1[1]
>       uart[0]
>       port[0]
>       port[1]
>       port[2]
>       port[3]
>       irq[0]
>       _51_dummy[0]
>     0>

> First line contains version number of the program. Second line informs about type of the simulated microcontroller. Third line prints out how many hardware elements are simulated.

> #### conf objects

> This command is for development only.

### version

Print out the version of the program.

    0> ver
    0.6-pre58
    0>

### ?,help [command]

Help command. It prints out short description of the commands.

If a command name is given as parameter then ?Csim prints out all command that has similar names:

    0> ? s
    show subcommand    Generic command for showing things about the uCsim
    set subcommand     Set, see `set' command for more help
    stop               Stop
    step               Step
    state              State of microcontroller
    statistic [mem [startaddr [endaddr]]]
                       Statistic of memory accesses
    0> ? s o
    show option [name] Show internal data of options
    set option name|nr value
                       Set value of an option
    0>

Some commands have more than one name which can produce interesting result:

    0> ? t r
    timer delete id    Delete a timer
    timer start id     Start a timer
    0>

It looks that names of listed subcommands start with no "r" but take a closer look on that commands:

    0> ? t d
    timer delete id    Delete a timer
    Names of command: delete remove
    long help of timer delete
    0> ? t start
    timer start id     Start a timer
    Names of command: run start
    long help of timer run
    0>

If parameter is unique name of a command then long description of the command is printed out.

### quit

Quit. This command terminates actual console, it does not ask you to confirm your intention. Simulator always reads commands from a file so end of file condition finishes too.

Note that if -Z option was used at invocation then the quit command does not terminate the simulator program. In this case kill command can be used to terminate the simulator. See for more information about using multiple consoles.

    $ ucsim_51
    ucsim 0.2.24, 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.
    > q
    $

### kill

This command terminates the simulator. It does not ask for confirmation. It doesn't matter how many consoles are used and what commands are running on them.

### exec "file"

Reads commands from "file" and executes them. This command opens a new console (which will use same in/out file as the actual one) to execute the file. This means the "quit" command in the file will not exit the simulator:

    drdani@emma:~$ cat /tmp/x
    get opt
    quit
    conf
    drdani@emma:~$ ucsim_51
    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.
    0> exec "/tmp/x"
    1> get opt
     0. config_file(by application) is hidden!
     1. console_on(by application) is hidden!
     2. cpu_type(by application) is hidden!
     3. debug(by console1): FALSE - Debug messages to console1
     4. debug(by console0): FALSE - Debug messages to console0
     5. debug(by application): FALSE - Print debug messages (-V)
     6. irq_stop(by mcs51_controller): FALSE - Stop when IRQ accepted
     7. null_prompt(by application): FALSE - Use \0 as prompt (-P)
     8. prompt(by console1): "" - Prompt string of console1
     9. prompt(by console0): "" - Prompt string of console0
    10. prompt(by application): (null) - String of prompt (-p)
    11. serial_in_file(by application) is hidden!
    12. serial_out_file(by application) is hidden!
    13. xtal(by application): 11059200.000 - Frequency of XTAL in Hz
    1> quit
    0>

### expression [/format] expr

Executes "expr" as an expression. For more about expressions, see command syntax.

    0> expr 1 + 2
    3
    0> expr xram[256*dph+dpl]= &sp
    129
    0>

Following formats are supported:

- x hexadecimal
- X hexadecimal prefixed with `0x`
- 0 8 characted long hexadecimal prefixed with `0x`
- d signed decimal
- o octal
- u unsigned decimal
- b binary
- B logical value as one bit
- L logical value in T/F form
- c chacter constant in 'c' form (non-printable values are escaped in c syntax)

If more then one format character is used then all requested form will be printed:

    0> expr /bx 123
    00000000000000000000000001111011
    7b
    0>

### show

Show command can be used to display different kind of information. It must be followed by a subcommand. Subcommands are:

show copying
show warranty
show option
show error

> #### show copying

> This command can be used to list licensing information. It is first 10 point of the version 2 of GNU General Public License. If you do not accept GPL simply do not use the program.

> #### show warranty

> This command prints out last 2 point of the license ("NO WARRANTY" message).

> #### show option

> This command is for development only.

> #### show error

> Errors or warnings are events which can happen in the simulated system during simulation. Report of that events can be turned on or off using set error command. Errors are organized in parent-child relationship. Children are listed under the parent:

>     0> sh er
>     Error: non-classified [on/ON]
>       Error: memory [on/ON]
>         Error: invalid_address [unset/ON]
>         Error: non_decoded [unset/ON]
>       Error: stack [off/OFF]
>         Error: stack_tracker [unset/OFF]
>           Error: stack_tracker_wrong_handle [unset/OFF]
>           Error: operation_on_empty_stack [unset/OFF]
>           Warning: stack_operation_unmatched_to_top_of_stack [unset/OFF]
>           Warning: stack_looks_corrupted [unset/OFF]
>     0>

> First element is the type (Error or Warning). Error stops the simulation. Warning is just reported and simulation goes on. Next element is the name of the error. Last element shows actual value and state. Value can be:
> on
>   state is ON
> off
>   state is OFF
> unset
>   state is inherited from the parent.
> If state is ON and the event happens, it is reported. If state is OFF then the event is silently ignored.

### get

This command can be used to get value of various kind of things. It requires a subcommand to specify what is going to be set. Known subcommands are:

get sfr
get option
get error

> #### get sfr address...

> This command can be used to check values of SFR location(s) if SFR exists in simulated memory. Note that dump memory or ds can be used as well.

> Parameters are interpreted as SFR names or addresses and values of addressed locations are dumped out.

>     $ ucsim_51
>     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.
>     0> get sfr pcon p1 0 0x80 kahd scon 256
>     0x87 00 .
>     0x90 ff .
>     Warning: Invalid address 0
>     0x80 ff .
>     Warning: Invalid address kahd
>     0x98 00 .
>     Warning: Invalid address 256
>     0>

> #### get option [name]

> Get actual value of option(s). Some options can be set by set option to modify behaviour of the simulator. Using get option you can get actual value of these options. If you use this command without parameter you get list of all options known by the program. In this way you can figure out which options can be used.

>     $ ucsim_51 -V
>     ucsim 0.5.0, 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.
>     0> get opt
>      3. debug(by console0): FALSE - Debug messages to console0
>      4. debug(by application): FALSE - Print debug messages (-V)
>      5. irq_stop(by mcs51_controller): FALSE - Stop when IRQ accepted
>      6. null_prompt(by application): FALSE - Use \0 as prompt (-P)
>      7. prompt(by console0): "" - Prompt string of console0
>      8. prompt(by application): (null) - String of prompt (-p)
>     11. xtal(by application): 11059200.000 - Frequency of XTAL in Hz
>     0>

> First element of the list is the number of the option. It is followed by name of the option (debug, irq_stop, etc.). Number or the name can be used to identify the option in get option and set option command. Next element shows which part of the simulator created the option.

> Next element of the list is the value of the option. It can be an integer or a floating point number, a string or a boolean value.

> Last part describes the option.

> Some options can have same name. An example is the debug option. One is created by the application to store value given by -V (see invocation). This will be used as default value when a new instance of a console is created:

>     $ cat /tmp/x
>     get opt debug
>     $ ucsim_51
>     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.
>     0> get opt debug
>      3. debug(by console0): FALSE - Debug messages to console0
>      4. debug(by application): FALSE - Print debug messages (-V)
>     0> set opt 4 1
>     0> get opt debug
>      3. debug(by console0): FALSE - Debug messages to console0
>      4. debug(by application): TRUE - Print debug messages (-V)
>     0> exec "/tmp/x"
>     1> get opt debug
>      3. debug(by console1): TRUE - Debug messages to console1
>      4. debug(by console0): FALSE - Debug messages to console0
>      5. debug(by application): TRUE - Print debug messages (-V)
>     1>
>     0>

> #### get error

> Same as show error.

### set

This command can be used to set various kind of things. It requires a subcommand to specify what is going to be set. Known subcommands are:

set option
set error
set memory
set bit
set hardware

> #### set option name|nr value

> Set option value. Options described at (get option) command can be set using this command. First parameter must be an option name or number and second the new value. Interpretation of the value depends on type of the option. Value for a boolean type of option interpreted as follows: if first character of the value is one of `1`, `t`, `T`, `y`, `Y` then value will be TRUE otherwise it will be FALSE.

>     $ ucsim_51 -V
>     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.
>     > get opt
>      0. config_file(by application) is hidden!
>      1. console_on(by application) is hidden!
>      2. cpu_type(by application) is hidden!
>      3. debug(by console0): TRUE - Debug messages to console0
>      4. debug(by application): TRUE - Print debug messages (-V)
>      5. irq_stop(by mcs51_controller): FALSE - Stop when IRQ accepted
>      6. null_prompt(by application): FALSE - Use \0 as prompt (-P)
>      7. prompt(by console0): "" - Prompt string of console0
>      8. prompt(by application): (null) - String of prompt (-p)
>      9. serial_in_file(by application) is hidden!
>     10. serial_out_file(by application) is hidden!
>     11. xtal(by application): 11059200.000 - Frequency of XTAL in Hz
>     > set opt debug f
>     Ambiguous option name, use number instead
>     > set opt 3 f
>     > get opt debug
>      3. debug(by console0): FALSE - Debug messages to console0
>      4. debug(by application): TRUE - Print debug messages (-V)
>     >

> #### set error error_name on|off|unset

> This command can be used to set if an error event should be reported or not. Actual settings can be retrieved by show error command.

> #### set console interactive [on|off]|noninteractive|raw|edited

> #### set memory memory_type address data...

> This command can be used to modify content of any simulated memory. First parameter must be a class name to specify type of memory. Class names can be checked by info memory command. Chips and address spaces can be used as well.

> Second parameter specifies start address of the modification.

> Remaining parameters will be written into the memory starting at address specified by second parameter. Data list can include numbers as well as strings. See syntax for more details.

> Modified memory locations will be dumped out.

>     0> set mem xram 1 "ab\tcd\0ef\012ghq" 2 "ABC"
>     0x0001 61 62 09 63 64 00 65 66 ab.cd.ef
>     0x0009 0a 67 68 71 02 41 42 43 .ghq.ABC
>     0> set mem sfr pcon 0x34
>     0x87 34                      4
>     0> set mem xram_chip 1 2
>     0x0001 02                      .
>     0>

> #### set bit address 0|1

> Set one bit to 0 or 1. First parameter specifies the bit. It can be the address of the bit (number or symbolic name) or it can be specified in address.bitnumber format where address addresses SFR area and bitnumber is number of bit in specified SFR location. Using this syntax any SFR (and 8051's internal RAM) location can be modified it need not be really bit addressable.

> Second parameter interpreted as 1 if it is not zero.

> Modified memory location is dumped out.

>     $ ucsim_51
>     ucsim 0.2.38-pre2, 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.
>     > set bit tf1 1
>     0x88 80 .
>     > set bit 130 0
>     0x80 fb .
>     > set bit pcon.2 1
>     0x87 04 .
>     > set bit 10.7 1
>     0x0a 80 .
>     >

> #### set hardware hardware_id data

> This command can be used to set value into a hardware element of the controller (conf command lists them).

> Actually only port element of MCS51 accepts this method. It can be used to set value of external circuits which connected to ports of simulated controller. First parameter specifies port element (as an array), second is the new value.

>     0> conf
>     Type of microcontroller: 51 CMOS
>     Controller has 9 hardware element(s).
>       timer0[0]
>       timer1[1]
>       uart[0]
>       port[0]
>       port[1]
>       port[2]
>       port[3]
>       irq[0]
>       _51_dummy[0]
>     0> set hw port[0] 12
>     0> i h po[0]
>     port[0]
>     P0    11111111 0xff 255 . (Value in SFR register)
>     Pin0  00001100 0x0c  12 . (Output of outside circuits)
>     Port0 00001100 0x0c  12 . (Value on the port pins)
>     0> set hw port[0] 23
>     0> i h po[0]
>     port[0]
>     P0    11111111 0xff 255 . (Value in SFR register)
>     Pin0  00010111 0x17  23 . (Output of outside circuits)
>     Port0 00010111 0x17  23 . (Value on the port pins)
>     0> set hw irq[0] 12
>     Nothing to do
>     0>

### state

State of the simulator and the simulated microcontroller:

    > state
    CPU state= OK PC= 0x009c6c XTAL= 1.10592e+07
    Operation since last reset= (51682412 vclks)
    Inst= 51682412 Fetch= 51682412 Read= 0 Write= 0
    Total time since last reset= 56.079 sec (620188944 clks)
    Time in isr = 0 sec (0 clks)   0%
    Time in idle= 0 sec (0 clks)   0%
    Max value of stack pointer= 0x000007, avg= 0x000003
    Simulation: stopped
    >

The "CPU state" in the first line is an internal information. PC is value of the program counter. First line shows XTAL frequency too.

Following lines contain information about simulated time. First, full simulated time (elapsed from last reset) is printed out in seconds and number of clock periods then same data is printed out about time spent in interrupt service routines as well as in idle mode. Last data in lines of ISR and IDLE time shows ratio of ISRs, Idle times and main program.

Last lines inform about maximum value of the stack pointer and a "not very well" calculated average value of it, and if the simulation is running or stopped.

### reset

Reset command. It resets the microcontroller. It has same effect as active signal on the RST pin.

    $ ucsim_51 -V remoansi.hex
    ucsim 0.2.24, 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.
    58659 bytes read from remoansi.hex
    > i r
    000000 00 00 00 00 00 00 00 00 ........
    000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
    000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
       000000 02 01 60 LJMP  0160
    > s
    000000 00 00 00 00 00 00 00 00 ........
    000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
    000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
       000160 c2 90    CLR   P1.0
    > s
    000000 00 00 00 00 00 00 00 00 ........
    000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
    000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
       000162 c2 97    CLR   P1.7
    > res
    > i r
    000000 00 00 00 00 00 00 00 00 ........
    000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
    000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
       000000 02 01 60 LJMP  0160
    >

### info

This command prints out information about different things which must be specified as parameter to the command. Following subcommands are known:

info breakpoints
info registers
info hardware
info memory
info variables
info history

> #### info breakpoints

> This subcommand prints out information about breakpoints:

>     0> b 12
>     Breakpoint 1 at 0x00000c: MOV   R7,A
>     0> tb 43
>     Breakpoint 2 at 0x00002b: MOV   R7,A
>     0> b sfr w 0x80
>     0> i b
>     Num Type       Disp Hit   Cnt   Address  What
>     1   fetch      keep 1     1     0x00000c MOV   R7,A
>     2   fetch      del  1     1     0x00002b MOV   R7,A
>     3   event      keep 1     1     0x000080 write
>     0>

> As you see above, the command can be shortened to "i b". The list of breakpoints contains 7 columns:
> Num
>   Number of the breakpoint.
> Type
>   This column shows type of the breakpoint. It can be fetch for normal breakpoints or event for event breakpoints. First the normal breakpoints are listed and then the event breakpoints.
> Disp
>   This shows if the breakpoint is temporary (del) or not (keep).
> Hit
>   How many times the breakpoint must be hit before it really stops the program.
> Cnt
>   Counter of breakpoint hits. This counter decrements and the breakpoint is activated if it reaches zero.
> Address
>   Address where the breakpoint is set.
> What
>   For normal breakpoints this field contains disassembled instruction where the breakpoint is set. For event breakpoints it contains type of event.

> #### info registers

> This subcommand prints out full register set of the CPU. Output of this command depends of type of CPU.

> ##### Registers of MCS51 family

>     $ ucsim_51 remoansi.hex
>     ucsim 0.2.12, 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.
>     58659 bytes read from remoansi.hex
>     > sopt stopit 1
>     > g
>     5
>      * 000023 02 01 1c LJMP  011c
>     > i r
>     000000 18 02 16 ba 00 02 00 0a ........
>     000018 4a J  ACC= 0x0a  10 .  B= 0x00   DPTR= 0x16ba @DPTR= 0x00   0 .
>     000002 16 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
>      * 000023 02 01 1c LJMP  011c
>     >

> In first line the actual register bank is dumped out. Register banks reside in internal RAM, address at the beginning of the line shows start address of actual register bank selected by RS0 and RS1 bits of PSW register.

> Next two lines begin with value of indirectly addressed internal RAM cells. Second line shows IRAM cell pointed by R0 while third line shows IRAM addressed by R1.

> Second line displays some important registers. First one is the accumulator. Its value dumped out in hexadecimal, decimal form and then the ASCII character of its value. It is followed by value of the B register which is dumped out in hexadecimal form only. Next is DPTR register in hexadecimal and then external RAM cell which is addressed by DPTR. This is dumped out in hexadecimal, decimal and ASCII too.

> In third line you find program status word in hexadecimal and then some flag bits of PSW register. Last line is disassembled instruction at PC.

> ##### Registers of AVR family

>     $ ucsim_avr test_arith.hex
>     ucsim 0.2.37, 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.
>     > 83 words read from test_arith.hex
>     83 words read from test_arith.hex
>     > run

>     Stop at 0x000047: (105) User stopped
>     F 0x000047
>     > i r
>     000000 00 2c 21 23 20 35 19 14 03 00 00 00 00 00 00 00 .,!# 5..........
>     000010 00 01 1e 89 01 00 10 e2 14 00 01 10 00 00 00 00 ................
>     ITHSVNZC  SREG= 0x03   3 .
>     00000011  SP  = 0x000000
>     X= 0x1001 [X]= 0x00   0 .  Y= 0x0000 [Y]= 0x00   0 .  Z= 0x0000 [Z]= 0x00   0 .
>      * 000047 940c 0047 jmp   0x000047
>     >

> First two lines show first 32 bytes of internal RAM which is the register set of AVR controllers.

> At the beginning of next two lines bits of status register are printed. These lines present hexadecimal, decimal and ASCII values of the status register too, and value of the stack pointer.

> Following line shows indirect addressing registers X, Y, and Z as well as pointed memory values.

> Last line is disassembled instruction at PC.

> ##### Registers of Z80 family

>     $ ucsim_z80
>     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.
>     0> i r
>     SZ-A--P-C  Flags= 0x00   0 .  A= 0x00   0 .
>     00-0--0-0
>     BC= 0x0000 [BC]= 00   0 .  DE= 0x0000 [DE]= 00   0 .  HL= 0x0000 [HL]= 00   0 .
>     IX= 0x0000 [IX]= 00   0 .  IY= 0x0000 [IY]= 00   0 .  SP= 0x0000 [SP]= 00   0 .
>      ? 0x0000 00          NOP
>     0>

> ##### Registers of XA family

>     $ ucsim_xa
>     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.
>     The XA Simulator is in development, UNSTABLE, DEVELOPERS ONLY!
>     0> i r
>     CA---VNZ | R0:0100 R1:0302 R2:0504 R3:0706
>     00---000 | R4:0908 R5:0b0a R6:0d0c SP:0100 ES:0000  DS:0000
>      ? 0x0302 02 03             ADD   R0l,[R3]
>     0>

> ##### Registers of HC08 family

>     $ ucsim_m68hc08
>     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.
>     0> i r
>     V--HINZC  Flags= 0x60  96 `  A= 0x00   0 .
>     0--00000      H= 0x00   0 .  X= 0x00   0 .
>     SP= 0x00ff [SP+1]= 00   0 .
>      ? 0x0000 00 01 02    brset #0,*0x01,0x0005
>     0>

> #### info hardware|hw identifier

> This subcommand prints out information about a unit of the controller. identifier specifies hardware element. One form of it is a name. Names of hardware elements can be checked by conf command. This form is accepted only when name is unique. If more than one element exists with the same name then name must be followed by id number in square brackets in same form as it is listed by conf command.

> Output format of this command depends on CPU family and type of the CPU too because requested unit can be different in different type of controller even in the same CPU family.

>     $ ucsim_51 -t 51
>     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.
>     0> conf
>     ucsim version 0.5.0-pre3
>     Type of microcontroller: 51 CMOS
>     Controller has 8 hardware element(s).
>       timer0[0]
>       timer1[1]
>       uart[0]
>       port[0]
>       port[1]
>       port[2]
>       port[3]
>       irq[0]
>       _51_dummy[0]
>     0> i h port[2]
>     port[2]
>     P2    11111111 0xff 255 . (Value in SFR register)
>     Pin2  11111111 0xff 255 . (Output of outside circuits)
>     Port2 11111111 0xff 255 . (Value on the port pins)
>     0> i h t[0]
>     timer0[0] 0x0000 13 bit timer OFF irq=0 dis prio=0
>     0> i h u
>     uart[0] Shift, fixed clock MultiProc=none irq=dis prio=0
>     Receiver OFF RB8=0 irq=0
>     Transmitter TB8=0 irq=0
>     0>

> Timer #2 differs a little bit from other timers of MCS51:

>     $ ucsim_51 -t 52
>     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.
>     0> i h timer0
>     timer0[0] 0x0000 13 bit timer OFF irq=0 dis prio=0
>     0> i h t[2]
>     timer2[2] 0x0000 reload 0x0000 timer OFF irq=0 dis prio=0
>     0>

> #### info memory

> This command shows information about memory system: chips, address spaces and address decoders.

>     $ ucsim_51
>     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.
>     0> i m
>     Memory chips:
>       0x000000-0x010000    65536 rom_chip (8,%02x,0x%04x)
>       0x000000-0x000080      128 iram_chip (8,%02x,0x%02x)
>       0x000000-0x010000    65536 xram_chip (8,%02x,0x%04x)
>       0x000000-0x000080      128 sfr_chip (8,%02x,0x%02x)
>     Address spaces:
>       0x000000-0x010000    65536 rom (8,%02x,0x%04x)
>       0x000000-0x000080      128 iram (8,%02x,0x%02x)
>       0x000080-0x000080      128 sfr (8,%02x,0x%02x)
>       0x000000-0x010000    65536 xram (8,%02x,0x%04x)
>     Address decoders:
>      0 rom 0x0000 0xffff -> rom_chip 0x0000 activated
>      0 iram 0x00 0x7f -> iram_chip 0x00 activated
>      0 sfr 0x80 0xff -> sfr_chip 0x00 activated
>      0 xram 0x0000 0xffff -> xram_chip 0x0000 activated
>     0>

> First column shows address ranges, next one is the size followed by the name of the memory. This name can be used in other commands (such as dump, set memory, etc.). Last column shows some technical information (width in bits, format specifier to print out content and address).

> Address decoders are associated with address spaces. Each address space has a list of decoders. First column of the address decoder information is the number of the decoder. Next three columns specifies name and area of the address space which is handled by the decoder. After "->" sign the name and the address of the memory chip is printed where the decoder maps the area of the address space.

> Memory system of other controller family can be different.

>     $ savr
>     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.
>     0> i m
>     Memory chips:
>       0x000000-0x00ffff    65536 rom_chip (16,%04x,0x%04x)
>       0x000000-0x00007f      128 iram_chip (8,%02x,0x%02x)
>     Address spaces:
>       0x000000-0x00ffff    65536 rom (16,%04x,0x%04x)
>       0x000000-0x00ffff    65536 iram (8,%02x,0x%04x)
>     Address decoders:
>      0 rom 0x0000 0xffff -> rom_chip 0x0000 activated
>      0 iram 0x0000 0x007f -> iram_chip 0x00 activated
>     0>

> #### info variables [name]

> Print out information about variables. Variable is memory location which has a name. It can be created by var command and several variables are created by the simulator. Optionally the name can be specified in the command to search for it in variable names.

>     0> info var a
>     pa rom[0xf000] = 00000000
>       Data register of pa
>     sim_real_time simif_0_cfg[0xa] = 00000000
>       Real time since reset in msec (int, RO)
>     sim_reason simif_0_cfg[0x5] = 00000000
>       Reason of last stop (int, RO)
>     sim_start simif_0_cfg[0x2] = 00000000
>       WR: start simulation, RD: true if running
>     sim_xtal simif_0_cfg[0x6] = 00a8c000
>       Xtal frequency in Hz (int, RW)
>     0> var abc
>     0> i v a
>     abc variables[0x00] = 00000000
>     pa rom[0xf000] = 00000000
>       Data register of pa
>     sim_real_time simif_0_cfg[0xa] = 00000000
>       Real time since reset in msec (int, RO)
>     sim_reason simif_0_cfg[0x5] = 00000000
>       Reason of last stop (int, RO)
>     sim_start simif_0_cfg[0x2] = 00000000
>       WR: start simulation, RD: true if running
>     sim_xtal simif_0_cfg[0x6] = 00a8c000
>       Xtal frequency in Hz (int, RW)
>     0>

> First word is the name of the variable, followed by memory and the address, last word is the actual value in hexadecimal. Predefined variables have a short description which is printed in next line.

> #### info history

> This command is the same as history information.

### timer

Handling of timers. Don't be confused! This command doesn't handle timer element of the controller. It manages "clock counters" which can be used to profile applications.

Known subcommands are:

timer add
timer delete
timer get
timer start
timer stop
timer set

Each subcommand can (some must) be followed by a timer id which can be a number or a string. Timers are numbered from 1. You can use any number greater than 0 to identify a timer. Or you can use a symbolic name, in this case simulator uses the first unused number to allocate a new timer.

> #### timer add|create|make id [direction [in_isr]]

> To create a new timer. New timers are turned ON by default and initialized to value 0. Direction is an integer (can be positive or negative) number which is added to the actual value in every step. If in_isr is TRUE the timer counts only when execution is in an interrupt handler.

> #### timer delete|remove id

> To remove a timer if you don't need it any more.

> #### timer get [id]

> To get value of timers. If you don't use timer id in this command simulator prints out value of all timers including predefined ones. See example below.

> #### timer start|run id

> To turn a timer ON.

> #### timer stop id

> To turn a timer OFF. It still exist but doesn't count xtal periods.

> #### timer set|value id value

> To set value of the timer (number of xtal periods). value is the new value.

>     0> tim a 3
>     0> tim g
>     timer #0("time") ON: 0.463255 sec (5123232 clks)
>     timer #0("isr") ON: 0.0051888 sec (57384 clks)
>     timer #0("idle") ON,ISR: 0 sec (0 clks)
>     timer #3("unnamed") ON: 0 sec (0 clks)
>     0> tim a "a"
>     0> tim g
>     timer #0("time") ON: 0.463255 sec (5123232 clks)
>     timer #0("isr") ON: 0.0051888 sec (57384 clks)
>     timer #0("idle") ON,ISR: 0 sec (0 clks)
>     timer #1("a") ON: 0 sec (0 clks)
>     timer #3("unnamed") ON: 0 sec (0 clks)
>     0>