Assembly Language
Assembly Language
QUESTION 1
Determine the contents of the destination operands and flags after executing the
following instructions.
Instruction
MOV A,#55H
ADD A,#E6H
SUBB A,#7BH
OV
0
QUESTION 2
PSW
CY
0
AC
0
F0
0
RS1
0
RS0
1
OV
0
P
0
New Value
10H
0FH
0EH
0DH
0CH
0BH
0AH
09H
08H
07H
05H
04H
03H
02H
01H
00H
77H
54H
0BH
45H
9DH
17H
1AH
20H
10H
E4H
12H
23H
34H
F5H
34H
0FH
ABC:
LP:
MOV R0,#10H
MOV A,#1H
MOV @R0,A
INC A
DEC R0
CJNE R0,#0BH,ABC
SJMP LP
QUESTION 3
a)
Determine the addressing modes of the source operand in the following instructions:
(i)
(ii)
(iii)
(iv)
23-03-2008
Instruction
MOV A,@R1
MOV R0,#45H
MOV A,R7
MOV 75H,50H
Addressing Mode
(i)
(ii)
(iii)
(iv)
Valid or Invalid?
QUESTION 4
(a)
Valid/Invalid
Table 1
(b)
Instruction
MOV @R1,45H
XRL 45H,#75H
MOV R7,A
MOV 45H,@R0
Table 2
QUESTION 5
Find out the results of the operation shown in the table below.
Instruction
MOV A, #F5H
ADD A,#F2H
CLR C
ADDC A,#24H
CY
0
-
AC
0
-
OV
0
-
Remark
Initial Value
-
QUESTION 6
Identify the addressing mode of the source operands in the following instructions:
Instruction
MOV A,#56H
MOV 56H,76H
MOV A,@R0
ANL A,#45H
MOV A,R7
ORL A,45H
MOV @R1,25H
ADD A,@R1
SUBB A,45H
23-03-2008
Addressing Mode
PSW
CY
0
AC
0
F0
0
RS1
1
RS0
1
OV
0
P
0
New Value
1FH
1EH
1DH
1CH
1BH
1AH
19H
18H
17H
16H
15H
14H
13H
12H
11H
10H
77H
54H
0BH
45H
9DH
17H
1AH
20H
10H
E4H
12H
23H
34H
F5H
34H
0FH
K2:
LP:
MOV R0,#10H
MOV A,#20H
MOV @R0,A
DEC A
INC R0
CJNE R0,#18H,K2
SJMP LP
QUESTION 8
Identify the addressing mode of the destination operands in the following instructions:
Instruction
MOV 56H,A
MOV 56H,76H
MOV @R0,A
ANL 45H,#35H
MOV R7,A
ORL 55H,A
MOV @R1,25H
MOV R7,#45H
MOV @R1,23H
Addressing Mode
QUESTION 9
Figure 4-1 shows some of the contents in
the 8051 Internal Data Memory. Which
memory location is affected by the
following instruction:
48H
47H
46H
45H
13H
3FH
F5H
51H
SETB 0CH
22H
12H
21H
62H
20H
5AH
Figure 4-1: Internal Data
Memory
23-03-2008
b.
c.
d.
7FH
7EH
2FH
2EH
7FH
77H
7EH
76H
7DH
75H
7CH
74H
7BH
73H
7AH
72H
79H
71H
78H
70H
23H
22H
21H
20H
1FH
17H
0FH
07H
1EH
16H
0EH
06H
1DH
15H
0DH
05H
1CH
14H
0CH
04H
1BH
13H
0BH
03H
1AH
12H
0AH
02H
19H
11H
09H
01H
18H
10H
08H
00H
Bank 3
18H
Bank 2
10H
Bank 1
08H
07H
06H
05H
04H
03H
02H
01H
00H
R7
R6
R5
R4
R3
R2
R1
R0
QUESTION 11
Figure 5-1 shows the content in some
location of the 8051 Internal Data
Memory.
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
24H
23H
22H
21H
20H
23-03-2008
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
Instruction
MOV A,#0F5H
ADD A,#16H
SUBB A,#2BH
OV
0
QUESTION 13
The content of some of the location of the
Internal Data Memory is shown below.
How are the contents affected when the
following program is executed:
7FH
7EH
23H
22H
21H
20H
1FH
17H
0FH
07H
1EH
16H
0EH
06H
1DH
15H
0DH
05H
1CH
14H
0CH
04H
19H
11H
09H
01H
Bank 2
10H
Bank 1
08H
Bank 0
00H
QUESTION 14
Identify the invalid instructions:
Instruction
MOV A,#56H
MOV #56H,76H
MOV A,@R0
ANL A,#45H
MOV A,R7
ORL @R1,45H
MOV @R1,25H
ADD A,@R7
SUBB A,45H
23-03-2008
1AH
12H
0AH
02H
Bank 3
18H
23H
F7H
22H
12H
21H
62H
20H
EAH
Internal Data Memory
1BH
13H
0BH
03H
Valid/Invalid
18H
10H
08H
00H
PSW
CY
0
AC
0
F0
0
RS1
1
RS0
1
OV
0
P
0
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
24H
23H
22H
21H
20H
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
19H
18H
2DH
20H
02H
01H
00H
12H
20H
2DH
Instruction
MOV A,#0E5H
ADD A,#0FH
SUBB A,#3BH
ORL A,#0FH
23-03-2008
OV
0
PSW
CY
0
AC
0
F0
0
RS1
0
RS0
0
OV
0
P
0
32H
31H
30H
2FH
2EH
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
17H
4FH
F5H
51H
16H
44H
12H
62H
52H
4FH
63H
23H
6FH
22H
19H
18H
2DH
20H
02H
01H
00H
Figure
12H
32H
25H
1-1
QUESTION 18
The content of some of the location of the
Internal Data Memory is shown below.
How are the contents affected when the
following program is executed:
7FH
7EH
MAIN: JB 0AH,K1
MOV 21H,#28H
K1:
SETB 07H
23H
22H
21H
20H
18H
23H
F7H
22H
12H
21H
62H
20H
0AH
Internal Data Memory
23-03-2008
10H
08H
00H
1FH
17H
0FH
07H
1EH
16H
0EH
06H
1DH
15H
0DH
05H
1CH
14H
0CH
04H
1BH
13H
0BH
03H
1AH
12H
0AH
02H
19H
11H
09H
01H
Bank 3
Bank 2
Bank 1
Bank 0
18H
10H
08H
00H
Instruction
MOV A,#033H
SUBB A,#0FFH
ANL A,#0FH
ORL A,#0AAH
OV
0
QUESTION 20
Figure 5-1 shows the content in some location of
the 8051 Internal Data Memory.
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
24H
23H
22H
21H
20H
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
Figure 5-1
QUESTION 21
Listing 7-1 shows a simple assembly
language program.
(a)
(b)
(c)
CSEG AT 00H
LJMP MAIN
CSEG AT 0100H
MAIN: MOV R0,#20H
MOV R7,#0AH
M1:
MOV A,@R0
ANL A,#0FH
MOV @R0,A
INC R0
DJNZ R7,M1
HANG:SJMP HANG
020100
7820
7F0A
E6
540F
F6
08
DFF9
80FE
Listing 7-1
23-03-2008
Instruction
MOV A,#55H
ADD A,#E6H
SUBB A,#7BH
SOLUTION 2
10H
0FH
0EH
0DH
0CH
0BH
0AH
09H
08H
07H
05H
04H
03H
02H
01H
00H
77H
54H
0BH
45H
9DH
17H
1AH
20H
10H
E4H
12H
23H
34H
F5H
34H
0FH
New Value
01H
02H
03H
04H
05H
0BH
SOLUTION 3
23-03-2008
(i)
(ii)
(iii)
(iv)
Instruction
MOV A,@R1
MOV R0,#45H
MOV A,R7
MOV 75H,50H
Addressing Mode
Register Indirect
Immediate
Register
Direct
(i)
(ii)
(iii)
(iv)
Instruction
SUBB A,#45H
MOV A,@R3
MOV R7,50H
MOV #45H,A
Valid or Invalid?
Valid
Invalid
Valid
Invalid
OV
0
0
0
Valid/Invalid
Invalid
Valid
Invalid
Invalid
Table 1
(b)
Destination Operand
Addressing Mode
Indirect
Direct
Register
Direct
Table 2
Instruction
MOV @R1,45H
XRL 45H,#75H
MOV R7,A
MOV 45H,@R0
SOLUTION 5
Instruction
MOV A, #F5H
ADD A,#F2H
CLR C
ADDC A,#24H
CY
0
1
0
1
AC
0
0
0
OV
0
0
0
Remark
Initial Value
-
SOLUTION 6
Instruction
MOV A,#56H
MOV 56H,76H
MOV A,@R0
ANL A,#45H
MOV A,R7
ORL A,45H
MOV @R1,25H
ADD A,@R1
SUBB A,45H
23-03-2008
Addressing Mode
Immediate
Direct
Register Indirect
Immediate
Register
Direct
Direct
Register Indirect
Direct
10
77H
54H
0BH
45H
9DH
17H
1AH
20H
10H
E4H
12H
23H
34H
F5H
34H
0FH
18H
19H
1AH
1BH
1CH
1DH
1EH
1FH
20H
SOLUTION 8
Instruction
MOV 56H,A
MOV 56H,76H
MOV @R0,A
ANL 45H,#35H
MOV R7,A
ORL 55H,A
MOV @R1,25H
MOV R7,#45H
MOV @R1,23H
Addressing Mode
Direct
Direct
Register Indirect
Direct
Register
Direct
Register Indirect
Register
Register Indirect
SOLUTION 9
Byte location 21H is affected. The new value of this location became 72H.
SOLUTION 10
(a)
(b)
(c)
(d)
128 Bytes
00H to 7FH
18H
SETB 04H
23-03-2008
11
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
13H
3FH
F5H
51H
F6H
44H
12H
62H
9EH
45H
64H
28H
AEH
25H
Instruction
MOV A,#0F5H
ADD A,#16H
SUBB A,#2BH
OV
0
0
0
SOLUTION 13
Explanation:
23H
22H
21H
20H
F7H
12H
62H
EAH FAH
23-03-2008
12
Valid/Invalid
Valid
Invalid
Valid
Valid
Valid
Invalid
Valid
Invalid
Valid
SOLUTION 15
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
24H
23H
22H
21H
20H
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
13H
3FH
F5H
51H
F6H
44H
12H
62H
9EH
45H
64H
28H
AEH
25H
19H
18H
2DH
20H
27H
26H
02H
01H
00H
12H
20H
2DH
12H
20H
2DH
23-03-2008
13
Instruction
MOV A,#0E5H
ADD A,#0FH
SUBB A,#3BH
ORL A,#0FH
OV
0
0
0
0
SOLUTION 17
32H
31H
30H
2FH
2EH
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
96H
65H
B4H
18H
BEH
39H
07H
00H
01H
00H
2DH
2AH
23-03-2008
14
23H
22H
21H
20H
F7H
12H
62H 28H
0AH 8AH
Instruction
MOV A,#033H
SUBB A,#0FFH
ANL A,#0FH
ORL A,#0AAH
OV
0
0
0
0
SOLUTION 20
2DH
2CH
2BH
2AH
29H
28H
27H
26H
25H
24H
23H
22H
21H
20H
13H
3FH
F5H
51H
F6H
44H
12H
62H
5AH
4FH
13H
33H
6FH
12H
06H
04H
02H
02H
0AH
0FH
03H
03H
0FH
02H
SOLUTION 21
(a)
The size of the program can be determined by counting the number of bytes of the
machine codes. The answer is 16 bytes.
(b)
The machine code for instruction INC R0 is 08H. It is stored in program memory
location 0108H.
(c)
23-03-2008
15