Lab 1 Using Visual Emulator: Download The Emulator Answer To Questions (Q)
Lab 1 Using Visual Emulator: Download The Emulator Answer To Questions (Q)
Lab 1 Using Visual Emulator: Download The Emulator Answer To Questions (Q)
1
Using Visual Emulator
Download the emulator
https://salmanarif.bitbucket.io/visual/downloads.html
Answer to questions (Q)
Load the following Program in
Visual Emulator
main
; The purpose of this program is to add: aa+bb=cc LDR r1, =aa ;load memory address of aa into r1 After execution:
PC = 0xC+4
; First we define the variables; The variables are stored in
LDR r2, [r1] ;load content of memory address in r1 into r2 (that
locations 0x100-0x108 in the MEMMORY is 0x0001)
aa DCD 0x00112233 ;load (32 bit) value 0x00000001 into LDR r3, =bb
memory location 0x100 (by default) call it aa LDR r4, [r3]
bb DCD 2 ;load (32 bit) value 0x00000002 into memory location ADDS r5, r2, r4 ;r2+r4 -> r5 and update flags
0x104 (by default)
LDR r6, =cc ;load memory address of cc into r6
cc DCD 0 ;load (32 bit) value 0x00000000 into memory location STR r5, [r6] ;store the sum into variable cc
0x108 (by default)
; this section shows that the sum is infact loaded into cc
LDR r7, =cc
DCB Define Constant Byte Reserve 8-bit values LDR r8, [r7]
DCW Define Constant Half- Reserve 16-bit values ; cc+1--> r9
word ADDS r9, r8, #1
DCD Define Constant Word Reserve 32-bit values
END
DCQ Define Constant Reserve 64-bit values
Execute the Program:
Click on Step Froward
See what happens as
you step through
Note how registers R1-R9
change
Note that the memory address
for aa is 0x100, for bb is 0x104
and so far….
Click on HEX BIN and DEC and
see the values.
Question:
Q1. What is the largest value
of aa variable in HEX and
DECIMAL? How many bits are
required to represent this
value?
Q2. What is the memory
address of cc?
See what happens as
you step through
Note that every time an
instruction is executed, the PC
value is increased.
Note that as ADDS is executed,
the color of CSPR changes
indicating it is being updated.
Question:
Q3. By the time the program is
completed, what is the value
of PC?
See what happens as
you step through
Note that every time an
instruction is executed the
INTRUCTION clock cycle is
increased.
Question:
Q4. How many instruction
cycles are required to execute
ADDS instruction?
Q5. How many instruction
cycles are required to execute
STR instruction?
Q6. How many instruction
cycles are require to complete
this code?
As you execute ….Click on MEMORY when LDR is executed. Note that you
can see the Memory address for variable aa this is where it is saved.
Q7. How many bytes variable aa has?
Question:
Q4. How many instruction
cycles are required to execute
ADDS instruction?
Q5. How many instruction
cycles are required to execute
STR instruction?
Q6. How many instruction
cycles are require to complete
this code?
DATA MEMORY LOCATIONS
0x100 aa
0x104 bb
0x108 cc
INSTRUCTION MEMORY LOCATIONS
Line 1 0x00
Line 9 0x08
Line 10 0x0C
There are two separate memory structures for DATA and INSTRUCTIONS.
The DATA MEMORY in this EMUALTOR starts from 0x100. However, the Instruction
MEMORY starts from 0x0. We know that based on the value of the PC
Question:
Q4. How many instruction
cycles are required to execute
ADDS instruction?
Q5. How many instruction
cycles are required to execute
STR instruction?
Q6. How many instruction
cycles are require to complete
this code?
Try the following commands. In each case specify http://web.sonoma.edu/users/f/farahman/sonoma/courses/es310/310_arm/res
ources/datasheets/list_of_assembly_commands.pdf
the purpose of the command, what happens to the
destination register
Examples Purpose What happens to
Examples Purpose? What happens ? the dest. ?
to the dest. ? CMP r0, #42
MOV r0, #42 CMN r2, #42
MOV r2, r3 TST r11, #1
MVN r1, r0 MOV R2, R0, LSL #2
MOV r0, r0 ADD R9, R5, R5, LSL #3
ADD r0, r1, r2 RSB R9, R5, R5, LSL #3
SUB r5, r3, #10 SUB R10, R9, R8, LSR #4
RSB r2, r5, #0xFF00 MOV R12, R4, ROR R3
AND r8, r7, r2 stop B stop
ORR r11, r11, #1 SUBS r4, r0, r2
BIC r11, r11, #1 SBC r5, r1, r3
EOR r11, r11, #1 UMUL r6, r4, r2
ADC r5, r3 r1 MLS r6, r4, r1, r0
MUL r6, r4, r2 ADD r1, r0, r0, LSL #3
http://web.sonoma.edu/users/f/farahman/sonoma/courses/es310/310_arm/res
ources/datasheets/list_of_assembly_commands.pdf