You are on page 1of 5

University of Southern Mindanao

Kabacan, Cotabato
College of Engineering and Information Technology

LABORATORY ACTIVITY NO. 1

CpE 511 - Microprocessor System

Submitted by:

Alfie T. Morales
Freylen Melkha P. Modina
Mark Jayson Garciano
5-BSCpE-A

Submitted to:

Jeannalen P. Lunod, ME-Cpe


Instructor

Undated:
PROBLEM:

Make a program that will perform the following:

1. Load 0x70 to register named reg_1 the moment bit 0 of porta is 1.


2. Load 0x3A to working register the moment bit 1 of porta is 1.
3. The sum of reg_1 and w will be computed and the result will be displayed
to portb the moment bit 2 of porta is 1.
4. The value in portb is continuously shifted to:
a. the right, the moment bit 3 of porta is 1. The output remains on
shifting to the right until power is taken out of the circuit.
b. the left, the moment bit 4 of porta is 1. The output remains on
shifting to the left until power is taken out of the circuit.
SYSTEM FLOW: Start

Teach porta

Teach portb

Clear portb

No
Porta, bit
0=1?

Yes

Load reg_1
w/ 0x70

No Porta, bit
1=1?

Yes
Load w_reg
w/ 0x3A

No Porta, bit
2=1?

Yes

Add reg_1
and w_reg

No Porta, bit
3=1?

Yes
No
Porta, bit 4=1?
Rotate right
portb
Yes

Rotate left Call delay


portb

Call delay
SOURCE CODE:

porta equ 0x05


portb equ 0x06
reg_1 equ 0x0C
w_reg equ 0x0D
ncount equ 0x0E
mcount equ 0x0F
org 0x00
start movlw 0xff
tris porta
movlw 0x00
tris portb
clrf portb
first btfss porta,0
goto first
movlw 0x70
movwf reg_1
second btfss porta,1
goto second
movlw 0x3A
movwf w_reg
third btfss porta,2
goto third
addwf reg_1,w
movwf portb
fourth btfss porta,3
goto fifth
rr rrf portb,f
call delay
goto rr
fifth btfss porta,4
goto fourth
rl rlf portb,w
call delay
goto rl
delay movlw 0xff
movwf mcount
loadn movlw0xff
movwf ncount
decn decfszncount,f
goto decn
decfszmcount,f
goto loadn
return
end

You might also like