Coa 190106107029
Coa 190106107029
LABORATORY MANUAL
Computer Engineering Department
Semester IV
Year 2020-21
Date: 08/01/2021
Experiment 1
THEORY:
Booth's multiplication algorithm is a multiplication algorithm that multiplies two signed binary numbers
in notation .The Booth's algorithm serves two purposes:
Fast multiplication (when there are consecutive 0's or 1's in the multiplier). And Signed multiplication.
Booth's algorithm is a powerful direct algorithm to perform signed-number multiplication. The algorithm
is based on the fact that any binary number can be represented by the sum and difference of other
binary numbers. Using a signed binary notation, we can represent a multiplier in a unique scheme with
the possibility of fewer add cycles for a given multiplier.
Booth's multiplication algorithm is a multiplication algorithm that multiplies two signed binary numbers
in two's complement notation. Booth's algorithm examines adjacent pairs of bits of the N-bit multiplier Y
in signed two's complement representation, including an implicit bit below the least significant bit, y -1 = 0.
For each bit yi, for i running from 0 to N-1, the bits y i and yi-1 are considered. Where these two bits are
equal, the product accumulator P is left unchanged. Where y i = 0 and yi-1 = 1, the multiplicand times 2i is
added toP; and where yi = 1 and yi-1 = 0, the multiplicand times 2i is subtracted from P. The final value of P
is the signed product.
The representation of the multiplicand and product are not specified; typically, these are both also in
two's complement representation, like the multiplier, but any number system that supports addition and
subtraction will work as well. As stated here, the order of the steps is not determined. Typically, it
proceeds from LSB to MSB, starting at i = 0; the multiplication by 2 i is then typically replaced by
incremental shifting of the P accumulator to the right between steps; low bits can be shifted out, and
subsequent additions and subtractions can then be done just on the highest N bits of P. There are many
variations and optimizations on these details.
The algorithm is often described as converting strings of 1's in the multiplier to a high-order +1 and a low-
order –1 at the ends of the string. When a string runs through the MSB, there is no high-order +1, and the
net effect is interpretation as a negative of the appropriate value.
ALGORITHM:
1
Computer Organization and Architecture […Type your Enrolment Number here…]
2
Computer Organization and Architecture […Type your Enrolment Number here…]
3
Computer Organization and Architecture […Type your Enrolment Number here…]
CONCLUSION:
EVALUATION:
4
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 2
AIM: Write the working of 8085 simulator GNUsim8085 and basic architecture of 8085 along with small
introduction.
5
Computer Organization and Architecture […Type your Enrolment Number here…]
Accumulator:-It is a 8-bit register which is used to perform arithmetical and logical operation. It stores
the output of any operation. It also works as registers for i/o accesses.
It can be one of the operand in the instruction.
Temporary Register:-It is a 8-bit register which is used to hold the data on which the accumulator is
computing operation. It is also called as operand register because it provides operands to ALU.
Registers:-These are general purposes registers. Microprocessor consists 6 general purpose registers of
8-bit each named as B,C,D,E,H and L. Generally theses registers are not used for storing the data
permanently. It carries the 8-bits data. These are used only during the execution of the instructions.
These registers can also be used to carry the 16 bits data by making the pair of 2 registers. The valid
register pairs available are BC,DE HL. We cannot use other pairs except BC,DE and HL. These registers are
programmed by user.
Flag Registers:-It consists of 5 flip flop which changes its status according to the result stored in an
accumulator. It is also known as status registers. It is connected to the ALU. There are five flip-flops in the
flag register are as follows:
All of the three flip flop set and reset according to the stored result in the accumulator.
1.Sign- If D7 of the result is 1 then sign flag is set otherwise reset. As we know that a number on the D7
always desides the sign of the number.
if D7 is 1: the number is negative.
if D7 is 0: the number is positive.
2.Zeros(Z)-If the result stored in an accumulator is zero then this flip flop is set as 1 otherwise it is reset
and also if the result of any arithmetic or logical operation is zero its set as 1( The result of this operation
can be in any registers).
3.Auxiliary carry(AC)-If any carry goes from D3 to D4 in the output then it is set otherwise it is reset.
4.Parity(P)-If the no of 1's is even in the output stored in the accumulator then it is set otherwise it is
reset for the odd.
5.Carry(C)-If the result stored in an accumulator generates a carry in its final output then it is
setotherwise it is reset.
Instruction registers(IR):-It is a 8-bit register. When an instruction is fetched from memory then it is
stored in this register.
Program Counter:-It is a 16 bit register used as memory pointer. It stores the memory address of the next
instruction to be executed. So we can say that this register is used to sequencing the program. Generally
the memory have 16 bit addresses so that it has 16 bit memory. The program counter is set to 0000H.
6
Computer Organization and Architecture […Type your Enrolment Number here…]
Stack Pointer:-It is also a 16 bit register used as memory pointer. It points to the memory location called
stack. Generally stack is a reserved portion of memory where information can be stores or taken back
together.
Timing and Control Unit:-It provides timing and control signal to the microprocessor to perform the
various operation. It has three control signals. It controls all external and internal circuits. It operates with
reference to clock signal. It synchronizes all the data transfers. There are three control signal:
1.ALE-Airthmetic Latch Enable, It provides control signal to synchronize the components of
microprocessor. 2.RD- This is active low used for reading operation.
3.WR-This is active low used for writing operation.
There are three status signal used in microprocessor S0, S1 and IO/M. It changes its status according the
provided input to these pins.
Serial Input Output Control-There are two pins in this unit. This unit is used for serial data
communication.
Interrupt Unit-There are 6 interrupt pins in this unit. Generally an external hardware is connected to
these pins. These pins provide interrupt signal sent by external hardware to microprocessor and
microprocessor sends acknowledgement for receiving the interrupt signal. Generally INTA is used for
acknowledgement.
1. Labels
2. Operations :- these operations can be specified as
Machine operations (mnemonics):- used to define operations in the form of opcode as mention in the
instruction set of microprocessor 8085.
Pseudo operations (like preprocessor in C):- these are assembly directives.
3. Operands
4. Comments
In addition, you have constants in an assembly program. Unless otherwise specified, a constant which is
always numeric is in decimal form. If appended with a character h it is assumed to be in hexadecimal
form. If a hex constant starts with an alpha-char don't forget to include thenumber 0 in the beginning,
since that will help the assembler to differentiate between a label and a constant.
Labels:-
When given to any particular instruction/data in a program, takes the address of that instruction or data
as its value. But it has different meaning when given to EQU directive. Then it takes the operand of EQU
as its value. Labels must always be placed in the first column and must be followed by an instruction (no
empty line). Labels must be followed by a : (colon), to differentiate it from other tokens.
Operations:-
As mentioned above the operations can be specified in two ways that are mnemonics and pseudo
operation.
Pseudo operations can be defined by using following directives:-
There are only 3 directives currently available in our assembly language.
1. DB - define byte ( 8 bits )
2. DS - define size (no. of bytes)
3. EQU - like minimalistic #define in C
DB is used to define space for an array of values specified by comma separated list. And the label (if given
to the beginning of DB) is assigned the address of the first data item.
DS is used to define the specified number of bytes to be assigned and initialize them to zero. To access
each byte you can use the + or -operator along with label.
EQU behaves similar to #define in C. But it is simple. It can be used to give names only to numeric
constants. Nesting of EQU is not allowed. You can use EQU only in operands for pseudo ops and
mnemonics.
Operands:-
Operands are specified according to the user. The register set specified in the architecture of 8085 (A, B,
C, D, H and L) are used to access and store data. These registers are specified as operand. In case of
accessing data or storing data in the memory ‘m’ is specified as an operand and the address of this
memory location is taken from the HL pair (data in HL pair).
TASK: Write a program to add two numbers stored at A anc B and store the result at A.
Example:
8
Computer Organization and Architecture […Type your Enrolment Number here…]
Input
A=12h , B=18h
Output
A=2Ah
Step1:open GNU Sim 8085 above window will open. Now click on close button highlighted in the above
screen shot.
Step2: start writing the code after start: nop in load me at 10 that is at load me at 11.
9
Computer Organization and Architecture […Type your Enrolment Number here…]
Step 3: click on reset and reset all the registers by clicking on reset all.
10
Computer Organization and Architecture […Type your Enrolment Number here…]
Step 5: after you execute the code mention the name your program by writing the name in the name section as
mentioned in the screen shot in below picture and the drive where you want to save it. After that click on save.
Step 6: after this you will see the result of the instructions in the respective registers as seen in the below
picture.
11
Computer Organization and Architecture […Type your Enrolment Number here…]
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
Output Data:
CONCLUSION:
EVALUATION:
12
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 3
AIM: Write an assembly language code in GNUsim8085 to store numbers in reverse order in memory
location.
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
Output Data:
CONCLUSION:
EVALUATION:
13
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 4
Task1: Add the contents of memory locations 4000H and 4001H and place the result in memory location
4002H.
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
14
Computer Organization and Architecture […Type your Enrolment Number here…]
Output Data:
Task2:Subtract the contents of memory location 4001H from the memory location 2000H and place
the result in memory location 4002H.
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
Output Data:
15
Computer Organization and Architecture […Type your Enrolment Number here…]
Task3:Add the 16-bit number in memory locations 4000H and 4001H to the 16-bit number in memory
locations 4002H and 4003H. 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
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
Output Data:
Task4:Add the contents of memory locations 40001H and 4001H and place the result in the memory
locations 4002Hand 4003H.
Program:
Memory Address Machine Code Mnemonics Operands Command
16
Computer Organization and Architecture […Type your Enrolment Number here…]
Input Data:
Output Data:
CONCLUSION:
EVALUATION:
17
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 5
AIM: Write an assembly language code in GNUsim8085 to find the factorial of a number.
Program:
Memory Address Machine Code Mnemonics Operands Command
18
Computer Organization and Architecture […Type your Enrolment Number here…]
Input Data:
Output Data:
CONCLUSION:
EVALUATION:
19
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 6
Task1:Find the 2's complement of the number stored at memory location 4200H and store the
complemented number at memory location 4300H.
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
20
Computer Organization and Architecture […Type your Enrolment Number here…]
Output Data:
Task2:Find the l's complement of the number stored at memory location 4400H and store the
complemented number at memory location 4300H.
Program:
Memory Address Machine Code Mnemonics Operands Command
Input Data:
Output Data:
Task3:Write a program to shift an eight bit data four bits right. Assume that data is in register C.
Program:
21
Computer Organization and Architecture […Type your Enrolment Number here…]
Input Data:
Output Data:
Task4:Program to shift a 16-bit data 1 bit left. Assume data is in the HL register pair.
Program:
Memory Address Machine Code Mnemonics Operands Command
22
Computer Organization and Architecture […Type your Enrolment Number here…]
Input Data:
Output Data:
CONCLUSION:
EVALUATION:
Experiment 7
23
Computer Organization and Architecture […Type your Enrolment Number here…]
Circuit Diagram:
Design in Logisim:
24
Computer Organization and Architecture […Type your Enrolment Number here…]
CONCLUSION:
EVALUATION:
25
Computer Organization and Architecture […Type your Enrolment Number here…]
Experiment 8
AIM: Implement i) Logic Gates ii) Half Adder and iii) Full Adder in Verilog HDL
i) Logic Gates
THEORY:
AND GATE:
The AND gate performs logical multiplication which is most commonly known as the AND junction.
The operation of AND gate is such that the output is high only when all its inputs are high and when
any one of the inputs is low the output is low.
Y=a&b
OR GATE:
The OR gate performs logical addition which is most commonly known as the OR junction. The
operation of OR gate is such that the output is high only when any one of its input is high and when
both the inputs are low the output is low.
Y=a|b
NOT GATE:
The Inverter performs a basic logic gate function called Inversion or Complementation. The purpose of
an inverter is to change one logic level to opposite level. When a high level is applied top an inverter,
the low level will appear at the output and vice versa.
Y = ~a
NAND GATE:
The term NAND is derived from the complement of AND. It implies the AND junction with an
inverted output. The operation of NAND gate is such that the output is low only when all its inputs are
high and when any one of the inputs is low the output is high.
Y = ~(a & b)
NOR GATE:
The term NOR is derived from the complement of OR. It implies the OR junction with an inverted
output. The operation of NOR gate is such that the output is high only when all its inputs are low and
when any one of the inputs is high the output is low.
Y = ~(a | b)
EX-OR GATE:
The output is high only when the inputs are at opposite level.
Y=a^b
EX-NOR GATE:
The output is high only when the inputs are at same level.
Y = ~(a ^ b)
26
Computer Organization and Architecture […Type your Enrolment Number here…]
Program:
27
Computer Organization and Architecture […Type your Enrolment Number here…]
THEORY:
The half adder consists of two input variables designated as Augends and Addend bits. Output variables
produce the Sum and Carry. The ‘carry’ output is 1 only when both inputs are 1 and ,sum’ is 1 if any
one input is 1. The Boolean expression is given by,
Circuit Diagram:
Truth Table:
28
Computer Organization and Architecture […Type your Enrolment Number here…]
Program:
THEORY:
A Full adder is a combinational circuit that focuses the arithmetic sum of three bits. It consists of 3
inputs and 2 outputs. The third input is the carry from the previous Lower Significant Position. The two
outputs are designated as Sum (S) and Carry (C). The binary variable S gives the value of the LSB of
the Sum. The output S=1 only if odd number of 1’s are present in the input and the output C=1 if two or
three inputs are 1.
sum = x ^ y ^ z
carry= (x & y) | (y & z) | (x & z)
Circuit Diagram:
29
Computer Organization and Architecture […Type your Enrolment Number here…]
Truth Table:
Program:
CONCLUSION:
EVALUATION:
30