CSCS 323: Course Title Course Code Credits Instructor
CSCS 323: Course Title Course Code Credits Instructor
CSCS 323: Course Title Course Code Credits Instructor
Credits
Instructor
Assembly Language Programming and Organization of the IBM PC by Ytha Yu and Charles Marut (McGraw-Hill)
ihs/CSCS323/Spring 2012
A Computer System
What is a computer? A computer is an electronic machine which can read, store, retrieve, process and display information. What is a Computer System? A computer system consists of two major components:
1.
2.
Hardware It consists of circuits which can read, store, retrieve, process and display information. Software It consists of programs which:
a. b.
drive the computer (Operating System) facilitate users to perform specific jobs such as word processing
(Application Software).
ihs/CSCS323/Spring 2012
Number Systems
A number system consists of digits. The number of digits in a number system is called its base. The following four number systems are commonly used. Number System Decimal Binary Octal Hexadecimal Digits 0-9 0,1 (bits) 0-7 0-9, A-F (A=10, F=15) Base 10 2 8 16
ihs/CSCS323/Spring 2012
2
2 2 2 2
11 1
5 1 2 1 1 0 0 1
Base
(23)10 = (10111)2
ihs/CSCS323/Spring 2012
Example:
(10111)2 = 1*20 + 1*21 + 1*22 + 0*23 + 1*24 = (23)10
ihs/CSCS323/Spring 2012
Representation of Numbers
(10111)2 is binary number; it can also be written as 10111b or 10111B where b or B indicate that the preceding number is binary. Similarly, H or h are used to represent a hexadecimal number, D or d are used to represent a decimal number & O or o are used to represent an octal number.
ihs/CSCS323/Spring 2012
(37)10 = (25)16
02
ihs/CSCS323/Spring 2012
EX. Convert the following hex. numbers to their binary equivalents and check the result: 0A7Dh, 48GDh
ihs/CSCS323/Spring 2012
10001100b = 8Ch EX. Convert the following hex. numbers to their binary equivalents and check the result: 0A7Dh, 48GDh
ihs/CSCS323/Spring 2012
10
ihs/CSCS323/Spring 2012
11
Language of Computer
A computer understands machine language only. In this language, everything is expressed in terms of 0s and 1s (Bit Patterns). The bit The bit stands for a binary digit, and it can be either 0 or 1. A bit cannot store much information. To store meaningful information, we use a collection of 8, 16, 32, bits. The Byte A collection of 8 bits is called a Byte. It can store a character in some way and is also called a cell. The Word A word can be 1, 2, 4, 8, bytes is called a word.
ihs/CSCS323/Spring 2012
12
Representation of Information
The information consists of letters, digits, punctuation symbols and other symbols; these are called characters. A unique integer code has been assigned to each character; inside
ihs/CSCS323/Spring 2012
13
Exercise
How is information represented inside the computer. Write a detailed note on different coding Systems.
ihs/CSCS323/Spring 2012
14
ihs/CSCS323/Spring 2012
15
Logic instructions
o o Logic instructions can be used to change individual bits in the computer The truth tables for the logic operators AND, OR, XOR & NOT shown in fig. Here a, b are logic / bit variables whose values cab be 0 (false),1(true)
a AND b
a OR b
a XOR b
0
0 1 1
0
1 0 1
a 0 1
0
0 0 1
NOT a 1 0
0
1 1 1
0
1 1 0
ihs/CSCS323/Spring 2012
16
a F F
b F T
a AND b F F
a OR b F T
a XOR b F T
T
T
F
T
F
T
T
T
T
F
a F T
NOT a T F
ihs/CSCS323/Spring 2012 17
ihs/CSCS323/Spring 2012
18
To output, the CPU places data in the port from where the output
device reads it.
ihs/CSCS323/Spring 2012
19
ihs/CSCS323/Spring 2012
20
Execute
ihs/CSCS323/Spring 2012
21
The Clock
To ensure that all the steps required to execute a machine language instruction are performed in an order, a clock circuit controls the processor by generating a train of pulses. Period interval between two pulses Clock speed No. of pulses generated per second (Unit: Hz, MHz, GHz) o The 8086 processor had a clock speed of 4.77 MHz o Now speed are in GHz. The processing speed depends upon the clock speed.
<----Period---->
Computer circuits are activated by clock pulses. Each step in Fetch-Execute cycle requires one or more clock pulses; e.g. 8086 processor takes 4 pulses to perform a read operation and 70 pulses to perform a multiplication operation.
ihs/CSCS323/Spring 2012
22
Programming Languages
Machine Language
The computer can execute a program written in machine language only. In Machine Language, operations and operands are expressed in terms of 0s and 1s (bit patterns). Example:
Instruction
00000101 00000100 00000000
Meaning
Add 4 to AX and store the result in AX
ihs/CSCS323/Spring 2012
23
Disadvantaes of Assembly language? Instructions are very primitive; not suitable for writing large programs. What is solution then? High Level Languages (Fortran, Pascal, C, C++, Java, have been invented.
High Level languages Ex. Point out distinguishing feature of High Level languages.
ihs/CSCS323/Spring 2012
24
ihs/CSCS323/Spring 2012
25
Type of registers:
Register Data registers Address registers
Flags register
ihs/CSCS323/Spring 2012
26
ihs/CSCS323/Spring 2012
27
Special Function
It is preferred to be used in arithmetic, logic and data transfer instructions because its use generates shortest machine code. Also used in I/O and multiplication & division operations Used as address register; e.g. in XLATE instruction. Used as a counter in LOOP and REP (repeat) instructions and string operations.
DX (Data register)
ihs/CSCS323/Spring 2012
28
Segment Registers
The segment registers are used to store RAM addresses of instructions and of data The processor uses these addresses to access the memory locations. The 8086 processor used 20 bit address to each byte in its 1 MB RAM; these are called physical addresses. The size of each segment register is 16 bit and cannot accommodate 20 bit address.
What is solution?
o o Divide the 20 bit physical address into two components and load each component in a separate register. For this purpose main memory is divided into segments.
ihs/CSCS323/Spring 2012
29
Segments
What is a segment?
o A segment is a contiguous block of 216 bytes (64 KB) of RAM so that the address size of each of its bytes is 16 bit. The byte number within the segment is called offset. Each segment is identified by a 16-bit segment number. Address of each byte has two parts: 1. segment number 2. offset.
o o
Example: 02AB : 0255H is a logical Address, where, 02AB is segment number, 0255 is offset H indicates that these numbers are Hexadecimal.
ihs/CSCS323/Spring 2012 30
2. Add offset (expressed in Hex) to it. The physical address corresponding to 02AB : 0255H is: 02AB0 + 02 5 5 02D05
ihs/CSCS323/Spring 2012
31
Show that segments are overlapping. What is minimum size of a segment and why? How can the size of segment be increased? What is maximum size of a segment and why?
ihs/CSCS323/Spring 2012
32
CS DS SS ES
ihs/CSCS323/Spring 2012
33
Flags Register
9 out of its 16 bits are used as flags. Six bit (0, 2, 4, 6, 7 and 11) represent status flags Three bits (8,9,10) represent control flags Six status flags reflect the result of the preceding instruction; if result of the preceding instruction is zero then the flag ZF is made 1 (true). Three control flags enable or disable certain operations of the processor; e.g. if the interrupt flag IF is made zero then the input from the keyboard is ignored by the processor.
ihs/CSCS323/Spring 2012
34