Starting from:

$30

Homework 2 Application Program Status Register

Homework 2 (20 points in total)
Q1. (4 pts) Application Program Status Register (APSR)’s flags
After the following piece of instructions is executed, what value will be maintained in each of NZCV flags
in APSR?
MOV R0, #0x80000000
MOV R1, #0x1
SUBS R2, R1, R0
Flag Value
N
Z
C
V
Q2. (6 pts) Memory Endianness and Alignment
1) As you see the following example with #1234 at memory address 0x20000000, allocate
#9876543210 to memory address 0x20001000. (2pts)
An example:
Big endian
Address Data Contents (in hex)
0x20000000 04
0x20000001 D2
0x20000002
0x20000003
Little endian
Address Data Contents (in hex)
0x20001000 D2
0x20001001 04
0x20001002
0x20001003
A question you must solve:
#9876543210
Big endian
Address Data Contents (in hex)
0x20000000
0x20000001
0x20000002
0x20000003
Little endian
Address Data Contents (in hex)
0x20001000
0x20001001
0x20001002
0x20001003
2) As you see the following example with exampleData, allocate myData to the memory and fill out
the spaces to indicate how each data element is mapped. Assume that the memory is based on a 32
-bit addressing system. (2pts)
I
06402
9826543210
16 617283950 10A
16 38580246 14
of 2411265 6
16 150704 I
16 9419 O
16 588 NBS
EA 16 36 126
16 2 4 EA
16 16 0 2 BO
4C
oz 34 B EA
An example:
struct exampleData {
 char a;
 short b;
};
+ 0th + 1st + 2nd + 3rd
0th byte a b b
4th byte
8th byte
A question you should solve:
struct myData {
 char a;
 long long int b;
 double c;
 short d;
 char *e;
 float f;
};
+ 0th + 1st + 2nd + 3rd
0th byte
4th byte
8th byte
12th byte
16th byte
20th byte
24th byte
28th byte
32nd byte
Q3. (10 pts) Introduction to VisUAL
Complete the following assembly program that 1) read characters (i.e., ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’,
‘I’, ‘J’, ‘K’, ‘L’) given at address “src”, 2) change them to the corresponding lower-cased characters, and 3)
store them at address “dst”.
I 8
8
a
b b b b
b b b b
c c c c
c c c c d d
e e e e f f f f
Submission: You need to submit two files.
File 1 (5pts): Your HW2-Q3.s.
File 2 (5pts): A pdf file with:
1. (1pts) A screenshot of your code.
2. (4pts) A screenshot of VisUAL’s “View Memory Contents” window.

More products