Software simulator for MCS51
Download
Simulator is available for two platforms: DOS and UNIX but DOS version
is not supported any more. DOS version is not finished so I call it
demo version and it is available in binary only. Limitations of DOS
version are:
- There is no built in help available;
- Some of the utilities are not working, for example calculator, bit
simulator;
- Serial line works in mode 1 independently of mode bits.
I used this simulator to verify my applications and I never used
missing feautres mentioned above, so I think that this "demo" version
can be usefull anyway.
Download
now
How to install
DOS version
Get the ZIP file and unzip it. ZIP file contains three files:
s51.exe the executable itself, dpmi16bi.ovl and
rtm.exe. Last two files are required because s51.exe is
a DOS protected mode program. Put these files in a directory which is
in the PATH or keep them together with the s51.exe.
UNIX version
UNIX version is distributed in source.
- Get archive file, uncompress and untar it. These steps will
produce a directory s51-X.Y.Z where X.Y.Z is the version
number.
- Go to the directory and configure the package. Issue
configure command. It will determine your system and
make Makefile. Istallation directory can be specified with
--prefix=dir option to the
configure. Default directory is
/usr/local. Executable file will be placed in bin
subdirectory.
- Compile the package with make command.
- Install executable s51 to any directory you want. It can be
done with make install command which will place files
in installation directory specified with --prefix=dir option of
configure. Note that you may have to have special
privilege to do this if installation directory is not writable by you.
How to use
DOS version
S51 for DOS has written in Borland Pascal using Turbo Vision to
produce menu driven, multiwindow user interface which is very easy to
use. The program can be started using following command:
C:\> s51 [input file]
Parameter is optional. If it specified it must be the name of an
Intel hex file. Some screenshots of the program and short descriptions
of them:
UNIX version
The simulator can be started in the following way:
$ s51 [-hHVvP] [-p prompt] [-t CPU] [-X freq[k|M]] [-c file]
[-s file] [files...]
Specified files must be names of Intel hex files. Simulator loads
them in specified order into the ROM of the simulated system.
Options:
- -t CPU
- Type of CPU. Recognized types are: 51, 8051, 8751, C51, 80C51,
87C51, 31, 8031, C31, 80C31, 52, 8052, 8752, C52, 80C52, 87C52, 32,
8032, C32, 80C32, 251, C251. Note that recongition of a CPU type as
option does not mean that the simulator can simulate that kind of
CPU. Default type is C51.
- -X freq[k|M]
- XTAL frequency is freq Hertz. k or M can be
used to specify frequency in kHZ or MHz. Space is not allowed between
the number and the k or M. Default value is 11059200 Hz.
- -c file
- Open command console on file. Command consoles is on
standard input and output by default. Using this option the console
can be opened on any file for example on the serial interface of the
computer.
- -s file
- Connect serial interface of the simulated microcontroller to the
file. Nothing is used by default which means that characters
transmitted by serial interface of the simulated microcontroller go to
nowhere and it will never receive anything. If you are going to
communicate with serial interface interactively the best idea is to
specify a teminal with -s option.
- -p prompt
- Using this option you can specify any string to be the prompt of
command interpreter, for example:
$ s51 -p "s51> "
Software Simulator of MCS51, version 0.0.1
s51>
- -P
- Prompt will be a null ('\0') character. This feature can be
usefull for programs which controlls simulator through a pipe.
- -V
- Verbose mode. The simulator notifies you about some kind of
internal actions for example interrupts. Messages are printed on
command console.
- -v
- Print out version number and stop.
- -H
- Print out types of known CPUs. Names printed out by this option
can be used to determine CPU type using -t option.
- -h
- Print out a short help about the options and stop.
The simulator can be controlled with a simple monitor program which
uses the command console to read commands and print out results. After
starting the program you see a prompt on the command console and you
can write in commands after the prompt:
$ s51
S51 0.2.0, Copyright (C) 1997 Daniel Drotos, Talker Bt.
S51 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.
> h
l file Load (intel hexa) file
dl,do Download (intel hex) data
g [start [stop]] Go
pc [address] Get/set content of PC
s [step] Step
n [step] Next
bs f|d addr [hit] Set FETCH Breakpoint
bse wi|ri|wx|rx|ws|rs|rc f|d addr [hit]
Set EVENT Breakpoint
bd addr Delete FETCH Breakpoint
bde wi|ri|wx|rx|ws|rs|rc addr
Delete EVENT Breakpoint
ba Delete all breakpoints
bl List Breakpoints
dis [start [offset [lines]]]
Disassemble code
dc [start [stop]] Dump code in disass form
dch [start [stop]] Dump code in hex form
di [start [stop]] Dump Internal RAM
dx [start [stop]] Dump External RAM
dr Dump registers
dp Dump ports
ds [addr...] Dump SFR
db addr... Dump bit
si addr data... Set Internal RAM
sx addr data... Set External RAM
sc addr data... Set code (ROM)
ss addr data... Set SFR area
sb addr data... Set bit
sp port data Set port pins
fi start stop data Fill IRAM area with `data'
fx start stop data Fill XRAM area with `data'
fs start stop data Fill SFR area with `data'
fc start stop data Fill ROM area with `data'
res Reset
wi,Wi string Search for `string' in IRAM (Wi case sensitive)
wx,Wx string Search for `string' in XRAM (Wx case sensitive)
wc,Wc string Search for `string' in ROM (Wc case sensitive)
sopt opt value Set value of option
gopt [opt] Get value of option(s)
q Quit
show c|w Show licensing information
h,? Help about commands
>
In command reference you can find more
information about breakpoints and execution of the simulated program.
Code analyzer
This feature is included into both DOS and UNIX versions. Code
analyzer analyzes the code of the simulated program and tries to
figure out which address contains valid instruction. Analyzer starts
analyzing of the code with address 0 which always must contain an
instruction because reset of the device sets zero into program
counter. So, analyzer marks address 0 that it contains an
instruction. Then it marks the address of the next instruction and so
on. If the analyzer finds a jump instruction it continues with
destination address of the jump instruction. If it finds a
call instruction, it recursively analyzes destination address
as well as next instruction follows the call one. Analyzator
stops if it finds an address which is already marked or if it finds a
return instruction or an indirect jump which is
impossible to follow. All these mean that it is impossible to discover
all instructions of the program.
This problem is solved in very simple way in UNIX version. If the
execution reaches an umarked address, the analyzer is called to
analyze the code starting at actual address pointed by the PC. This
method is not included into DOS version but this re-analyzation can be
requested by pressing Ctrl-F7 at any time.