0% found this document useful (0 votes)
4 views34 pages

1 Introduction

The document provides an overview of computer programming languages, including high-level, assembly, and machine languages, and their relationships. It explains the roles of assemblers, compilers, and the importance of understanding assembly language for system-level programming. Additionally, it covers components of computer systems, memory types, and the differences between primary and secondary memory.

Uploaded by

mertuygun160
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views34 pages

1 Introduction

The document provides an overview of computer programming languages, including high-level, assembly, and machine languages, and their relationships. It explains the roles of assemblers, compilers, and the importance of understanding assembly language for system-level programming. Additionally, it covers components of computer systems, memory types, and the differences between primary and secondary memory.

Uploaded by

mertuygun160
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Programing

Next . . .
❖ High-Level, Assembly-, and Machine-Languages

❖ Components of a Computer System

❖ Technology Improvements

❖ Programmer’s View of a Computer System


Some Important Questions to Ask
❖ What is Assembly Language?

❖ What is Machine Language?

❖ How is Assembly related to a high-level language?

❖ Why Learn Assembly Language?

❖ What is an Assembler, Linker, and Debugger?


A Hierarchy of Languages
Application Programs

High-Level Languages
Machine independent High-Level Language
Machine specific Low-Level Language
Assembly Language

Machine Language

Hardware
Assembly and Machine Language
❖ Machine language
 Native to a processor: executed directly by hardware
 Instructions consist of binary code: 1s and 0s

❖ Assembly language
 Slightly higher-level language
 Readability of instructions is better than machine language
 One-to-one correspondence with machine language instructions
❖ Assemblers translate assembly to machine code
❖ Compilers translate high-level programs to machine code
 Either directly, or
 Indirectly via an assembler
Introduction COE 301– KFUPM slide 5
Assembly and Machine Language
❖ Machine language
 Native to a processor: executed directly by hardware
 Instructions consist of binary code: 1s and 0s

❖ Assembly language
 Slightly higher-level language
 Readability of instructions is better than machine language
 One-to-one correspondence with machine language instructions
❖ Assemblers translate assembly to machine code
❖ Compilers translate high-level programs to machine code
 Either directly, or
 Indirectly via an assembler
Introduction COE 301– KFUPM slide 6
Assembly and Machine Language
❖ Machine language
 Native to a processor: executed directly by hardware
 Instructions consist of binary code: 1s and 0s

❖ Assembly language
 Slightly higher-level language
 Readability of instructions is better than machine language
 One-to-one correspondence with machine language instructions
❖ Assemblers translate assembly to machine code
❖ Compilers translate high-level programs to machine code
 Either directly, or
 Indirectly via an assembler
Computer Languages

Introduction COE 301– KFUPM slide 8


Compiler and Assembler
Instructions and Machine Language
❖ Each command of a program is called an instruction (it
instructs the computer what to do).
❖ Computers only deal with binary data, hence the
instructions must be in binary format (0s and 1s) .
❖ The set of all instructions (in binary form) makes up the
computer's machine language. This is also referred to as
the instruction set.
Instruction Fields
❖ Machine language instructions usually are made up of
several fields. Each field specifies different information
for the computer. The major two fields are:
❖ Opcode field which stands for operation code and it
specifies the particular operation that is to be performed.
 Each operation has its unique opcode.
❖ Operands fields which specify where to get the source
and destination operands for the operation specified by
the opcode.
 The source/destination of operands can be a constant, the
memory or one of the general-purpose registers.
Translating Languages
Program (C Language):
swap(int v[], int k) { A statement in a high-level
int temp; language is translated
temp = v[k]; typically into several
v[k] = v[k+1]; machine-level instructions
v[k+1] = temp;
}
Compiler
MIPS Assembly Language: MIPS Machine Language:
sll $2,$5, 2 00051080
Assembler
add $2,$4,$2 00821020
lw $15,0($2) 8C620000
lw $16,4($2) 8CF20004
sw $16,0($2) ACF20000
sw $15,4($2) AC620004
jr $31 03E00008
Advantages of High-Level Languages
❖ Program development is faster
 High-level statements: fewer instructions to code

❖ Program maintenance is easier


 For the same above reasons

❖ Programs are portable


 Contain few machine-dependent details
