COA Lab Manual
COA Lab Manual
Name:
Enrollment number:
Batch:
Year:
GNUSim8085 is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor
in Linux and Windows. It contains a simple editor component with syntax highlighting. Also it has
a keypad to input assembly language instructions with appropriate arguments.
• Printing support.
The 8085 microprocessor was made by Intel in mid 1970s. It was binary compatible with 8080
microprocessor but required less supporting hardware thus leading to less expensive microprocessor
systems.
It is a general purpose microprocessor capable of addressing 64k of memory. The device has 40
pins, require a +5V power supply and can operate with 3 MHz single phase clock.
It has also a separate address space for up to 256 I/O ports. The instruction set is backward
compatible with its predecessor 8080 even though they are not pin-compatible.
The 8085 has a 16 bit address bus which enables it to address 64 KB of memory, a data bus 8 bit
wide and control buses that carry essential signals for various operations. It also has a built in
register array which are usually labelled A(Accumulator), B, C, D, E, H, and L. Further special-
purpose registers are the 16-bit Program Counter (PC), Stack Pointer (SP), and 8-bit flag register F.
The microprocessor has three maskable interrupts (RST 7.5, RST 6.5 and RST 5.5), one Non-
Maskable interrupt (TRAP), and one externally serviced interrupt (INTR). The RST n.5 interrupts
refer to actual pins on the processor a feature which permitted simple systems to avoid the cost of a
separate interrupt controller chip.
Control Unit
Generates signals within microprocessor to carry out the instruction, which has been decoded. In
reality causes certain connections between blocks of the processor be opened or closed, so that data
goes where it is required, and so that ALU operations occur.
The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’, ‘AND’, ‘OR’,
etc. Uses data from memory and from Accumulator to perform arithmetic and always stores the
result of operation in the Accumulator.
Registers
The 8085 microprocessor includes six registers, one accumulator, and one flag register, as shown in
Fig 1. In addition, it has two 16-bit registers: the stack pointer and the program counter. The 8085
has six general-purpose registers to store 8-bit data; these are identified as B, C, D, E, H, and L as
shown in Fig 1. They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit
operations. The programmer can use these registers to store or copy data into the registers by using
data copy instructions.
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register is
used to store 8-bit data and to perform arithmetic and logical operations. The result of an operation
is stored in the accumulator. The accumulator is also identified as register A.
Flag Registers
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero(Z), Carry (CY),
Sign (S), Parity (P), and Auxiliary Carry (AC) flags. The most commonly used flags are Zero,
Carry, and Sign. The microprocessor uses these flags to test data conditions.
Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This register is a memory
pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit register. The
microprocessor uses this register to sequence the execution of the instructions. The function of the
program counter is to point to the memory address from which the next byte is to be fetched. When
a byte (machine code) is being fetched, the program counter is incremented by one to point to the
next memory location.
The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory location
in R/W memory, called the stack. The beginning of the stack is defined by loading 16-bit address in
the stack pointer.
This is a temporary store for the current instruction of a program. Latest instruction is sent to here
from memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction is then passed to next stage.
Holds addresses received from PC for eg: of next program instruction. MAR feeds the address bus
with address of the location of the program under execution.
Control Generator
Generates signals within microprocessor to carry out the instruction which has been decoded. In
reality it causes certain connections between blocks of the processor to be opened or closed, so that
data goes where it is required, and so that ALU operations occur.
Register Selector
This block controls the use of the register stack. Just a logic circuit which switches between
different registers in the set will receive instructions from Control Unit.
All these operations are part of the communication processes between microprocessor and peripheral
devices. The 8085 performs these operations using three sets of communication lines called buses -
the address bus, the data bus and the control bus.
Address Bus
The address bus is a group of 16 lines. The address bus is unidirectional: bits flow only in one
direction – from the 8085 to the peripheral devices. The microprocessor uses the address bus to
perform the first function: identifying a peripheral or memory location. Each peripheral or memory
location is identified by a 16 bit address. The 8085 with its 16 lines is capable of addressing 64 K
memory locations.
Data Bus
The data bus is a group of eight lines used for dataflow. They are bidirectional: data flows in both
direction between the 8085 and memory and peripheral devices. The 8 lines enable the
microprocessor to manipulate 8-bit data ranging from 00 to FF.
Control Bus
The control bus consists of various single lines that carry synchronization signals. These are not
groups of lines like address of data bus but individual lines that provide a pulse to indicate an
operation. The 8085 generates specific control signal for each operation it performs. These signals
are used to identify a device type which the processor intends to communicate
PRACTICAL: 2
Aim : Write an assembly language programming for addition of two 8bit unsigned nos.
a)With carry provision b) Without carry provision
Q1. How many different instructions Microprocessor 8085 have? What is an instruction set?
Ans. 8085 microprocessor has a total of 74 different instructions for performing different operations or tasks.
The entirely different instructions that a particular microprocessor can handle is called its instruction set.
As an example, for gadget controls and traffic signals, assembly language programming is done because
programs in such cases are compact and not lengthy.
But for cases where large program lengths are a must, compilers/interpreters are used. For such a case, although
a large memory space is required, the advantage lies in very quick debugging.
Write an assembly language programming for addition of two 16bit unsigned nos.
Input:
7000 2A,00,71 LHLD 7100H ; Load first (lower 8 bit at 7100, Higher 8 bit at 7101) in H-L pair
7003 EB XCHG ; Shift to D-E pair
7004 2A,02,71 LHLD 7102H ; Load second (lower 8 bit at 7102, Higher 8 bit at 7103) in H-L pair
7007 19 DAD D ; add both no.
7008 22,04,71 SHLD 7104H ; Save the result (lower 8 bit at 7104, Higher 8 bit at 7105) in H-L pair
700B 76 HLT ; Stop the program.
Output:
PRACTICAL: 5
Write an assembly language programming for subtraction of two 16bit unsigned nos.
Input :
Output :
PRACTICAL: 6
Write an assembly language programming for multiplication of two 8bit unsigned nos.
Input :
Output:
PRACTICAL: 7
Input :
Output :
PRACTICAL: 8
Write an assembly language programming for a)smallest b)Largest no within an array
of 5nos.
2014 HLT
Q3. What type of memory is the stack? How the stack is initialized? Ans. Stack is a ‘last-in first-out’ or
LIFO type of memory. This means that data which is pushed last into stack is popped out of it first.
The stack is initialized by means of the stack pointer. The software instruction is like this: LXI SP,
0044.It means that the stack is initiated at the memory location 4400 by the stack pointer.
Write an assembly language programming for arranging a string of two 5bit nos.in
a) Descending order b) Ascending order.
800B D2, 14, JNC If (A) >= second byte, do not exchange
80 NEXTBYT
Input :
2012 HLT
Input :
Output :
PRACTICAL: 12
Flow Chart :
Numerical Example :
PRACTICAL: 13
Arithmetic Instructions are the instructions which perform basic arithmetic operations
such as addition, subtraction and a few more. In 8085 microprocessor, the
destination operand is generally the accumulator.
Input:
JNZ
2105H MULTIPLYLOOP Repeated addition
Explanation –
1. First set register B with data.
2. Set register D with data by calling MULTIPLY subroutine one time.
3. Decrement B and add D to itself B times by calling MULTIPLY subroutine
as 4*3 is equivalent to 4+4+4 (i.e., 3 times).
4. Repeat the above step till B reaches 0 and then exit the program.
5. The result is obtained in D register which is stored in memory
PRACTICAL: 15
LogiSim is a LOGic SIMulator. When learning computer architecture and logic circuits, one needs a
real-world, graphical example of what you are studying. Text and diagrams only go so far. A helpful
tool for designing and simulating logic circuits is Logisim.
The explorer pane contains all of the elements needed to create circuits. For example, gates, plexers
etc. In order to add an element from the explorer pane, you select the item in the pane. Next, you click
on the canvas to drop the element onto your design. Now to add an element from the explorer pane,
you need to select any item in the pane. Next, you click on the canvas to drop the element onto your
design. Suppose, we choose and drop an AND gate onto the canvas. Explorer pane>>gates>>AND
gate The attributes pane will get activated i.e. will have some options. The figure here shows the AND
gate into canvas and also attribute along with options.
We can change the direction the gate faces (east, west, north, south), or the number of data bits (the
default is 1). As you build circuits, you will be changing the attributes of your elements here. Changing
Values in Circuits In the toolbar, you'll notice a little hand icon (shown in Figure). This icon is used to
change values in circuits. This is how you test your circuits.
Code :
<?xml
version="1.0"
encoding="UTF-8"
standalone="no"?>
<project source="2.7.1" version="1.0">
This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/).
<lib desc="#Wiring" name="0"/>
<lib desc="#Gates" name="1"/>
<lib desc="#Plexers" name="2"/>
<lib desc="#Arithmetic" name="3"/>
<lib desc="#Memory" name="4"/>
<lib desc="#I/O" name="5"/>
<lib desc="#Base" name="6">
<tool name="Text Tool">
<a name="text" val=""/>
<a name="font" val="SansSerif plain 12"/>
<a name="halign" val="center"/>
<a name="valign" val="base"/>
</tool>
</lib>
<main name="main"/>
<options>
<a name="gateUndefined" val="ignore"/>
<a name="simlimit" val="1000"/>
<a name="simrand" val="0"/>
</options>
<mappings>
<tool lib="6" map="Button2" name="Menu Tool"/>
<tool lib="6" map="Button3" name="Menu Tool"/>
<tool lib="6" map="Ctrl Button1" name="Menu Tool"/>
</mappings>
<toolbar>
<tool lib="6" name="Poke Tool"/>
<tool lib="6" name="Edit Tool"/>
<tool lib="6" name="Text Tool">
<a name="text" val=""/>
<a name="font" val="SansSerif plain 12"/>
<a name="halign" val="center"/>
<a name="valign" val="base"/>
</tool>
<sep/>
<tool lib="0" name="Pin">
<a name="width" val="4"/>
<a name="tristate" val="false"/>
</tool>
<tool lib="0" name="Pin">
<a name="facing" val="west"/>
<a name="output" val="true"/>
<a name="width" val="4"/>
<a name="labelloc" val="east"/>
</tool>
<tool lib="1" name="NOT Gate"/>
<tool lib="1" name="AND Gate"/>
<tool lib="1" name="OR Gate"/>
</toolbar>
<circuit name="main">
<a name="circuit" val="main"/>
<a name="clabel" val=""/>
<a name="clabelup" val="east"/>
<a name="clabelfont" val="SansSerif plain 12"/>
<wire from="(320,270)" to="(380,270)"/>
<wire from="(400,320)" to="(460,320)"/>
<wire from="(400,220)" to="(460,220)"/>
<wire from="(380,270)" to="(380,340)"/>
<wire from="(670,290)" to="(720,290)"/>
<wire from="(670,300)" to="(720,300)"/>
<wire from="(500,510)" to="(690,510)"/>
<wire from="(270,520)" to="(460,520)"/>
<wire from="(300,220)" to="(350,220)"/>
<wire from="(270,270)" to="(320,270)"/>
<wire from="(350,220)" to="(400,220)"/>
<wire from="(500,420)" to="(680,420)"/>
<wire from="(740,420)" to="(800,420)"/>
<wire from="(160,270)" to="(270,270)"/>
<wire from="(500,230)" to="(670,230)"/>
<wire from="(500,330)" to="(670,330)"/>
<wire from="(680,310)" to="(720,310)"/>
<wire from="(800,420)" to="(800,450)"/>
<wire from="(670,300)" to="(670,330)"/>
<wire from="(350,410)" to="(460,410)"/>
<wire from="(420,240)" to="(420,270)"/>
<wire from="(300,220)" to="(300,500)"/>
<wire from="(380,270)" to="(420,270)"/>
<wire from="(420,240)" to="(460,240)"/>
<wire from="(400,220)" to="(400,320)"/>
<wire from="(320,270)" to="(320,430)"/>
<wire from="(300,500)" to="(460,500)"/>
<wire from="(680,310)" to="(680,420)"/>
<wire from="(690,320)" to="(720,320)"/>
<wire from="(770,450)" to="(800,450)"/>
<wire from="(760,330)" to="(920,330)"/>
<wire from="(320,430)" to="(460,430)"/>
<wire from="(690,320)" to="(690,510)"/>
<wire from="(380,340)" to="(460,340)"/>
<wire from="(160,220)" to="(300,220)"/>
<wire from="(670,230)" to="(670,290)"/>
<wire from="(740,370)" to="(740,420)"/>
<wire from="(350,220)" to="(350,410)"/>
<wire from="(270,270)" to="(270,520)"/>
<comp lib="3" loc="(500,420)" name="Multiplier">
<a name="width" val="4"/>
</comp>
<comp lib="3" loc="(500,510)" name="Divider">
<a name="width" val="4"/>
</comp>
<comp lib="2" loc="(760,330)" name="Multiplexer">
<a name="select" val="3"/>
<a name="width" val="4"/>
</comp>
<comp lib="0" loc="(160,270)" name="Pin">
<a name="width" val="4"/>
<a name="tristate" val="false"/>
</comp>
<comp lib="3" loc="(500,330)" name="Subtractor">
<a name="width" val="4"/>
</comp>
<comp lib="6" loc="(460,368)" name="Text">
<a name="text" val="SUBTRACTOR"/>
</comp>
<comp lib="0" loc="(770,450)" name="Pin">
<a name="width" val="3"/>
<a name="tristate" val="false"/>
</comp>
<comp lib="0" loc="(160,220)" name="Pin">
<a name="width" val="4"/>
<a name="tristate" val="false"/>
</comp>
<comp lib="0" loc="(920,330)" name="Pin">
<a name="facing" val="west"/>
<a name="output" val="true"/>
<a name="width" val="4"/>
<a name="labelloc" val="east"/>
</comp>
<comp lib="6" loc="(88,217)" name="Text">
<a name="text" val="A"/>
</comp>
<comp lib="6" loc="(471,458)" name="Text">
<a name="text" val="MULTIPLIER"/>
</comp>
<comp lib="6" loc="(742,487)" name="Text">
<a name="text" val="MULTIPLEXER BITS"/>
</comp>
<comp lib="6" loc="(465,552)" name="Text">
<a name="text" val="DIVIDER"/>
</comp>
<comp lib="6" loc="(940,368)" name="Text">
<a name="text" val="OUTPUT"/>
</comp>
<comp lib="6" loc="(774,283)" name="Text">
<a name="text" val="8:1 MULTIPLEXER"/>
</comp>
<comp lib="3" loc="(500,230)" name="Adder">
<a name="width" val="4"/>
</comp>
<comp lib="6" loc="(469,269)" name="Text">
<a name="text" val="ADDER"/>
</comp>
<comp lib="6" loc="(93,272)" name="Text">
<a name="text" val="B"/>
</comp>
</circuit>
</project>
PRACTICAL: 17
HDL simulators are software packages that simulate expressions written in one of
the hardware description languages, such as VHDL, Verilog, SystemVerilog.
This page is intended to list current and historical HDL simulators, accelerators, emulators,
etc.
In this Verilog project, basic blocks in digital logic design such as D-Flip-Flop, adders, ALU,
registers, memory, multiplexers, decoders, counters, etc. are implemented in Verilog HDL
for beginners.
,.mem_to_reg(mem_to_reg),.alu_op(alu_op),.jump(jump),.branc
h(branch),.mem_read(mem_read),
.mem_write(mem_write),.alu_src(alu_src),.reg_write(reg_writ
e),.sign_or_zero(sign_or_zero));
// multiplexer regdest
assign reg_write_dest = (reg_dst==2'b10) ? 3'b111:
((reg_dst==2'b01) ? instr[6:4] :instr[9:7]);
// register file
assign reg_read_addr_1 = instr[12:10];
assign reg_read_addr_2 = instr[9:7];
register_file
reg_file(.clk(clk),.rst(reset),.reg_write_en(reg_write),
.reg_write_dest(reg_write_dest),
.reg_write_data(reg_write_data),
.reg_read_addr_1(reg_read_addr_1),
.reg_read_data_1(reg_read_data_1),
.reg_read_addr_2(reg_read_addr_2),
.reg_read_data_2(reg_read_data_2));
//.reg3(reg3),
//.reg4(reg4));
// sign extend
assign sign_ext_im = {{9{instr[6]}},instr[6:0]};
assign zero_ext_im = {{9{1'b0}},instr[6:0]};
assign imm_ext = (sign_or_zero==1'b1) ? sign_ext_im :
zero_ext_im;
// JR control
JR_Control
JRControl_unit(.alu_op(alu_op),.funct(instr[3:0]),.JRContro
l(JRControl));
// ALU control unit
ALUControl
ALU_Control_unit(.ALUOp(alu_op),.Function(instr[3:0]),.ALU_
Control(ALU_Control));
// multiplexer alu_src
assign read_data2 = (alu_src==1'b1) ? imm_ext :
reg_read_data_2;
// ALU
alu
alu_unit(.a(reg_read_data_1),.b(read_data2),.alu_control(AL
U_Control),.result(ALU_out),.zero(zero_flag));
// immediate shift 1
assign im_shift_1 = {imm_ext[14:0],1'b0};
//
assign no_sign_ext = ~(im_shift_1) + 1'b1;
// PC beq add
assign PC_beq = (im_shift_1[15] == 1'b1) ? (pc2 -
no_sign_ext): (pc2 +im_shift_1);
// beq control
assign beq_control = branch & zero_flag;
// PC_beq
assign PC_4beq = (beq_control==1'b1) ? PC_beq : pc2;
// PC_j
assign PC_j = {pc2[15],jump_shift_1};
// PC_4beqj
assign PC_4beqj = (jump == 1'b1) ? PC_j : PC_4beq;
// PC_jr
assign PC_jr = reg_read_data_1;
// PC_next
assign pc_next = (JRControl==1'b1) ? PC_jr : PC_4beqj;
// data memory
data_memory datamem(.clk(clk),.mem_access_addr(ALU_out),
.mem_write_data(reg_read_data_2),.mem_write_en(mem_write),.
mem_read(mem_read),
.mem_read_data(mem_read_data));
// write back
assign reg_write_data = (mem_to_reg == 2'b10) ?
pc2:((mem_to_reg == 2'b01)? mem_read_data: ALU_out);
// output
assign pc_out = pc_current;
assign alu_result = ALU_out;
endmodule
PRACTICAL: 18