LAB 3 Introduction To Assembly Programming1
LAB 3 Introduction To Assembly Programming1
INTRODUCTION TO
ASSEMBLY
PROGRAMMING
OBJECTIVE
To develop basic concepts of assembly programming
END }
TO ACCESS GENERAL PURPOSE REGISTERS (R0-R7)
ORG 0
END
TO WRITE (OUTPUT) DATA ON I/O PORTS (P0-
P3)
ORG 0
END
TO READ (INPUT) DATA FROM I/O PORTS (P0-
P3)
ORG 0
MOV R0, P1 ; R0 = P1
MOV R1, P3 ; R1 = P3
MOV P2, P0 ; P2 = P0
END
TO ACCESS INDIVIDUAL BITS OF I/O PORTS
(P0-P3)
ORG 0
END
HOW TO CHANGE REGISTER BANK
We have 2 bits in PSW register RS0 and RS1. To
select any register bank we have following four
combinations
ORG 0
; By default bank 0 is active
SETB RS0
CLR RS1 ; Register bank 1 is active now
CLR RS0
SETB RS1 ; Register bank 2 is active now
SETB RS0
SETB RS1 ; Register bank 3 is active now
END
ADDITION
ADD A, <scr-byte> ; Add scr-byte to ‘A’ and
; saves result in ‘A’
ORG 0
END
EXERCISE I
a. Write a program which read port 1 and 2, add them
and then show the result on port 0.
b. Design proteus simulation for the above program
and test your program on it.
EXERCISE II
a. Write a program which read values from port1,
port2 and port3. Then saves value of port1 in R0-
bank 0, value of port2 in R1-bank 1 and value of
port3 in R2-bank 2
b. Now add above values and display result on port 0.
c. Design a proteus simulation for the above program.