You are on page 1of 14

MICROPROCESSORS

EXPERIMENT NO. 2

Programming with Time Delay using


LEDs

Leader:
Member/s:

Course/Section: CPE108L/E01

Group No.: 3

Date of Performance: December 3, 2020


Date of Submission: December 5, 2020

Prof. Cyrel O. Manlises


Professor
PART ONE: TIME DELAY
Q1. Was there an error when you assembled (Assm) the
program? If yes, what do you think is the reason why?

Yes, there was an error when I changed the code

to MOV A, FFFFH and MOV B, FFH. The error said,

unknown label. I think the reason of the error was

because the code does not follow the proper

code that will add 0 after the # sign and

additionally, the code FFFFH and FFH are

characters and not as a hexadecimal.


Q2. What is the new code?

ORG 0000H

MAIN:

CLR A

MOV A, #34H

MOV B, #36H

MOV R0, #03H

AGAIN: DEC A

DJNZ B, AGAIN

ADD A, B

COUNT: DJNZ R0, COUNT

ADD A, B

MOV P1, A

END
Q3. Illustrate the final output in LEDs.
Q4. To make the output faster, what line of the new program
should be changed?

The line that should be changed is the MOV RO

so that the output will be faster. R0 is equal to 0

means no more delay for led outputs.

Q5. What instruction should be added in the new program to


display the correct output in the LEDs?
The instruction that should be added in the new

program for the correct display output of LEDS is

add CPL A to complement the contents of the

Accumulator. CPL instruction complements the

value of the particular destination and then result

back in the destination operand. Every bit that

contained a 1 will automatically change to a 0

and bits that contained a 0 will automatically

change to a 1.
PART TWO: I/O PORT INTERFACE WITH TIME DELAY

Q1. What is final output of the program?

The final output of the program is that the LEDs

were changing in positions and colors while in the

SEVEN-SEGMENT DISPLAY, it wasn’t stable. Also

the pins and bits kept on changing. But after how

many seconds and instructions, the SEVEN-

SEGMENT DISPLAY became stable while the LEDs

were the last to became stable.


Start of the output. (RL)
End of the output. (RL)

Q2. Illustrate how instructions RL and RR were executed using


the content of the Accumulator register (the rotated data in
binary numbers).
When I changed the RL to RR using the content

of the Accumulator register, the displayed final

output was like the final output from RL. The

SEVEN-SEGMENT DISPLAY became stable while

the LEDs also all lit up.

Start of the output. (RR)

End of the output. (RR)


Q3. Change the value of R0 to a lower hexadecimal value,
save, assemble and run the program. What is the effect of
changing the value of R0 to the output of the program?

Changing the value of R0 to a lower hexadecimal

value run the program faster. I changed the code

MOV RO,#0FH to MOV RO, #1H. Therefore, the

lower the value of RO, the faster the output of

the program will start.


Q4. What is the importance of the instruction RET in
assembly language?

The importance of RET in assembly language is

that it will instruct the high-order and low-order

bytes of the PC from the stack. Moreover, without

RET the LEDs will not light and as well as the

SEVEN-SEGMENT DISPLAY. The program will just

run without RET but the LEDS and SEVEN-


SEGMENT DISPLAY will not light up. Also, RET will

ends the function and returns to the main

program. The instruction RET will be the one that

will run the program effectively and completely,

Without RET
Q5. What is the correct flowchart of the program encoded in
part II, #2? Use the space provided below.

START

INITIALIZING ADDRESS
ORG 0000H

CLEAR ACCUMULATOR
A

CALL DELAY

NO

IS
REGISTER 0
EQUAL TO
0
YES

STORE SWITCH
INPUT TO
ACCUMULATOR

COMPLEMENT THE
CONTENT REGISTER

DISPLAY ACCUMULATOR
REGISTER’S CONTENT TO
PORT 1

ROTATE
REGISTER
ACCUMULATOR

STOP

You might also like