▪ Can be used with little or no modifications on different machines

 Compiler translates to the target machine language


 However, Assembly language programs are not portable
Why Learn Assembly Language?
❖ Many reasons:
 Accessibility to system hardware
 Space and time efficiency

❖ Accessibility to system hardware


 Assembly Language is useful for implementing system software
 Also useful for small embedded system applications

❖ Space and Time efficiency


 Understanding sources of program inefficiency
 Tuning program performance
 Writing compact code
Assembly Language Programming Tools
❖ Editor
 Allows you to create and edit assembly language source files
❖ Assembler
 Converts assembly language programs into object files
 Object files contain the machine instructions
❖ Linker
 Combines object files created by the assembler with link libraries
 Produces a single executable program
❖ Debugger
 Allows you to trace the execution of a program
 Allows you to view machine instructions, memory, and registers
Assemble and Link Process

Source Object
File Assembler File

Source Object Executable


File Assembler File Linker
File

Link
Source Object
Assembler Libraries
File File
MARS Assembler and Simulator Tool
Note
❖ High-Level Languages it's the language that humans understand, such as the C
program and it is translated into Assembly Language where in a Assembly
Language translates the information appropriately and sends it to Machine
Language: which is 0 and 1 language.
❖ Machine language is a low-level programming language made out of binary
numbers or bits that can only be read by machines. It is also known as machine
code or object code, in which instructions are executed directly by the CPU.
❖ Assembly language is a type of low-level programming language that is intended
to communicate directly with a computer's hardware. Unlike machine language,
which consists of binary and hexadecimal characters, assembly languages are
designed to be readable by humans.
❖ Compiler is a computer program that translates computer code written in one
programming language (the source language) into another language (the target
language). Types of compiled language – C, C++, C#, CLEO, COBOL, etc.
❖ Interpreter directly executes instructions written in a programming or scripting
language without previously converting them to an object code or machine code.
Examples of interpreted languages are Perl, Python and Matlab.
Introduction COE 301– KFUPM slide 18
Components of a Computer System
❖ Processor Computer
 Datapath Memory
 Control
I/O Devices
❖ Memory & Storage Control Input
 Main Memory B
Processor U Output
 Disk Storage S
Datapath Disk
❖ Input devices
❖ Output devices Network

❖ Bus: Interconnects processor to memory and I/O


❖ Network: newly added component for communication
Memory
❖ Ordered sequence of bytes
 The sequence number is called the memory address

❖ Byte addressable memory


 Each byte has a unique address
 Supported by almost all processors

❖ Physical address space


 Determined by the address bus width
 Pentium has a 32-bit address bus
 Itanium with a 64-bit address bus can support
Address Space
Address, Data, and Control Bus
❖ Address Bus
 Memory address is put on address bus
a
 If memory address = a bits then 2 locations are addressed
❖ Data Bus: bi-directional bus
 Data can be transferred in both directions on the data bus
❖ Control Bus
Processor Memory
 Signals control address bus
0
transfer of data Address Register a bits
1
data bus 2
 Read request Data Register d bits 3
 Write request read
write ...
 Done transfer Bus Control
done a
2 –1
Memory Devices
❖ Volatile Memory Devices
 Data is lost when device is powered off
 RAM = Random Access Memory
 DRAM = Dynamic RAM
▪ 1-Transistor cell + trench capacitor
▪ Dense but slow, must be refreshed
▪ Typical choice for main memory
 SRAM: Static RAM
▪ 6-Transistor cell, faster but less dense than DRAM
▪ Typical choice for cache memory
❖ Non-Volatile Memory Devices
 Stores information permanently
 ROM = Read Only Memory
 Used to store the information required to startup the computer
 Many types: ROM, EPROM, EEPROM, and FLASH
 FLASH memory can be erased electrically in blocks
Storage-Device Hierarchy

Introduction COE 301– KFUPM slide 24


Introduction COE 301– KFUPM slide 25
Memory Unit of computer
❖ Computer memory types and functions : This unit is responsible to store
programs or data on a temporary or permanent basis. It has primary
memory (main memory) and secondary memory (auxiliary memory). The
input data which is to be processed is brought into main memory before
processing.

❖ Types Of Computer Memory:

