updated lab manual for coa (1)
updated lab manual for coa (1)
SVIT-VASAD
LAB MANUAL
No. SUBJECT
1 Write the working of 8085 simulator GNUsim8085 and basic architecture of 8085.
8085 is pronounced as "eighty-eighty-five" microprocessor. It is an 8-bit microprocessor designed
by Intel in 1977 using NMOS technology.
It has the following configuration −
LAB MANUAL
Stack pointer
It is also a 16-bit register works like stack, which is always incremented/decremented by 2 during
push & pop operations.
Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon the
result stored in the accumulator.
These are the set of 5 flip-flops −
Sign (S)
Zero (Z)
Auxiliary Carry (AC)
Parity (P)
Carry (C)
Its bit position is shown in the following table −
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
LAB MANUAL
Interrupt control
As the name suggests it controls the interrupts during a process. When a microprocessor is
executing a main program and whenever an interrupt occurs, the microprocessor shifts the control
from the main program to process the incoming request. After the request is completed, the
control goes back to the main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5, RST 5.5, TRAP.
Serial Input/output control
It controls the serial data communication by using these two instructions: SID (Serial input data)
and SOD (Serial output data).
Address buffer and address-data buffer
The content stored in the stack pointer and program counter is loaded into the address buffer and
address-data buffer to communicate with the CPU. The memory and I/O chips are connected to
these buses; the CPU can exchange the desired data with the memory and I/O chips.
Address bus and data bus
Data bus carries the data to be stored. It is bidirectional, whereas address bus carries the location
to where it should be stored and it is unidirectional. It is used to transfer the data & Address I/O
devices.
8085 Architecture
SARDAR VALLABHBHAI PATEL INSTITUTE OF TECHNOLOGY
SVIT-VASAD
LAB MANUAL
LAB MANUAL
2 1. Write the 8085 program to add two 8 bit numbers stored in registers.
2. Write the 8085 program to add two 16 bit numbers.
3. Write the 8085 program to subtract two 8 bit numbers stored in registers.
4. Write the 8085 program to subtract two 8 bit numbers without using SUB instruction.
Write the 8085 program to add two 8 bit numbers stored in registers.
MVI A,02H ; move 02H in A
MVI B,03H ; move 03H in B
ADD B ; A<-A+B
HLT ; halt
LAB MANUAL
Memory Value
Location
4000H 02
4001H 03
Output:
Memory Value
Location
4000H 02
4001H 03
4002H 05
Write the 8085 program to subtract two 8 bit numbers stored in registers.
MVI A,04H ; move 04H in A
MVI B,02H ; move 02H in B
SUB B ; A<-A-B
HLT ; halt
Input:
SARDAR VALLABHBHAI PATEL INSTITUTE OF TECHNOLOGY
SVIT-VASAD
LAB MANUAL
Memory Value
Location
2050H 03
2051H 02
Output:
Memory Value
Location
2052H 01
Write the 8085 program to subtract two 8 bit numbers without using SUB instruction.
MVI A,04H ; move 04H in A
CMA ; compliment value in A
ADI 01 ; add 1 in A
MOV B,A ; move value from A to B
MVI A,05H ; move 05H in A
ADD B ; A<-A+B
HLT ; halt
LAB MANUAL
Memory Value
Location
2050H 02
2051H 03
2052H 04
2053H 05
Output:
Memory Value
Location
2054H 08
2055H 06
Write an 8085 assembly language program to add two 16-bit numbers stored in memory.
LAB MANUAL
DAD D ; Add Content of Register H (05) with Content of Register D (03) as well
as Content of Register L (04) with Content of Register E (02) (including
carry if it’s generated) and result (08) into Register H and result (06)
into Register L
SHLD 2054h ; Store Content of Register H (08) at Memory Location 2054 and
Register L (06) at Memory Location 2055
HLT ; End of Program
Input:
Memory Value
Location
2050H 02
2051H 03
2052H 04
2053H 05
Output:
Memory Value
Location
2054H 08
2055H 06
LAB MANUAL
2.ANI
3. ORA
5.XRA
LAB MANUAL
6.XRI
LAB MANUAL
2. A.B = (A’+B’)’
4 1. Write the 8085 program to mask lower four bits of an 8 bit number stored in
A register
2. Write the 8085 program to set all upper four bits of an 8 bit number stored in
A register
Write the 8085 program to mask lower four bits of an 8 bit number stored in
A register
LDA 2050H ; load accumulator with value in 2050H
ANI 0F0H ; A<-A.0F0H
STA 2051H ; store value in 2051H from A
HLT ; halt
Write the 8085 program to set all upper four bits of an 8 bit number stored in
A register
LDA 2050H ; load accumulator with value in 2050H
ORI 0F0H ; A<-A+0F0H
STA 2051H ; store value in 2051H from A
HLT ; halt
LAB MANUAL
Input:
Memory Value
Location
2050H 14
Output:
Memory Value
Location
3050H 04
3051H 01
5 1. Write the 8085 program to add two 8 bit numbers stored in memory locations.
2. To perform XOR operation of two 8 bit nos. stored on memory location 2000H and 2001H.
3. Write the 8085 program to transfer block of data from one address to another.
4. Write the 8085 program to transfer block of data from one address to another In reverse order.
5. Write the 8085 program to add all the elements of the given array.
Write the 8085 program to add two 8 bit numbers stored in memory locations
MVI A, 02H ; Move 02h 8-bit data in Accumulator (A)
STA 4000H ; Store Content of Accumulator (02) at Memory Location 2050
MVI A, 03H ; Move 03h 8-bit data in Accumulator (A)
STA 4001H ; Store Content of Accumulator (03) at Memory Location 2051
LDA 4000H ; Load Data (03) from Memory Location 2050 into A
MOV B, A ; Move Content of Accumulator (03) into Register B
LDA 4001h ; Load Data (02) from Memory Location 2051 into A
ADD B ; Add Content of Register B (03) & Content of A (02)
STA 4002h ; Store Content of Accumulator (05) at Memory Location 2052
HLT ; End of Program
SARDAR VALLABHBHAI PATEL INSTITUTE OF TECHNOLOGY
SVIT-VASAD
LAB MANUAL
Input:
Output:
To perform XOR operation of two 8 bit nos. stored on memory location 2000H and 2001H.
MVI A, 02H ; Move 02h 8-bit data in Accumulator (A)
STA 2000H ; Store Content of Accumulator (02) at Memory Location 2050
MVI A, 03H ; Move 03h 8-bit data in Accumulator (A)
STA 2001H ; Store Content of Accumulator (03) at Memory Location 2051
LDA 4000H ; Load Data (03) from Memory Location 2050 into A
MOV B, A ; Move Content of Accumulator (03) into Register B
LDA 2001h ; Load Data (02) from Memory Location 2051 into A
XRA B ; Add Content of Register B (03) & Content of A (02)
STA 2002h ; Store Content of Accumulator (05) at Memory Location 2052
HLT ; End of Program
Input:
Output:
LAB MANUAL
Write the 8085 program to transfer block of data from one address to another.
LXI H, 2000H ; Store the source address in H
LXI D, 4000H ; Store the destination address in D
MVI B, 05H ; Set the counter value to 5
NEXT:MOV A, M ; Move the value from memory to A
STAX D ; Store the value at destination
INX H ; Increment H
INX D ; Increment D
DCR B ; Decrement B
JNZ NEXT ; Jump to NEXT if not zero
HLT ; End of program
Input:
Output:
LAB MANUAL
Write the 8085 program to transfer block of data from one address to another In reverse
order
LXI H, 2000H ; Load starting address in H
LXI D, 4000H ; Load destination address in D
MVI B, 05H ; Initialize the value of counter
NEXT: MOV A, M ; Move the value from Memory to A
STAX D ; Store at the destination
DCX H ; Decrement H by 1
INX D ; Increment D by 1
DCR B ; Decrement B by 1
JNZ NEXT ; Jump to label NEXT if not zero
HLT ; End of program
Input:
Output:
LAB MANUAL
Write the 8085 program to add all the elements of the given array
XRA A ; Clean A to save sum
MOV B, A ; Clean B to save carry
MVI C, 05H ; Counter
LXI H, 0005H ; Load H with 0005H
NXTBYT: ADD M ; Add
JNC NXTMEM ; If no carry do not increment carry register
INR B ; Increment B by 1
NXTMEM: INX H ; Increment H by 1
DCR C ; Decrement C by 1
JNZ NXTBYT ; Jump if not zero
STA 0002H ; Store in 0002H
MOV A, B ; Move value from B to A
STA 0001H ; Store in 0001H
HLT ; End
LXI H, 000AH ; Store 000AH in H register
MOV A, M ; Store the value from A in memory
INX H ; Increment H by 1
MOV A, B ; Store the value from B in memory
HLT ; End of Program
Input:
Output:
LAB MANUAL
7 1. Write 8085 program to shift given 8- bit no. using shift instruction and subroutine.
2. Write 8085 program to find the factorial of the number using subroutine.
Write 8085 program to shift given 8- bit no. using shift instruction and subroutine
MVI A,04H ; move 04H in register A
CALL Shift ; call subroutine
HLT ; halt
LAB MANUAL
LAB MANUAL
LAB MANUAL
LAB MANUAL
The R-type instructions include add, sub, and, or, and slt.R-type instructions must access registers
and an ALU
Executing an R-type instruction
1. Read an instruction from the instruction memory
2. The source registers, specified by instruction fields rs and rt, should be read from the register file
3. The ALU performs the desired operation
4. Its result is stored in the destination register, which is specified by field rd of the instruction
word
The lw, sw and beq instructions are all I-type encoding
The steps in executing al- type
1. Fetch the instruction, like beq
2. Read the source registers
3. Compare the values by subtracting them in the ALU , if needed
Instruction fetching :-
The CPU is always in an infinite loop, fetching instructions from memory and executing them The
program counter or PC register holds the address of the current instruction
MIPS Applications:
MIPS processors are used in embedded systems such as residential gateways and routers.
Originally, MIPS was designed for general-purpose computing.
MIPS advantages:
All opcodes are single micro-operations that can be more easily pipelined
All opcodes are 4 bytes which simplifies the instruction decoder a lot
Probably doesn’t need a micro-op cache (x86 cores have this)