星期四, 1月 08, 2009

EE3120 (B) MP & ASSEMBLY LANGUAGE PROG (02EE3120) Quiz 2 Solution

Quiz 2 (total 60 marks)

1. Compile and state the contents of each ROM location for the following data.
ORG 100H
MYDAT_1: DB "EE3210"
MYDAT_2: DB "Spring"
MYDAT_3: DB "12-2-10"
[10 marks]

Ans:
0100 1 ORG 100H [1 mark]
0100 45453332 2 MYDATA__1: DB "EE3210" [3 marks]
0104 3130
0106 53707269 3 MYDATA 2: DB "Spring" [3 marks]
010A 6E67
010C 31322D32 4 MYDATA_3: DB "12-2-10" [3 marks]
0110 2D3130


2. In the 8051, which register bank conflicts with the stack? What is the size of the stack pointer (SP) register?
[10 marks]
Ans: Register bank 08 conflicts with the stack. [5 marks]

SP size is 8 bits. [5 marks]


3. Explain what is the difference between these two instructions.
(a) MOV A0H,#10H (b) MOV @R0 , #10H ;if R0=A0H
[10 marks]

Ans:
(a) Puts 10h in the address A0h of the SFRs (which is P2) [5 marks]
(b) Write 10h into the address A0h which is referred as memory [5 marks]

4. Assuming the use of bank 1, find at what RAM location each of the following lines stored the data.
(a) MOV R4,#16H (b) MOV R1,#20H (c)MOV R3,#24H (d) MOV R7,#12H
[12 marks]
Ans:
Bank 1 location from 08-0F; i.e. R0 locates at 08 and R7 locates at 0F

(a) MOV R4,#16H will write to RAM location 0C
(b) MOV R1,#20H will write to RAM location 09
(c) will write to RAM location 0B
(d) will write to RAM location 0F [3 each total 12 marks]

5. Find the contents of register A after each of the following instructions,
MOV A,#60H
ANL A,#36H
[8 marks]
Ans:
MOV A,#60H Accumulator A stores 60H [4 marks]
ANL A,#36H Value A will operate an “ANL” with 36, ie 0110 0000 (60) and 0011 0110 (36) = 0010 0000 and get 20. [4 marks]


Write a program to get 8-bit data from P0 and send it to ports P1 and P2.
[10 marks]
Ans:

ORG 0000h [1 marks]
MOV A, #0FFH[2 marks]
MOV P0, A[2 marks]
MOV A, P0[1 marks]
MOV P1, A[1 marks]
MOV P2, A[1 marks]
HERE: SJMP HERE[1 marks]
END[1 marks]