❖ In general the memory is classified into two categories as follows

❖ Primary memory or main memory .

❖ Secondary memory or auxiliary memory.

❖ Cache memory.
Introduction COE 301– KFUPM slide 26
Primary Memory
❖ The memory unit that communicates directly with the CPU is
called main memory or the internal memory the primary
memory allows the computer to store data for immediate
manipulation and to keep track of what is currently being
processed . It is volatile in nature It Means that when the
power is turned off the contents of the primary memory are
lost forever. Primary memory can be for the classified into
two categories which are as follows:-
❖ RAM (Random access memory).
❖ ROM (Read only memory).

Introduction COE 301– KFUPM slide 27


Primary Memory
❖ RAM (random access memory)
❖ It is also known as read write memory that allows CPU to read
as well as write data and instructions into it . RAM (random
access Memory) is used for the temporary storage of input data
,output data and immediate results. There are of two categories
of RAM are as follows :-

❖ Dynamic RAM (DRAM) .


❖ Static RAM (SRAM) .

Introduction COE 301– KFUPM slide 28


Primary Memory
❖ Dynamic RAM (DRAM)
❖ It is made up of memory cells where each cell is composed of
one capacitor and one transistor. DRAM must be refreshed
continually to store information . DRAM is slower less
expensive and occupies less space on the computer’s
motherboard. There are three types of DRAM :-

❖ SDRAM .
❖ RDRAM .
❖ DDR -SDRAM .

Introduction COE 301– KFUPM slide 29


Primary Memory
❖ Static RAM (SRAM)
❖ It retains the data as long as power is provided to the memory Chip . It needs not be refreshed
periodically . SRAM uses multiple transistors for each memory cell. It does not use capacitor.
SRAM is often used as cache memory due to its high speed. SRAM is more expensive than
DRAM.
❖ Advantages of RAM :-
❖ It is volatile memory.
❖ Fast data access.
❖ It can read and write.
❖ Stores dynamic data.
❖ Improve computer performance.
❖ Categorized by architecture and speed.
❖ Disadvantages of RAM:-
❖ Stores information temporarily.
❖ Should match with compatible motherboards.

Introduction COE 301– KFUPM slide 30


Primary Memory
❖ ROM (Read only memory):-
❖ It is also known as non volatile memory or permanent storage. It does not
lose its content when the power is switched off . ROM (read only memory
)has only read capability , no right capability . ROM can have data and
instructions written to it only one time. Once a ROM is programmed at the
time of manufacturing it cannot be reprogrammed or rewritten. There are
three categories of ROM as follows:-

❖ Programmable ROM (PROM) .


❖ Erasable programmable ROM (EPROM).
❖ Electrically erasable programmable ROM( EEPROM).

Introduction COE 301– KFUPM slide 31


Secondary Memory
❖ These types of memories are internal or external storage
devices are ideal inside or outside the computer. It store
programs and data permanently you can assess any time when
attached to the computer . You cannot store the data in primary
memory permanently and primary memory cost higher than
secondary. It is slower but cheaper. Floppy disk, hard drives
,Compact Disc (CD), Digital video disc (DVD)

Introduction COE 301– KFUPM slide 32


Secondary Memory
❖ Floppy Disc
A Floppy Disk Drive (FDD) is a computer disk drive that enables
a user to save data on removable diskettes. This portable storage
device is a re-writable media and can be reused a number of
times. It is made of plastic with magnetic coating on it. It is round
in shape and is covered by square plastic jacket. Floppy disks are
commonly used to move files between different computers.
However, today these drives are being replaced with CD-R and
other writable disc drives and flash drives. 5*1”/4 diameter-
floppy has a capacity of 1.2MB. 3*1″/4 has a capacity of 1.44
MB.

Introduction COE 301– KFUPM slide 33


Secondary Memory
❖ A hard disk drive (HDD)
Is a non volatile random access digital data storage device. It is a
data storage device used for storing and retrieving digital
information using rotating disc (platters) coated with magnetic
material. All programs of a computer are installed in hard disk
within a particular drive. Now a days there are use capacitive
hard-disk available in the market to store the data like 500gb,
1TB, 30TB and even greater.

Introduction COE 301– KFUPM slide 34

You might also like