Professional Documents
Culture Documents
MEMORY
Computer memory is just like the human brain. It is used to store data/information and instructions. It is a
data storage unit or a data storage device where data is to be processed and instructions required for
processing are stored. It can store both the input and output can be stored here.
2
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
(i) Magnetic Tapes: Magnetic tape is a long, narrow strip of plastic film with a thin, magnetic coating on
it that is used for magnetic recording. Bits are recorded on tape as magnetic patches called RECORDS that
run along many tracks. Typically, 7 or 9 bits are
recorded concurrently. Each track has one read/write head, which allows data to be recorded and read as a
sequence of characters. It can be stopped, started moving forward or backward, or rewound.
(ii) Magnetic Disks: A magnetic disc is a circular metal or a plastic plate and these plates are coated with
magnetic material. The disc is used on both sides. Bits are stored in magnetized surfaces in locations called
tracks that run in concentric rings. Sectors are typically used to break tracks into pieces.
Hard discs are discs that are permanently attached and cannot be removed by a single user.
(iii) Optical Disks: It’s a laser-based storage medium that can be written to and read. It is
reasonably priced and has a long lifespan. The optical disc can be taken out of the computer by
occasional users. Types of Optical Disks :
3. Cache Memory: It is a type of high-speed semiconductor memory that can help the CPU run faster.
Between the CPU and the main memory, it serves as a buffer. It is used to store the data and programs that
the CPU uses the most frequently.
MOTHERBOARD
A motherboard is one of the most essential parts of a computer system. It holds together many of the crucial
components of a computer, including the central processing unit (CPU), memory and connectors for input
and output devices. The base of a motherboard consists of a very firm sheet of non-conductive material,
typically some sort of rigid plastic. Thin layers of copper or aluminum foil, referred to as traces, are printed
onto this sheet. These traces are very narrow and form the circuits between the various components. In
addition to circuits, a motherboard contains a number of sockets and slots to connect the other components.
3
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Parts of a Motherboard
1. Mouse & keyboard: Keyboard Connectors are two types basically. All PCs have a Key board port
connected directly to the motherboard. The oldest, but still quite common type, is a special DIN, and most
PCs until recently retained this style connector. The AT-style keyboard connector is quickly disappearing,
being replaced by the smaller mini DIN PS/2-style keyboard connector.
2. USB (Universal serial bus): USB is the General-purpose connection for PC. You can find USB
versions of many different devices, such as mice, keyboards,
scanners, cameras, and even printers. USB has a number of features that makes it particularly
popular on PCs. First, USB devices are hot swappable. You can insert or remove them without restarting
your system.
3. Parallel port: Most printers use a special connector called a parallel port. Parallel port carry data on
more than one wire, as opposed to the serial port, which uses only one wire. Parallel ports use a 25-pin
female DB connector. Parallel ports are directly supported by the motherboard through a direct connection
or through a dangle.
4. CPU Chip : The central processing unit, also called the microprocessor performs all the calculations
that take place inside a pc. Modern CPUs generate a lot of heat and thus require a cooling fan or heat sink.
The cooling device (such as a cooling fan) is removable, although some CPU manufactures sell the CPU
with a fan permanently attached.
5. RAM slots: Random-Access Memory (RAM) stores programs and data currently being used by the
CPU. RAM is measured in units called bytes. RAM has been packaged in many different ways. The most
current package is called a 168-pin DIMM (Dual Inline Memory module).
6. Floppy controller: The floppy drive connects to the computer via a 34-pin ribbon cable, which in turn
connects to the motherboard. A floppy controller is one that is used to control the floppy drive.
7. IDE controller: Industry standards define two common types of hard drives: EIDE and SCSI.
Majority of the PCs use EIDE drives. SCSI drives show up in high end PCs such as network servers or
graphical workstations. The EIDE drive connects to the
hard drive via a 2-inch-wide, 40-pin ribbon cable, which in turn connects to the motherboard. IDE
controller is responsible for controlling the hard drive.
4
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
8. PCI slot: Intel introduced the Peripheral component interconnect bus protocol. The PCI bus is used to
connect I/O devices (such as NIC or RAID controllers) to the main logic of the computer. PCI bus has
replaced the ISA bus.
9. ISA slot: (Industry Standard Architecture) It is the standard architecture of the Expansion bus.
Motherboard may contain some slots to connect ISA compatible cards.
10. CMOS Battery: To provide CMOS with the power when the computer is turned off all motherboards
comes with a battery. These batteries mount on the motherboard in one of three ways: the obsolete external
battery, the most common onboard battery, and built-in battery.
11. AGP slot: If you have a modern motherboard, you will almost certainly notice a single connector that
looks like a PCI slot, but is slightly shorter and usually brown. You also probably have a video card inserted
into this slot. This is an Advanced Graphics Port (AGP) slot.
12. CPU slot: To install the CPU, just slide it straight down into the slot. Special notches in the slot make
it impossible to install them incorrectly. So remember if it does not go easily, it is probably not correct. Be
sure to plug in the CPU fan's power.
13. Power supply plug in: The Power supply, as its name implies, provides the necessary electrical
power to make the pc operate. the power supply takes standard 110-V AC power and converts into 12-Volt,
5-Volt, and 3.3-Volt DC power.
A port is a physical docking point using which an external device can be connected to the computer. It can
also be programmatic docking point through which information flows from a program to the computer or
over the Internet.
Serial Port
• Used for external modems and older computer mouse
• Two versions: 9 pin, 25 pin model
• Data travels at 115 kilobits per second
Parallel Port
• Used for scanners and printers
• Also called printer port
• 25 pin model
• IEEE 1284-compliant Centronics port
5
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
PS/2 Port
Firewire Port
• Transfers large amount of data at very fast speed.
• Connects camcorders and video equipment to the computer.
• Data travels at 400 to 800 megabits per seconds.
• Invented by Apple.
• It has three variants: 4-Pin FireWire 400 connector, 6-Pin FireWire 400 connector, and 9-
Pin FireWire 800 connector.
Modem Port
Ethernet Port
• Connects to a network and high speed Internet.
• Connects the network cable to a computer.
• This port resides on an Ethernet Card.
• Data travels at 10 megabits to 1000 megabits per seconds depending upon the network
bandwidth.
Game Port
• Connect a joystick to a PC
• Now replaced by USB
Digital Video Interface, DVI port
• Connects Flat panel LCD monitor to the computer's high-end video graphic cards.
• Very popular among video card manufacturers.
Sockets
• Sockets connect the microphone and speakers to the sound card of the computer.
ADD-IN CARD
add-in card (add-on card, expansion card) A printed circuit board that plugs into an expansion slot in a
computer to provide some extra facility. The sockets normally connect to a bus, and the type of connector
and the use to which each contact is put are strictly defined to ensure compatibility between the card and
the computer. Cards are available that provide extra memory, communications interfaces, sound I/O
capabilities, device interfaces to extra disks or tape backup devices, for instance, or perhaps extra
processors in multiprocessor systems. See also PCMCIA
7
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
and/or television,
on their PCs. With a sound card, a system can go from mono sound, to stereo sound, to surround sound.
Video cards.
Video cards can increase the overall performance of a system, depending upon the card that is installed. They
can also allow the addition of multiple monitors. One of the ways that they increase performance is by taking
the workload off of the CPU and transferring it to the video card. A good video card is a wise investment.
Network cards.
Most motherboards have built in network cards; however, they can fail or they might not connect to the right
type of network in your situation. Additionally, you might need to connect with another or different type of
network or make multiple network connections. Those are a few examples of situations where a network
expansion card could prove useful.
USB cards.
An expansion card will allow you to add more USB ports to a system. You can also add newer versions of USB
by using an expansion card.
FireWire cards.
You can also add more FireWire ports to your system. If you don’t have FireWire, you can use an expansion
card to add it, and, by installing an expansion card, you can update your system.
Storage cards.
A variety of storage solutions are available through the use of expansion cards. If you need to add a SCSI tape
array, you can add an expansion card that allows you to connect to SCSI devices. There are also expansion
8
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
cards that are solid-state drives in their own right. They are an extremely unique solution for storage and they
are very fast; however, they tend to be fairly expensive.
Modem cards.
Most systems no longer come with built-in modems. However, some virtual private networks require the
client to dial-in in order to connect and a modem is needed to do so. An expansion card that has a modem
built into it will resolve this problem.
Wireless/Cellular cards.
Wireless and cellular network cards allow you to take advantage of wireless networks and a cellular card can
take advantage of LTE or 4G networks. Caution: additional data charges may apply.
TV tuner cards.
A TV tuner card allows a PC to make a cable television connection. This is a popular option for a home
theater PC. Cable television can be routed through, or watched, on the PC.
Riser cards.
The riser card is used as an adapter for other cards. They are plugged in and offer the ability to install another
card at a 90-degree angle. They are used when space is tight.
9
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
10
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
The power may be attached using one of two connectors, a Molex connector or a Berg connector for the drive.
The Molex connector may require to be wiggled slightly from side to side and apply gentle pressure outwards.
The Berg connector may just pull out or it may have a small tab which has to be lifted with a screwdriver.
11
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Now Pull data cables off from the drive as well as motherboard connector. The hard disk drive and CD/DVD
drives have two types of data cables. IDE and SATA cables. The IDE cables need better care while being
removed as it may cause the damage to drive connector pins. Gently wiggle the cable sideways and remove it.
The SATA cables can be removed easily by pressing the tab and pulling the connector straight back.
Now remove the screws and slide the drive out the back of the bay.
12
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
SIMM – gently push back the metal tabs while holding the SIMM chips in the socket. Tilt the SIMM
chip away from the tabs until a 45% angle. It will now lift out of the socket. Put SIMM in a safe place.
DIMM- There are plastic tabs on the end of the DIMM sockets. Press the tabs down and away from the
socket. The DIMM will lift slightly. Now grab it by the edges and place it safely. Do not let the chips get
dust at all.
remove processor
Now remove the screws of SMPS from the back of the cabinet and the SMPS can be detached from the tower
cabinet.
13
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
ASSEMBLING OF PC
14
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
15
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
1. CPU: A CPU socket uses a series of pins to connect a CPU,s. processor to the pc,s
motherboard. if a CPU is connected via a CPU socket.
3. Installation of RAM.
Install The RAM First on The Motherboard and Then Fix The Motherboard In The Case. To
Install RAM, First Ensure Its Compatibility with The Motherboard.
16
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
HARD DRIVE
17
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
18
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
19
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
The 8085 Microprocessor Kit is a learning tool designed to help individuals understand the concepts of
microprocessor programming and interfacing. The 8085 microprocessor is an 8-bit microprocessor
introduced by Intel in the mid-1970s. It was widely used in various applications such as embedded
systems, industrial control systems, and personal computers.
8085 Microprocessor: The heart of the kit is the 8085 microprocessor chip. It is an 8-bit
microprocessor with a 16-bit address bus, capable of addressing up to 64 KB of memory. The
8085 microprocessor executes instructions stored in memory and performs arithmetic, logic, and
data transfer operations.
Memory: The kit includes memory modules such as RAM (Random Access Memory) and ROM
(Read-Only Memory). RAM is used for storing data and program instructions temporarily, while
ROM contains permanent program instructions.
Input/Output Ports: The 8085 microprocessor communicates with external devices through
input/output ports. These ports allow the microprocessor to send and receive data from external
devices such as sensors, actuators, displays, and keyboards.
Address and Data Bus: The 8085 microprocessor communicates with memory and I/O
devices through the address bus and data bus. The address bus carries the address of memory
locations or I/O ports, while the data bus carries data between the microprocessor and memory or
I/O devices.
Clock Circuit: The 8085 microprocessor requires a clock signal to synchronize its operations.
The clock circuit generates the clock signal required by the microprocessor to execute instructions
at the specified frequency.
Power Supply: The kit includes a power supply unit to provide the necessary voltage and
current to the 8085 microprocessor and other components.
20
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Interface Components: Various interface components such as buffers, latches, and drivers
are used to interface the 8085 microprocessor with external devices.
Development Tools: The kit may include development tools such as an assembler, debugger,
and simulator to write, debug, and simulate programs for the 8085 microprocessor.
The 8085 Microprocessor Kit is an excellent tool for learning about microprocessor architecture,
programming, and interfacing. It provides hands-on experience with real-world applications and prepares
individuals for careers in embedded systems, digital electronics, and computer engineering.
21
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
22
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Consider the first number 10H is stored in memory location 4000H and the second number
stored in the memory location 4002H. Assume program starts from memory location 4000H.
Program:
LXI H ,4000H
MOV A,M
INX H ; 4001H
MOV C,M
ADD C
INX H ;4002H
MOV M,A
Observation:
Input: 10 (4000)
4 (4001)
Output: 102(4002)
Result:
23
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Two decimal numbers are stored in 2100H and 2101H. The result is to be stored in 2102H
Program:
LXI H, 2100H : "Get address of first number in H-L pair. Now H-L points to 2100H"
Observation:
17 at location 2101H
Result:
24
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
8bit number is stored in location 2400H and 1’s complement of given 8bit number will be stored in
2401H location. Consider program starts from memory location 2400H.
Program:
Observation:
Result:
25
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
8bit number is stored in location 4500H and 2’s complement of given 8bit number will be stored in
4501H location. Consider program starts from memory location 2400H.
Program:
Observation:
Result:
26
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
8bit number is stored in location 3000H and after shifting one bit left result will be stored in 3001H
location. Consider program starts from memory location 3000H.
Program:
LDA 3000H
RAL
STA 3001H
Observation:
Result:
Thus the program Left Shift an 8-bit no. by one bit is executed successfully.
27
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Two decimal numbers are stored in 2101H and 2102H. The result is to be stored in 2103H
Program:
JNC 200C: jump at memory location 200C if carry flag is Reset(Carry flag = 0)
Observation:
10 at location 2102
Result:
28
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Values of array are stored from location 4100H to 410A . Largest no. among all that is 11 stored at
location 410B
Program:
LXI H, 4100H
MOV C, M
INX H
MOV B, M
DCR C
LOOP: INX H
MOV A,M
CMP B
JC SKIP
MOV B,A
SKIP: DCR C
JNZ LOOP
LXI H ,410BH
MOV M,B
HLT
Observation:
29
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Result:
30
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Values of numbers are stored from location 2400H to 2405H . Sum of all the numbers are stored at
location 2406H
Program:
LXI H, 2400H
MOV C, M
MOV A,M
BACK: INX H
ADD M
DCR C
JNZ BACK
INX H
MOV M,A
RST 5
Observation:
Result:
31
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
The execution unit consists of: General purpose (scratch pad) registers AX, BX, CX and DX; Pointer
registers SP (Stack Pointer) and BP (Base Pointer); index registers source index (SI) & destination
index (DI) registers; the Flag register, the ALU to perform operations and a control unit with
associated internal bus. The 16-bit scratch pad registers can be split into two 8-bit registers. AX AL,
AH ; BX BL, BH; CX CL, CH; DX DL, DH.
Figure 1A
32
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Figure 1B
Register Uses/Operations
AX As accumulator in Word multiply & Word divide operations, Word I/O
operations
AL As accumulator in Byte Multiply, Byte Divide, Byte I/O, translate,
Decimal Arithmetic
AH Byte Multiply, Byte Divide
33
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
34
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
35
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Programming Models:
Depending on the size of the memory the user program occupies, different types of assembly
language models are defined.
The source code consists of 8086/8088 program memories, appropriate pseudo-Opcodes and
assembler directives. The first is created with a text editor and is given an extension ASM. The
text editor may be any word processor (ex., EDLIN, NE) that can produce standard ASCII code.
36
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
To assemble the program two assemblers are available for the IBM-PC. They are:
Microsoft Macro Assembler (MASM) and Borland Turbo Assembler (TASM).
Besides doing the tedious task of producing the binary codes for the instruction statements, an
assembler also allows the user to refer to data items by name rather by numerical addresses.
This makes the program much more readable. In addition to program instructions, the source
program contains directives to the assembler. Pseudo instructions are assembler directives
entered into the source code along with the assembly language.
Once the program written completely, it can be assembled to obtain the OBJ file
by executing MASM. The assembly language program file name should be mentioned
along withthe command.
MASM<file name.ASM>
The <file name.ASM> file that contains the assembly language program is
assembled. The assembler generates error messages if there are any error
(Syntax errors).
These errors are listed along with the line number. If there are no errors then .OBJ
file is created. To obtain the .EXE file the user has to LINK the .OBJ file.
If a file is smaller than 64K bytes it, can be converted from an execution file to a command
file (.COM). The command file is slightly different from an execution file (.EXE).
In a command file the program must be originated at location 100H before it can execute.
This means that the program must be no longer than (64K-100H) in length. The
command file requires less space in memory than the equivalent execution file. The system
loads .COM file off the disk into the computer memory more quickly than the execution file.
To create a .COM file from a
.EXE file, we need the EXE2BIN converter EXE2BIN converts .EXE file to .COM or binary file.
37
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Example: DEBUG<filename.EXE>
Using DEBUG it is possible to find the bugs in the program. After loading it into the memory
it is possible to check and correct the errors using different commands in DEBUG. Some of
the commands are as follows:
G-GO
Format:G[offset][, offset]
Action: Executes a program starting at the current location offset values are temporary
breakpoints. Upon encounter of a breakpoint instruction the processor stops and displays
registersand flag contents.
T – TRACE
Action: Executes one or more instructions and displays register and flag values for
each ofthem.
Action: Same as Trace, but treats subroutine calls, interrupts, loop instructions, and repeat
38
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Q-QUIT
Format: Q
Action: Bytes the starting from the memory location whose address is provided by IP
addresses and written as a .COM file to the disk. The number of bytes that are to be stored is
indicated by the contents of the CX Register. The name of the file is to be specified by means
of theN command prior to executing the W command.
R-Register
Action: The contents of register are displayed additionally, the register content can replace by
the value entered by the user. If no register name is provided, the contents of all the register
are displayed
A-Assemble
U- Unassemble
Action: This command lists a program from the memory. The memory start location is
specified by CS: offset.
L-Load
39
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Action: Reads sectors from the disk into memory. The memory start address is provided in
the command
E-Enter
A program can be written and debugged using the following additional techniques.
1. Very carefully define them program to solve the problem in hand and work out
the best algorithm you can.
2. If the program consists of several parts, write, test and debug each part
individually andthen include parts one at a time.
3. If a program or program section does not work, first recheck the algorithm to
make sure it really does what you want it to. You might have someone else look at it
also.
4. If the algorithm seems correct, check to make sure that you have used the correct
instructions to implement the algorithm. Work out on paper the effect that a series of
instructions will have on some sample data. These predictions on paper can later
becompared with the actual results producer when the program section runs.
5. If you don‟t find a problem in the algorithm or the program instruction use debugger
to help you localize the problem. Use single step or trace for short program sections.
For longer programs use breakpoints. This is often a faster technique to narrow the
source of the problem down to a small region.
Program Development
The first step to develop a program is to know “What do I really want this program to do?”
As you think about the problem, it is good idea to write down exactly what you want the
program to do and the order in which you want the program to do it. At this point, no program
statement is written but just the operation in general terms.
40
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Flowcharts are graphic shapes to represent different types of program operations. The
specific operation desired is written by means of graphic symbols. Flowcharts are generally
used for simple programs or program sections.
1. Set up and declare the data structure for the algorithm you are working
with.
2. Write down the instructions required for initialization at the start of the code
section.
3. Determine the instructions required to implement the major actions
taken in thealgorithm, and decide how dada must be positioned for
these instructions.
4. Insert the instructions required to get the data in correct position.
The inclusion of spaces between label Opcode, operands, mnemonics and comments are
arbitrary, except that at least one space must be inserted if no space would lead to anambiguity
(e.g.. between the mnemonic and first operand). There can be no spaces within a mnemonic or
identifier and spaces within string constants or comments will be included as space characters.
Each statement in program consists of fields.
Label: It is an identifier that is assigned the address of the first byte of the instruction in which
it appears. The presence of a label in an instruction is optional, but, if present, the label
provides a symbolic name that can be used in branch instruction to branch to the instruction. If
there is no label, then the colon must not be entered. All labels begin with a letter or one of the
following special character: @, $,‟ – or?. A label may be any length from 1 to 35 characters. A
label appears in a program to identify the name of memory location for storing data and for
other purposes.
Opcode and Operands: The Opcode field is designed to hold the instruction Opcode. To the
41
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
right of Opcode field is the operand field, which contains information used by the Opcode.
Mnemonic: All instructions must contain a mnemonic. The mnemonic specifies the operation
to be executed.
Operand: The presence of the operands depends on the instruction. Some instructions have
no operands; some have one operand, and some two. If there are two operands, they are
separated by a comma.
Comments: The comment field is for commenting the program and may contain any
combination of characters. It is optional and if it is deleted the semicolon may also be deleted.
A comment may appear on a line by itself provided that the first character on the line is a
semicolon.
The MODEL directive selects a standard memory model for the assembly language program.
A memory model may be thought of a standard blue print or configuration, which
determines the way segments are linked together. Each memory model has a different set of
restrictions as to the maximum space available for code and data. But the most important thing
to know about model is that they affect the way that subroutines and data may be reached by
program.
42
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
A program running under DOS is divided into 3 primary segments (point to by CS) contains
program code; the data segment (pointed to by DS) contains the program variables, the stack
segment (pointed to by SS) contains the program stack.
" .DATA" directive (line 2) indicates the start of the data segment. It contains the
program variables.
" .CODE" directive (line k) indicates the start of the code segment. The end directive
(line n) indicates the end of the program file.
DATA-HERE SEGMENT
......
...... Data declaration
DATA-HERE ENDS CODE-
HERE SEGMENT
......
END
User can use code view to debug the program by following the steps given below:
43
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
44
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
ADDITION
Program:
SHLD 2004H :Store 16-bit result in memory locations 2004H and 2005H.
Observation:
Input: 4 (2000H)
6 (2002)
Output: 10 (2004H )
Result:
45
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
SUBTRACTION
Program:
MOV A, M ; Copy the operand from memory (H-L pair) into accumulator
Observation:
Input: 10 (2000H)
50 ( 2001H )
Output: 60 (2003H)
Result:
46
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
#include <math.h>
void binary(){
a1 = fabs(a);
b1 = fabs(b);
r = a1 % 2;
a1 = a1 / 2;
r2 = b1 % 2;
b1 = b1 / 2;
anum[i] = r;
anumcp[i] = r;
bnum[i] = r2;
if(r2 == 0){
bcomp[i] = 1;
if(r == 0){
47
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
acomp[i] =1;
c = 0;
c = 1;
else
c = 0;
res[i] = res[i] % 2;
bcomp[i] = res[i];
if (a < 0){
c = 0;
res[i] = 0;
48
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
c = 1;
else
c = 0;
res[i] = res[i]%2;
anum[i] = res[i];
anumcp[i] = res[i];
temp = bnum[i];
bnum[i] = bcomp[i];
bcomp[i] = temp;
int i;
49
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
c = 0;
c = 1;
else{
c = 0;
res[i] = res[i]%2;
pro[i] = res[i];
printf("%d",pro[i]);
printf(":");
printf("%d", anumcp[i]);
void arshift(){
pro[i-1] = pro[i];
50
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
pro[4] = temp;
anumcp[i-1] = anumcp[i];
anumcp[4] = temp2;
printf("\nAR-SHIFT: ");
printf("%d",pro[i]);
printf(":");
printf("%d", anumcp[i]);
int main(){
int i, q = 0;
do{
printf("\nEnter A: ");
51
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
scanf("%d",&a);
printf("Enter B: ");
scanf("%d", &b);
binary();
printf("\nA = ");
printf("%d", anum[i]);
printf("\nB = ");
printf("%d", bnum[i]);
printf("\nB'+ 1 = ");
printf("%d", bcomp[i]);
printf("\n\n");
if (anum[i] == q){
printf("\n-->");
52
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
arshift();
q = anum[i];
printf("\n-->");
printf("\nSUB B: ");
add(bcomp);
arshift();
q = anum[i];
else{
printf("\n-->");
printf("\nADD B: ");
add(bnum);
arshift();
q = anum[i];
printf("\nProduct is = ");
printf("%d", pro[i]);
53
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
printf("%d", anumcp[i]);
OUTPUT :
54
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Program:
LHLD 3000H
MOV A,L
CMA
MOV L,A
MOV A,H
CMA
ADI 01
MOV H,A
SHLD 3002H
Output
Before Execution:
3000H: 45
3001H: 46
After Execution:
3002H: 245
3003H: 246
Result:
Thus the program of 1’s and 2’s complement of 16-bit number is executed successfully.
55
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
I/O Interface
The method that is used to transfer information between internal storage and external I/O devices
is known as I/O interface. The CPU is interfaced using special communication links by the
peripherals connected to any computer system. These communication links are used to resolve
the differences between CPU and peripheral. There exists special hardware components between
CPU and peripherals to supervise and synchronize all the input and output transfers that are
called interface units.
Mode of Transfer:
The binary information that is received from an external device is usually stored in the memory
unit. The information that is transferred from the CPU to the external device is originated from
the memory unit. CPU merely processes the information but the source and target is always the
memory unit. Data transfer between CPU and the I/O devices may be done in different modes.
Data transfer to and from the peripherals may be done in any of the three possible ways
1. Programmed I/O.
2. Interrupt- initiated I/O.
3. Direct memory access( DMA).
1 . Programmed I/O: It is due to the result of the I/O instructions that are written in the
computer program. Each data item transfer is initiated by an instruction in the program. Usually
the transfer is from a CPU register and memory. In this case it requires constant monitoring by
the CPU of the peripheral devices.
Example of Programmed I/O: In this case, the I/O device does not have direct access to the
memory unit. A transfer from I/O device to memory requires the execution of several
instructions by the CPU, including an input instruction to transfer the data from device to the
CPU and store instruction to transfer the data from CPU to memory. In programmed I/O, the
CPU stays in the program loop until the I/O unit indicates that it is ready for data transfer. This is
56
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
a time consuming process since it needlessly keeps the CPU busy. This situation can be avoided
by using an interrupt facility. This is discussed below.
2. Interrupt- initiated I/O: Since in the above case we saw the CPU is kept busy
unnecessarily. This situation can very well be avoided by using an interrupt driven method for
data transfer. By using interrupt facility and special commands to inform the interface to issue an
interrupt request signal whenever data is available from any device. In the meantime the CPU
can proceed for any other program execution. The interface meanwhile keeps monitoring the
device. Whenever it is determined that the device is ready for data transfer it initiates an interrupt
request signal to the computer. Upon detection of an external interrupt signal the CPU stops
momentarily the task that it was already performing, branches to the service program to process
the I/O transfer, and then return to the task it was originally performing.
The I/O transfer rate is limited by the speed with which the processor can test and service
a device.
The processor is tied up in managing an I/O transfer; a number of instructions must be
executed for each I/O transfer.
Terms:
Hardware Interrupts: Interrupts present in the hardware pins.
Software Interrupts: These are the instructions used in the program whenever the
required functionality is needed.
Vectored interrupts: These interrupts are associated with the static vector address.
Non-vectored interrupts: These interrupts are associated with the dynamic vector
address.
Maskable Interrupts: These interrupts can be enabled or disabled explicitly.
Non-maskable interrupts: These are always in the enabled state. we cannot disable
them.
External interrupts: Generated by external devices such as I/O.
Internal interrupts: These devices are generated by the internal components of the
processor such as power failure, error instruction, temperature sensor, etc.
Synchronous interrupts: These interrupts are controlled by the fixed time interval.
All the interval interrupts are called as synchronous interrupts.
Asynchronous interrupts: These are initiated based on the feedback of previous
instructions. All the external interrupts are called as asynchronous interrupts.
Direct Memory Access: The data transfer between a fast storage media such as magnetic
disk and memory unit is limited by the speed of the CPU. Thus we can allow the peripherals
directly communicate with each other using the memory buses, removing the intervention of the
CPU. This type of data transfer technique is known as DMA or direct memory access. During
DMA the CPU is idle and it has no control over the memory buses. The DMA controller takes
over the buses to manage the transfer directly between the I/O devices and the memory unit.
57
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Advantages:
Standardization: I/O interfaces provide a standard way of communicating with external devices.
This means that different devices can be connected to a computer using the same interface,
which makes it easier to swap out devices and reduces the need for specialized hardware.
Modularity: With I/O interfaces, different devices can be added or removed from a computer
without affecting the other components. This makes it easier to upgrade or replace a faulty
device without affecting the rest of the system.
Efficiency: I/O interfaces can transfer data between the computer and the external devices at high
speeds, which allows for faster data transfer and processing times.
Compatibility: I/O interfaces are designed to be compatible with a wide range of devices, which
means that users can choose from a variety of devices that are compatible with their computer’s
I/O interface.
Disadvantages:
Cost: I/O interfaces can be expensive, especially if specialized hardware is required to connect a
particular device to a computer system.
Complexity: Some I/O interfaces can be complex to configure and require specialized knowledge
to set up and maintain. This can be a disadvantage for users who are not familiar with the
technical aspects of computer hardware.
Compatibility issues: While I/O interfaces are designed to be compatible with a wide range of
devices, there can still be compatibility issues with certain devices. In some cases, device drivers
may need to be installed to ensure proper functionality.
58
COA LAB Hariom Tiwari
BTES 402 - 18 2224374
Security risks: I/O interfaces can be a security risk if they are not properly configured or secured.
Hackers can exploit vulnerabilities in I/O interfaces to gain unauthorized access to a computer
system or steal data.
59