Lab3_Exercise01-Assembly (2)
Lab3_Exercise01-Assembly (2)
The objective of this exercise is familiarization with the Keil MDK-ARM programming
environment (creating projects, entering assembly language programs, assembling, simulating, and
debugging). An assembly language program is entered and simulated in Keil MDK-ARM, and
various questions about the environment explore important features of assembly language
programming with Keil MDK-ARM.
Prelab Work
Procedure
Figure 1. Opening Keil MDK-ARM’s µVision IDE
Page 1 of 15
Lab Exercise 1: Tutorial Page 2 of 15
b. Click the Save icon (or select menu FileSave) to save the program.
5. Edit target options for the project.
Note: during assembly, a listing file will be produced, which has columns
added to the left of the assembly source. Because the number of characters on a
line increases in the listing file, it is best viewed in landscape mode. The
settings below produce a listing file suitable for printing in landscape mode
from a text editor, such as Notepad++.
a. On the second toolbar row, click the Target Options icon (or select menu
ProjectOptions for Target 'Target1' …) to launch the Options for
Target 'Target1' window, as shown in Figure 9.
Q2. In ConstData, why does DCD produce different word values for 0x00000010
and 10?
Q3. How much storage and what memory contents are shown for VarData in the
listing file?
Q4. At what offset within the RAM AREA does VarData begin?
Q5. What opcode (in hexadecimal) is generated for the NOP instruction?
Q6. How many bytes of machine code are generated for each assembly instruction?
Q7. Do assembly language program labels generate any code bytes? Explain why.
Q8. According to the symbol table at the end of the listing file, how many times is
SP_INIT used (not counting its definition).
d. Click on the Linker tab along the top of the window to get the options shown in
Figure 13.
0306-250 20141 Lab Exercise 1: Tutorial Page 11 of 15
b. On the second toolbar row, either click the Run button, select menu
DebugRun, or press F5.
c. On the second toolbar row, either click the Step button, select menu
DebugStep, or press F11. Look at Register pane to see the effects of executing
the instruction.
18. Start a new debug session and track all changes to the registers in Table 1.
a. On the top toolbar row toward the right of the window, click the Start/Stop
Debug Session icon to stop the debug session and return to the µVision IDE.
b. From the µVision IDE click the Start/Stop Debug Session icon to start a new
debug session.
c. Step through the program instructions to record each instruction’s register
changes in Table 1. Note that xPSR will have to be expanded to show N, Z, C, and
V. If an instruction does not change the value of a register, you may leave its cell in
the table blank rather than rewriting the same value.
If an instruction does not change the value of a register, you may leave its
celin the table blank rather than rewriting the same value.
Caution: The double-line border before the last NOP instruction in the
tableindicates that other instructions are executed before this NOP. Step
through the instructions not listed in the table and record the results after this
NOP has executed for the first time.
19. Show your completed table to your lab instructor for signature.
Report
LDR R0,=ICER
MOVS R1,#0
MVNS R1,R1
STR R1,[R0,#0]
LDR R0,=SP_INIT
MOV SP,R0
NOP
LDR R2,=ConstData
MOVS R3,#0x02
LDR R1,[R2,#0]
LDR R0,=VarData
STR R1,[R0,#0]
LDR R1,[R2,#4]
STR R1,[R0,#4]
ADDS R2,#8
SUBS R3,#1
BNE Loop
LDR R1,[R2,#0]
LDR R0,=VarData
STR R1,[R0,#0]
LDR R1,[R2,#4]
STR R1,[R0,#4]
ADDS R2,#8
NOP