You are on page 1of 3

EE 390 Home Work 1 Solution

Question 1:

State the size of the following 8051 registers: (a) r0 – r7, (b) ACC, (c) B, (d) Data pointer (e)
Program counter, and (f) PSW

Solution: (a) r0 – r7 is 8 bit each. (b) ACC = 8- bit. (c) B = 8-bit (d) Data pointer = 16 bit (e)
program counter = 16- bit, and (f) PSW = 8-bit.

Question 2:

Which of the following is (are) illegal?

(a) add a, r5
(b) add a, #0f5h
(c) add r2, r4 - illegal
(d) add a , #60h
(e) add 60h , #90 - illegal
(f) add 0e0h , #55h
(g) mov r3 , #500

Question 3:

Find the CY flag value after each of the following codes.

(a) mov a , #54h

add a , #0c4h CY = 1

(b) mov a , #00

add a , #0ffh CY = 0

(c) mov a , #250

add a , #06 CY = 1

Question 4:

Write a simple PROGRAM in which the value 55h is added 5 times and find the content of the
CY flag after the last addition operation.

mov a , #0
mov r2 , #5
mov r5 , #0
again: add a , #55h
jnc h_b
inc r5
clr c
h_b: djnz r2 , again
end
After the last addition CY = 0

Question 5:

Show the stack and stack pointer for each line of the following program

org 0000h
mov sp , #60h
mov r5 , #66h
mov r2 , #7fh
mov r7 , #5dh
push 5
push 2
push 7
clr a
mov r2 , a
mov r7 , a
pop 7
pop 2
pop 5
end

Solution:

61h
60h
SP = 60h

62h
61h 66h
60h
After first push, SP = 61h

63h
62h 7fh
61h 66h
60h
After second push, SP = 62h

63h 5dh
62h 7fh
61h 66h
60h
After third push, SP = 63h

63h
62h 7fh
61h 66h
60h
After POP 7, SP = 62h

63h
62h
61h 66h
60h
After pop 2, SP = 61h

63h
62h
61h
60h
After pop 5, SP = 60h

You might also like