16-bits addition: Add the 16-bit number in memory locations 4000H and
4001H tto th
the 16
16-bit
bit number
b iin memory llocations
ti 4002H and
d 4003H
4003H. Th
The
most significant eight bits of the two numbers to be added are in memory
locations 4001H and 4003H. Store the result in memory locations 4004H
and 4005H with the most significant byte in memory location 4005H
LHLD 4000H ; "Get first 16-bit number in HL"
XCHG ; "Save
Save first 16
16-bit
bit number in DE"
DE
LHLD 4002H ; "Get second I6-bit number in HL"
MOV A, E ; "Get lower byte of the first number"
ADD L ; "Add lower byte
y of the second number"
MOV L, A ; "Store result in L register"
MOV A, D ; "Get higher byte of the first number"
ADC H ; "Add higher byte of the second number with CARRY"
MOV H, A ; "Store result in H register"
SHLD 4004H ; "Store I6-bit result in memory locations 4004H and 4005H"
HLT ; "Terminate program execution”
Add two 16-bit numbers: Add the 16-bit number in memory locations
4000H and 4001H to the 16-bit number in memory locations 4002H and
4003H.
003 The e most
ost ssignificant
g ca t e eight
g tbbits
ts o
of tthe
e ttwo
o numbers
u be s to be added a
are
e in
memory locations 4001H and 4003H. Store the result in memory locations
4004H and 4005H with the most significant byte in memory location 4005H
---------or another program to do the same
LHLD 4000H ; Get first I6‐bit number
XCHG ; Save first I6‐bit
XCHG ; Save first I6 bit number in DE
number in DE
LHLD 4002H ; Get second I6‐bit number in HL
DAD D ; Add DE and HL
SHLD 4004H ; Store I6‐bit result in memory locations 4004H and 4005H.
; y
HLT ; Terminate program execution
10 ms delay subroutine:
Write an assembly subroutine/ sub-program to create a delay using BC register pair.
Also, clear the Z flag without affecting any other flags, and return to the main program.
DELAY: PUSH B ; Save BC and HL in to the Top Of Stack (TOS) in a RAM
PUSH H
LXI B, COUNT ; Load the ‘delay count’ (16 bits value) for a 10 ms delay
LOOP: DCX B
MOV A,C
AC
ORA B ; Set Z flag if B and C =0
JNZ LOOP ; Jump in a loop if not zero
PUSH PSW ; Save flag status on to the TOS
POP H ; Copyy flags
g in to L ((and A to H)) from TOS
MOV A,L
ANI 0xBF ; AND immediate with D6 (zero flag)=0
MOV L,A
PUSH H ; Save flag status with Z flag reset at TOS
POP PSW ; Bring values from TOS to flags and A from TOS
POP H ;
POP B
RET ; Return to the calling program
Calculation of the
Calculation of the ‘delay
delay count
count’ if the clock frequency is 4 MHz:
if the clock frequency is 4 MHz:
T‐state: 1/4x106 = 250 ns
LXI B, COUNT 10x T-states
LOOP: DCX B 06x T-states
MOV A,C
AC 04x T-states
ORA B 04x T-states
JNZ LOOP 07x (condition is not true) or 10x (condition is true) T-states
Delay time = 10 ms = [10+(6+4+4+10)(COUNT‐1)}+7]x 250ns
Arrange first 10 numbers from memory address 3000H in an
ascending order:
START: MVI B, 09 ;"Initialize counter
LXI H, 3000H ; Initialize memory pointer
MVI C, 09H ;;"Initialize
Initialize counter 22"
BACK: MOV A, M ;"Get the number"
INX H ;"Increment memory pointer"
CMP M ;"Compare number with next number"
JC SKIP ;"If less, don’t interchange"
JZ SKIP ;"If equal, don’t interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H ;"Interchange two numbers"
SKIP: DCR C ;"Decrement counter 2"
JNZ BACK ;"If not zero, repeat"
DCR B ;;"Decrement
Decrement counter 1 1"
JNZ START
HLT ;"Terminate program execution"
Programmable Peripheral
Interface (82C55)
About 82C55
• The 82C55 is a p popular
p interfacing
g component,
p , that
can interface any TTL-compatible I/O device to a
microprocessor.
• It is used to interface to the keyboard and a parallel
printer port in PCs (usually as part of an integrated
chipset).
• Requires insertion of wait states if used with a
microprocessor using higher that an 8 MHz clock.
• PPI has 24 pins for I/O that are programmable in
groups of 12 pins and has three distinct modes of
operation.
82C55 : Internal Block Diagram
82C55 : Pins
8085 Miccroco omputer
Arrchite
ecturre ussing 8
82C5
55
PB7
PB0
PB0‐
82C55: 7-segment display interface
C
Common Anode Displays
A d Di l
Common Anode Display
(Pin configuration)
82C55: 16-keys interface
.