Академический Документы
Профессиональный Документы
Культура Документы
8392
0200
2005
40B2
03E8
0200
E3E2
0021
9382
0202
240D
D3D2
0021
E0F2
0010
001D
8392
0202
2005
C3D2
0021
C0B1
0010
0000
1300
#0x01, &0x0021
#0x01, &0x0021
#0x01, &0x0021
4. (6 points) For the following assembly code, give contents of R4 after each line
is executed.
1.0x8000:
MOV.W
#FOOEY,R4
2.0x8004:
MOV.W
&FOOEY,R4
3.0x8008:
MOV.W
FOOEY,R4
4.0x800c:
MOV.W
5.0x800e:
MOV.W
6.0x8010:
MOV.W
...
0x9000: FOOEY: .word
...
0xA000: FOOBAR: .word
Answer
Answer
Answer
Answer
Answer
Answer
1:
2:
3:
4:
5:
6:
@R4,R4
@R4,R4
@R4+,R4
0xA000
0x9000
5.(6 points)
Assemble the following MSP430 assembly instructions. The
label TOM is located at address 0x8014. After assembly is completed, what is in
memory locations 0x8014, 0x8016, and 0x8018? (Give
your answer in hexadecimal with 0x.)
0x8014: TOM
BOB
mov.w TOM,BOB
6.(8 points)
Identify four problems in the following assembly program.
How would you fix the problems? (Identify the problems and change or add
instructions to fix them.)
call
mov
sqrtFunc
r0,result
;save
result: .word 0
sqrtFun:
push
push
mov
pop
pop
ret
r4
r5
r6,r0
r4
r5
#0x0006,SP
What are the stack assignments (shown below) and values for variables x, y, and z
just before the final brace?
x = ?
y = ?
z = ?
SUB.W
#0x0006,SP
MOV.W
MOV.W
INCD.W
MOV.W
SP,0x0002(SP)
SP,R15
R15
R15,0x0004(SP)
MOV.W
MOV.W
@R15,R15
; **z = 10;
#0x000a,0x0000(R15)
ADD.W
RET
#0x0006,SP
; {
; int x;
; int* y;
; int** z;
int x;
int* y;
int** z;
y = &x;
z = &y;
**z = 10;
Answers:
Address
0x0280
0x027E
0x027C
0x027A
0x0278
0x0276
; y = &x;
; z = &y;
; }
Data
Return address
0x027A
0x0278
0x000A
SP
2. (2 points) Given the C program on the right, what is the missing MSP430
assembly instruction generated by the compiler for the
struct node
line:
{
int count;
struct node *next;
getdata.next = &getdata;
Answer:
SUB.W
CLR.W
missing
ADD.W
RET
#4,SP
0x0000(SP)
instruction
#4,SP
};
int main(void)
{
struct node getdata;
getdata.count = 0;
getdata.next = &getdata;
return 0;
}