SC51QuickStartForAssemblyLanguage.pdf

(14 KB) Pobierz
© SPJ Systems, Pune. Phone: +91-20-27293002
www.spjsystems.com
SC51 Quick Start Manual
for
creating 8051 Assembly Language applications
Introduction:
The SC51 software package includes Assembler, Linker, Simulator and C
Compiler for 8051. Besides, an IDE and other tools like Visual Code Generator (VCG) and
terminal emulation cum ISP utility (SPJTerm) are also included. This document describes
steps to write 8051 Assembly language program using SC51; and further how to use
Simulator to test / debug these programs.
1. Start the SIDE51 program (i.e. the Integrated Development Environment)
2. From
Project
menu, select
Close project.
3. From
File
menu, select
New File.
An empty editor window will automatically open. You
may type the assembly language program here.
4. When you finish typing the assembly language program, select
Save As
from
File
menu.
The Save As dialog window will be displayed. Select the desired path where you wish to
save this program (for example, C:\SPJ). CAUTION: the pathname must not contain
space or other special characters such as tab, comma, semicolon etc. Then in the “File
name” field, type the name of the file with extension .ASM (for example, TEST1.ASM).
Just below the “File name” field, there is the selection list box “Save as type”. From this
list, select “All files (*.*)”. Then click on the “Save” button.
5. From the
Project
menu, select
New Project.
The Open dialog window will be displayed.
Select the same path where you saved the program in previous step. In the “File name”
field, type the name of the project, without any extension. The convention is to use the
same name as the program filename. E.g. “TEST1”. Then click on the “Open” button.
6. The action in the previous step will display the “Project Settings” dialog window. This
dialog window has 3 different parts named “Compiler Options”, “Assembler / Linker
Options”, and “Source Files”. Any of these 3 parts can be displayed by clicking on the
corresponding name near the top of this dialog window. Currently, the “Compiler
Options” will be automatically displayed. If the target micro-controller (must be a
member of 8051 family) is known, you may select the appropriate Manufacturer from the
list; and then select the appropriate
µC
from the list. If the target
µC
is not known or if
you cannot find it in the list, then you may simply select “Intel” as the manufacturer and
“8051” or “8052” as the
µC.
Note that when you select “8051” as the
µC,
the “Internal
RAM (Bytes)” selection automatically changes to 128. Similarly, when you select
“8052”, the “Internal RAM (Bytes)” selection automatically changes to 256. Select 8051
or 8052, depending on whether your target
µ
C has 128 or 256 bytes internal RAM,
respectively.
7. In the same window, the “Crystal frequency” field is also displayed with default value as
12 MHz. If your target uses different crystal frequency, then you may change it.
However, the current version of Compiler / Assembler does not actually use this value.
8. Click on “Assembler / Linker Options” to display that part of the dialog window. Since
you wish to use the simulator for debugging, it is necessary to check the box labeled
“Generate Debug Info from .ASM file”.
9. Under “Program Memory (Code Memory) map:” you may enter the start and end address
of program memory available in your target. This program memory maybe internal
(inside the
µC)
or external. E.g. if the target
µC
is Atmel 89C52 without external
memory, then you may enter start address as 0000 and end address as 1FFF.
10. Similarly, enter start and end addresses of the XDATA (i.e. external data memory). This
XDATA memory maybe on-chip or off-chip. Only start and end addresses are important,
but not physical location.
SC51 Quick Start Manual for Assembly Language applications
Page 1 of 3
© SPJ Systems, Pune. Phone: +91-20-27293002
www.spjsystems.com
11. The Compiler / Assembler automatically produces Intel HEX format file (.HEX file). If
you also require the binary image file (.BIN file), then check the box labeled “Generate
.BIN file (ROM image)”.
12. If you plan to use In-Circuit-Emulator (ICE) for debugging, then check the box labeled
“Generate Absolute OMF file”. This will create .AOM file, which is required by the ICE.
13. Click on “Source Files” to display that part of the dialog window. This window will
indicate that IDE has automatically added 2 files in this new project: TEST1.C and
STARTUP.ASM. The STARTUP.ASM file is automatically created by the IDE and is
required if you wish to write program in C. Since we have written an Assembly language
program, we do not need it. So click on the STARTUP.ASM filename to select it and
then click on the “Remove file” button. Similarly, the IDE may have automatically
created an empty C file (TEST1.C), which we do not need. So click on TEST1.C
filename and then click on the “Remove file” button. Now we wish to add our Assembly
language program in this new project. Hence, click on the “Add file” button. Select the
file TEST1.ASM (which we created in an earlier step) and then click on “Open” button.
Now the Project Settings dialog will indicate that TEST1.ASM file has been added into
the project. Now click “OK” button to create this new project.
14. From the
Compile
menu, select
Build.
This will invoke the assembler to assemble the file
TEST1.ASM; and further (assuming no errors) invoke the linker to create the .HEX and
other files. If there are any errors or warnings during the process of assembling or linking,
then those will be displayed in the output window (below the editor window). If there are
errors, then you may correct those by making appropriate changes to the program; select
Save
from
File
menu to save the changes and then again select
Build
from
Compile
menu. Repeat this until there are no errors.
15. Now we are ready to simulate this program. To do so, simply select
Simulator
from the
Tools
menu. Simulator for 8051 is an independent program and it will be launched by this
action and the current project (TEST1) will be automatically opened. The Simulator will
automatically display 5 windows (clockwise, from left-top corner): Program window,
Serial window, Internal RAM watch window, SFR watch window, Symbols watch
window. As the names indicate, these windows display the corresponding information.
So, the same program that you typed will be visible in the Program window.
16. To single step through the program, you may select
Single Step
from the
Run
menu
(pressing
F7
key is also equivalent). When you do so, the program window will indicate
that one instruction has been executed and the next instruction will be highlighted. You
may repeat the same to single step through the entire program.
17. While single stepping through the program, the contents of general purpose registers (R0-
R7) as well SFRs will be displayed in the SFR Watch Window. The register / SFR
contents can be seen changing as effect of each executed instruction. It is also possible to
modify register / SFR contents (except PC) by double clicking on it’s name.
18. Similarly, it is possible to observe contents of internal RAM while single stepping
through the program. To do so, right click in the Internal RAM Watch Window and then
select
Add
from the pop-up menu. Then enter the starting address of the 16 byte block of
Internal RAM that you wish to observe (e.g. 30) and press “OK” button. Upon doing so,
the entered memory address followed by contents of 16 consecutive locations will be
displayed. It is also possible to modify the contents of Internal RAM by double clicking
on the address in this Internal RAM Watch Window.
19. Similarly, it is possible to observe contents of external RAM while single stepping
through the program. To do so, it is necessary to first make the “External RAM Watch
Window” visible. To do so, select
External RAM Watch
from
View
menu. Then, the
remaining procedure is similar to that followed for Internal RAM Watch Window.
SC51 Quick Start Manual for Assembly Language applications
Page 2 of 3
© SPJ Systems, Pune. Phone: +91-20-27293002
www.spjsystems.com
20. When you are through with debugging, select
Exit
from
File
menu to close the Simulator.
Then (if necessary) you may edit the program, build it again and start the simulator to
debug again. Please note, only one instance of Simulator program should be started at any
time. It is recommended to close the Simulator while making any changes to the program.
SC51 Quick Start Manual for Assembly Language applications
Page 3 of 3
Zgłoś jeśli naruszono regulamin