Computer Architecture and Organization
Computer Architecture and Organization
1. Hardware:
Central Processing Unit (CPU): Often referred to as the brain of the
computer, the CPU performs calculations and executes instructions.
Memory (RAM): Random Access Memory is volatile memory that the CPU
uses to store data and instructions temporarily while the computer is running.
Storage: This includes devices like hard drives and solid-state drives,
providing non-volatile storage for long-term data retention.
Input Devices: These allow users to interact with the computer, such as
keyboards, mice, and touchscreens.
Output Devices: Devices like monitors and printers display or produce results
from the computer's processed information.
Motherboard: The main circuit board that connects and facilitates
communication between various hardware components.
2. Software:
Operating System (OS): This is the core software that manages hardware
resources and provides essential services for other software applications.
Examples include Windows, macOS, and Linux.
Applications: Software programs designed for specific tasks, such as word
processors, web browsers, and games.
Device Drivers: Software that allows the operating system to communicate
with and control hardware devices.
Utilities: Programs that perform system maintenance tasks, like antivirus
software and disk cleanup tools.
3. Data:
Binary Code: Computers process data in the form of binary code,
represented by 0s and 1s. These binary digits, or bits, are the fundamental
units of digital information.
Data Representation: Information is stored and processed in different
formats, such as text, numbers, images, and videos.
4. Communication:
Input and Output (I/O): The process of exchanging data between the
computer and its external environment through input and output devices.
Networks: Computers can be connected to form networks, enabling them to
communicate and share resources. The Internet is a global example of a
computer network.
5. System Software and Application Software:
System Software: Includes the operating system and utilities that manage
the computer system's hardware and provide a platform for running
applications.
Application Software: Programs designed to perform specific tasks or
functions, catering to the needs of users.
Function of RAM
Because of its volatility, RAM can't store permanent data. RAM can be
compared to a person's short-term memory, and a hard disk drive to a
person's long-term memory. Short-term memory is focused on immediate
work, but it can only keep a limited number of facts in view at any one time.
When a person's short-term memory fills up, it can be refreshed with facts
stored in the brain's long-term memory.
A computer also works this way. If RAM fills up, the computer's processor
must repeatedly go to the hard disk to overlay the old data in RAM with new
data. This process slows the computer's operation.
Offline memory typically referred to magnetic tape from which a specific piece
of data could only be accessed by locating the address sequentially, starting at
the beginning of the tape. RAM is organized and controlled in a way that
enables data to be stored and retrieved directly to and from specific locations.
Other types of storage -- such as the hard drive and CD-ROM-- are also
accessed directly or randomly, but the term random access isn't used to
describe these other types of storage.
RAM is similar in concept to a set of boxes in which each box can hold a 0 or a
1. Each box has a unique address that is found by counting across the
columns and down the rows. A set of RAM boxes is called an array, and each
box is known as a cell.
To find a specific cell, the RAM controller sends the column and row address
down a thin electrical line etched into the chip. Each row and column in a RAM
array has its own address line. Any data that's read flows back on a separate
data line.
RAM is physically small and stored in microchips. It's also small in terms of the
amount of data it can hold. A typical laptop computer may come with 8
gigabytes of RAM, while a hard disk can hold 10 terabytes.
A hard drive, on the other hand, stores data on the magnetized surface of
what looks like a vinyl record. Alternatively, an SSD stores data in memory
chips that, unlike RAM, are nonvolatile. They don't depend on having constant
power and won't lose data once the power is turned off. RAM microchips are
gathered together into memory modules. These plug into slots in a computer's
motherboard. A bus, or a set of electrical paths, is used to connect the
motherboard slots to the processor.
Most PCs enable users to add RAM modules up to a certain limit. Having
more RAM in a computer cuts down on the number of times the processor
must read data from the hard disk, an operation that takes longer than reading
data from RAM. RAM access time is in nanoseconds, while storage memory
access time is in milliseconds.
Up until now, we have talked about the first part of the information:
the bits. We know by now that everything inside a machine goes
back to long strings of 0 and 1, which are somehow encoded to give
them a meaning. But how does this work? It depends on the context.
Given a specific context, bits can be encoded respectively. The
following two examples illustrate this.
Have you ever wondered how a computer can produce colors? Just
as with everything else, it's by putting the correct order of 0 and 1 in
the correct place and by choosing the correct encoding. When we
talk about colors, we often use a hexadecimal number system in
addition. The hexadecimal number system is a base-16 number
system, which means that a single digit can show 16 different values
instead of 2 as in the binary system. The values in a base-16 system
range from 0–9 to A-F. Putting these values together gives a certain
color code. Each color is a combination of the colors red, green, and
blue.
If a computer has a certain string to decode (e. g.
111111111111111111111111), in the context of colors it would be
decoded to a hex string (e. g. FFFFFF), which mixes the colors red,
green, and blue with the given combination and reveals the color
white.
1. Assembler
2. Compiler
3. Interpreter
Assembler
Compiler
Interpreter
Compilation process in c
What is a compilation?
The compilation is a process of converting the source code into object code. It is
done with the help of the compiler. The compiler checks the source code for the
syntactical or structural errors, and if the source code is error-free, then it generates
the object code.
The c
compilation process converts the source code taken as input into the object code or
machine code. The compilation process can be divided into four steps, i.e., Pre-
processing, Compiling, Assembling, and Linking.
The preprocessor takes the source code as an input, and it removes all the comments
from the source code. The preprocessor takes the preprocessor directive and
interprets it. For example, if <stdio.h>, the directive is available in the program, then
the preprocessor interprets the directive and replace this directive with the content of
the 'stdio.h' file.
The following are the phases through which our program passes before being
transformed into an executable form:
o Preprocessor
o Compiler
o Assembler
o Linker
Preprocessor
The source code is the code which is written in a text editor and the source code file
is given an extension ".c". This source code is first passed to the preprocessor, and
then the preprocessor expands this code. After expanding the code, the expanded
code is passed to the compiler.
Compiler
The code which is expanded by the preprocessor is passed to the compiler. The
compiler converts this code into assembly code. Or we can say that the C compiler
converts the pre-processed code into assembly code.
Assembler
The assembly code is converted into object code by using an assembler. The name of
the object file generated by the assembler is the same as the source file. The
extension of the object file in DOS is '.obj,' and in UNIX, the extension is 'o'. If the
name of the source file is 'hello.c', then the name of the object file would be
'hello.obj'.
Linker
Mainly, all the programs written in C use library functions. These library functions are
pre-compiled, and the object code of these library files is stored with '.lib' (or '.a')
extension. The main working of the linker is to combine the object code of library
files with the object code of our program. Sometimes the situation arises when our
program refers to the functions defined in other files; then linker plays a very
important role in this. It links the object code of these files to our program. Therefore,
we conclude that the job of the linker is to link the object code of our program with
the object code of the library files and other files. The output of the linker is the
executable file. The name of the executable file is the same as the source file but
differs only in their extensions. In DOS, the extension of the executable file is '.exe',
and in UNIX, the executable file can be named as 'a.out'. For example, if we are using
printf() function in a program, then the linker adds its associated code in an output
file.
hello.c
1. #include <stdio.h>
2. int main()
3. {
4. printf("Hello javaTpoint");
5. return 0;
6. }
o Firstly, the input file, i.e., hello.c, is passed to the preprocessor, and the preprocessor
converts the source code into expanded source code. The extension of the expanded
source code would be hello.i.
o The expanded source code is passed to the compiler, and the compiler converts this
expanded source code into assembly code. The extension of the assembly code
would be hello.s.
o This assembly code is then sent to the assembler, which converts the assembly code
into object code.
o After the creation of an object code, the linker creates the executable file. The loader
will then load the executable file for the execution.