INHA UNIVERSITY INCHEON, KOREA http:// eslab.inha.ac.kr/ IBM PC Assembly Language and Programming by Peter Abel Chapter 1: Basic Feature of PC hardware Mohammed Nazim uddin( 나나 ) Email:[email protected] 1210 Hi-tech centre.
INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
IBM PC Assembly Language and Programming by Peter Abel
Chapter 1: Basic Feature of PC hardware
Mohammed Nazim uddin( 나짐 )
Email:[email protected] Hi-tech centre.
- 2 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Hardware Features
Internal Hardware Processor Memory Register
External hardware Keyboard Monitor Disk CD-ROM
- 3 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Bits and Bytes
Bits The fundamental building block of computer storage is Bit. A bit may be
• Off 0• On 1
- 4 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Bytes A group of nine related bits
• The eight data bits provide the basis for binary arithmetic and characters
256(28) – (00000000 ~ 11111111)• One Bit parity.
Rules of Parity• Must be odd in each byte
00001010 00001010(1)
Represents a storage Location
- 5 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Related Bytes Word
• 2-Byte(16-bit) Double Word
• 4-Byte(32-bit) Quadword
• 8-Byte(64-bit) Paragraph
• 16-byte(128) Kilobyte(KB)
Megabyte(MB)
- 6 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Number system
Binary Base 2 (0,1)
Binary to Decimal 01000001
• Bits are numbered from the right to left. b8b7b6b5b4b3b2b1b0
• Subscripts represent the place value, e.g. b6 has place value 26
• Conversion to decimal is done by evaluating the polynomial b8*28+ b7*27 + b6*26 + b5*25 +b4*24 +b3*23 +b2*22 +b1*21 + b0*20
In this case, 0+64+0+0+0+0+0+1 = 65
- 7 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Decimal Base 10( 0 to 9)
Decimal to Binary Divided by 2 Stop when 0 Concatenate the Remainder is reverse order
Example 65 1000001
65 / 2 = 32 r 132 / 2 = 16 r 016 / 2 = 8 r 08 / 2 = 4 r 04 / 2 = 2 r 02 / 2 = 1 r 01 / 2 = 0 r 1
- 8 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
HEXADECIMAL Base 16(0 to 9, A..F)
Binary to Hex Group bits by fours (start-
ing with least significant bits)
Add leading zeros as necessary to complete the last group
Convert each group to the equivalent hex digit
0100 1110b = 4Eh
Hex to Binary Expand each hex digit to
the equivalent 4-bit bi-nary form
• You may omit leading zeros of leftmost digit
37h = 0011 0111b (or 110111b)
- 9 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Character Data
American Standard Code for Information Interchange (ASCII) A 7-bit binary code for a set of 128 characters Usually occupy a byte of storage
• Leading bit may be ignored or used differently by various programs
A sequence of bytes containing ASCII codes is referred to as an ASCII string
- 10 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Numeric Data
Binary storage two’s complement, one’s complement, sign and magni-
tude, or biased representations
ASCII storage sequence of ASCII bytes representing the digits of the
number expressed in some radix
Binary Coded Decimal sequence of nybbles representing digits 0-9 of the number
- 11 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Binary Storage
A pre-arranged storage size is used typically byte, word, doubleword, or quadword
Represent a number in base two and en-code the bits 197d is 11000101b
• at least 8 bits will be required to store this number (leading zeros are added if necessary to fill additional bits for larger storage sizes)
- 12 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Signed vs Unsigned Codes
Unsigned Byte all 8 bits used to repre-
sent the magnitude of the number
Minimum 0 (zero) is coded as 00000000b
Maximum 255 is coded as 11111111b
Signed Byte two’s complement
code is most common only 7 bits are used for
the magnitude Minimum -128 is
coded as 10000000b Maximum +127 is
coded as 01111111b Zero is 00000000b
- 13 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Storage Sizes and Ranges
Unsigned Integer Byte
0 to 255 Word
0 to 65,535 Doubleword
0 to 4,294,967,295 Quadword
0 to 18,446,744,073,709,551,615
Signed (2’s Complement Code)
Byte -128 to 127
Word -32,768 to 32,767
Doubleword -2,147,483,648 to 2,147,483,647
Quadword -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
- 14 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Binary Arithmetic
Addition Numbers can be added
in any number base Use the same algorithm
you practiced in second grade!
Binary Example: c c c c
10101+ 1111100100
0+0 = 00+1 = 11+0 = 11+1 = 10
1+1+1 = 11
- 15 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Negative Binary Number A negative binary value is expressed in
Two’s complement notation. Two’s complement
• Reverse the bit• Add 1
Example: +65 Reverse bits
Add 1
Number -65
0100000110111110 1
10111111
- 16 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Subtraction How to Subtract 42 from 65 ?
65 : +(-43) : = 22
- 17 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
PC Components
System Board Processor, main memory, connectors, hard disk, etc…
Bus A bus with wires attached to the system board connects
the components.
Processor 8088,8086,80286….Pentium
Execution and Bus control unit
- 18 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
AH AL
BH BL
CH CL
DH DL
SP
BP
SI
DI
CS
DS
SS
ES
1
2
3
4
ALU------CU------FLAG
n
BUS control unit
Instruction pointer
||||||||||||||||||||
Instruction Queue
EU: Execution Unit
Program con-trol
BIU: Bus interface Unit
.
.
Execution and Bus control Unit
- 19 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Intel 8086 Organization
Registers - storage locations found inside the processor for temporary storage of data Data Registers (16-bit)
• AX, BX, CX, DX Address Registers (16-bit)
• Segment registers: CS, SS, DS, ES• Pointer registers: SP, BP, IP• Index registers: SI, DI
Status (Flags) register (16-bit)
- 20 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Data Registers
The data registers may be used for general purposes, however each has special uses AX : Accumulator BX : Base CX : Count DX : Data
Each byte of the 4 data registers can be ac-cessed independently AH, AL, BH, etc. These are referred to as 8-bit registers, but remember they
are part of an existing register
- 21 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Memory
8086 - 1 megabyte of memory (220 bytes)Each byte is accessed by specifying an
address (00000h through FFFFFh)20-bit addresses must be formed from 16-
bits of information
- 22 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
0000000400
A0000
B0000
C0000
D0000
E0000
F0000
Interrupt VectorsBIOS and DOS Data
DOS
Application Program Area
Video
Reserved
BIOS
- 23 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Segment Registers
20-bit addresses are obtained by combin-ing two 16-bit registers, segment:offset Address = segment*16(10h)+offset
Example CS: 010C IP: 14D2 Address = 010C*10+14D2 = 010C0+14D2 Address =
02592Each segment is 64K, segments can start
at any paragraph boundary
- 24 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Program Segments
During program execution, the segment registers are only changed if memory not currently accessible in an active segment must be accessed
Program bytes are arranged into distinct segments for convenience CS -> segment containing machine instructions SS -> segment containing storage for the stack DS -> segment containing data values and storage ES -> segment for additional data or special memory operations
Programmers must be aware of this organization
- 25 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Instruction and Stack Pointers
IP contains the address of the next instruc-tion to be executed IP specifies an offset into the CS segment IP is not the operand of any instruction
SP points to the top item on the stack SP is an offset into the SS segment SP can be used as an operand in some instructions
- 26 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
BP and Index Registers
BP is a Base Pointer Specifies an offset into any segment, but most commonly
the Stack segmentSI and DI are called Index registers
They normally specify an offset into the Data segment, al-though they can be used as offsets into any segment
Sometimes they hold a number to be added to the address of an array (index)
- 27 -INHA UNIVERSITYINCHEON, KOREA
http://eslab.inha.ac.kr/
Flags
Individual bits are used to store the status of the microprocessor Bits are set or cleared as the result of many operations Bits may be affected indirectly (by the execution of an in-
struction) or directly by an instruction designed to access the status word.