Lecture 2
Lecture 2
• ALU
– Performs arithmetic logic operations
– Includes accumulator (A) , temporary register and
flags(flipflop).
• Accumulator
– 8- bit register
– 8085 is accumulator based microprocessor.
– When data is read from input port, it first moved to
accumulator and when data is sent to output port, it
must be first placed in accumulator.
Internal Architecture of 8085
• Flags
•
• 8085 Bus
• Address Bus-
– It has 16 signal lines.
– these lines are split into two segments A15-A8 and
AD7- AD0
– The eight signals A15-A8 are unidirectional and
used as high order bus.
8085 Bus (continue..)
• Data Bus
– It has 8 signal lines
– AD0-AD7
– They are bidirectional
– They also serve the purpose of low order address
bus.
8085 Bus (continue..)
• Control and Status signals:
• ALE ( Address Latch Enable)-
– This signal is used primarily to latch the low-order address from the
multiplexed bus and generate a separate set of eight address lines A7 –A0
.
• RD (active low)
• WR( active low)
• IO/M-
– indicates if its an IO operation or memory operation.
• S1 and S0 –
– Status signals
Characteristics features of 8085(continue..)
• Externally initiated signals
• INTR – interrupt request
• INTA- interrupt acknowledge
• RST 7.5, RST6.5, RST 5.5 – vectored interrupt
• TRAP – NMI interrupt
• HOLD – DMA request for bus access
• HLDA- HOLD acknowledge
• READY ( input)- delay read or write cycle to match the speed with slow
peripherals.
• RESET IN – Reset MPU, PC sets to 0
• RESET out- MPU is being reset. Can be used to reset other devices
• SID and SOD – used for serial data transmission
Instruction Cycle
Instruction Format and Description
• Each instruction has two fields
• Op-code field
• Operand field
– It may include 8-bit (or 16-bit) data, an internal
register, a memory location, or an 8-bit (or 16-bit)
address.
Instruction Format
• Depending upon number of address specified, there are 3
types of instruction.
• One address format-
– It has 1 byte opcode and the operand is default. Eg; MOV A,B ,
ADD B
• Two address format-
– It has one byte opcode and 1 byte operand.
– Eg; MVI A, 80H , OUT 20H
• Three address format-
– It has one byte opcode and 2 bytes operand.
– Eg; LXI B, 2050H , LDA 4560H
Instruction format ( continue..)
Classification of instructions
• STAX RP [RP] A
• – Store s the contents of accumulator to memory location
specified by the contents of register pair. 1 byte instruction
• E. g. STAX B
• LXI B, 9500H Output
• LXI D, 9501H
[9500]=32H
• MVI A, 32H
• STAX B
[9501]=7AH
• MVI A, 7AH
• STAX D
Practice
• The memory location 2050H holds the data byte F7H.
Write instructions to transfer the data byte to
accumulator using different op-codes: LXI,MOV, LDAX
and LDA.
• ORA R/M
• – Logically OR the contents of
register/memory with the contents of
accumulator.
• – 1 byte instruction.
ORI 8 bit data
• – Logically OR 8 bit immediate data with the
contents of the accumulator.
• – 2 byte instruction.
•
XRA R/M
• – Logically exclusive OR the contents of
register memory with the contents of
accumulator.
• – 1 byte instruction.
• – CY and AC is reset and other as per result.
XRI 8 bit data
• – Logically Exclusive OR 8 bit data immediate
with the content of accumulator.
• – 2 byte instruction.
• – CY and AC is reset and other as per result.
CMA (Complement accumulator)
• – 1 byte instruction.
• – Complements the contents of the
accumulator.
• CMP R/M (1 byte instruction) CPI 8 bit data
( 2 byte instruction)
• – Compare the contents of register/ memory
and 8 bit data with the contents of
accumulator.
• – Status is shown by flags & all flags are
modified.
CMP instruction
Write a program to find 1’s and 2’s complement of 8-
bit number stored at 3000 memory address and store
result into 3001 and 3002 memory address.
Write a program to find 1’s and 2’s complement of 16-
bit number stored at 3000 memory address and store
result into 3002 and 3004 memory address.
Logical Rotate instructions
Branching instructions
• The branching instructions instruct the microprocessor to go
to a different memory location and the microprocessor
continues executing machine codes from that new location.
• The branching instructions are the most powerful instructions
because they allow the microprocessor to change the
sequence of a program, either unconditionally or under
certain test conditions
• Jump instructions
• Call and return instruction
• Restart instruction
Jump Instruction
• They are 3 byte instructions, one byte for the
operation code followed by a 16 bit (2 byte)
memory address.
• Unconditional jump:
• JMP 16-bit address
• Eg: JMP 4000H
• The jump location can also be specified using
a label or name.
Example
Conditional Jump
Write an assembly language program to count
the number of ones in contents of register B and
store the result at memory location 3050.
• Example:
• If register B contains 75H , then 3050H
memory location must contain 5.
Solution
Write an assembly language program in 8085 microprocessor to
check whether the 8 bit number which is stored at memory
location 2050 is even or odd. If even, store 22 at memory
location 3050 otherwise store 11 at memory location 3050.
WAP to move 10 bytes of data from starting
address 9500 H to 9600H
Solution
• MVI B, 0AH
• LXI H, 9500H
• LXI D, 9600H
• L1:MOV A, M
• STAX D
• INX H
• INX D
• DCR B
• JNZ L1
• HLT
Write to transfer 30 data starting from 8500 to
9500H if data is odd else store 00H.
Call and return instructions: (Subroutine)
• Subroutine
• A subroutine is a group of instructions that
perform a subtask. A subroutine is written as a
separate unit apart from the main program
and the microprocessor transfers the program
execution sequence from main program to
subroutine whenever it is called to perform a
task. After the completion of subroutine task
microprocessor returns to main program.
CALL and RET
Size of list is stored at 2040H and list of numbers from 2041H onwards.