Download HomeWork 3_ARM(2015)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Microprocessor Systems Tutorial 3.
Question 1.
For each code extract shown below, trace the values of the CPU registers used
a)
MOV r0, #10
MOV r1, r0
MOV r0, r1, LSL #4
MOV r1, r1, ASR #1
; r0 = 10
; r1 = r0
; r0 = r1 * 16
; r0 = signed(r1 / 2)
MOV r2, #8
MOV r0, r1, LSL r2
MOV r0, r1, ASR r2
; r2 = 8
; r0 = r1 x 2^r2
; r0 = signed(r1 / 2^r2)
b)
c)
MOV r0,#0
ADD r0, r0, #256
ADD r1, r1, r0, LSL #2
MOV r2, r0, LSR #6
d)
MOV r1, #0x20000000
LDR r0, =5000
STR r0, [r1]
LSL r0, r0, #2
ADD r1, r1, #4
STR r0, [r1]
LDR r3, [r1]
What value will be stored at RAM address 0x20000000 ?
Question 2.
What assembly code will be generated by the C language do .. while statement
shown below?
int i = 0;
do
i ++;
while (i <10);
Check your answer using the assembly dump generated by the IAR C compiler.
Microprocessor Systems Tutorial 3.
Question 3.
MOV r0, #0x20000000
MOV r0, #0x1388
Both instructions load a constant into r0 but the second one throws an assembler
error. Why? How else could you load the constant 0x1388 into r0?
Question 4.
Using the IAR assembler assemble the code extract
LDR r0, =5000
loop SUBS r0,r0,#1
BEQ fini
B
loop
fini
a) Identify the code generated by the pseudo-instruction LDR r0, =5000.
b) Draw a flowchart for this code extract.
Question 5.
Explain the differences between the immediate and the register indirect addressing
modes. Give an example of each using the MOV and the LD instructions.
Question 6.
Explain the difference between an assembler directive and an assembler instruction.
Question 7.
Use the assembler directives ORG (place at memory address) and DC32 (define a
constant) to
a) reserve a 4 byte word at SRAM address 0x2000 0000
b) define a 4 byte variable at SRAM address 0x2000 0007 and initiate it to value
0xDEADBEEF
Question 8.
Explain the operation of the instructions BL (branch and link) and BX (branch and
exchange).
Question 9.
a. Write an assembly subroutine named delay that will keep decrementing the
value it finds on entry in register r0 until it becomes zero and then returns.
b. Write an assembly extract that initiates the r0 with a value 0x3456, then calls
the subroutine delay and finally reads the value stored in r0.
Related documents