Welcome To The World of Assembly Language Programming
Welcome To The World of Assembly Language Programming
Language Programming
By Hasan Murad
Lecturer,
Department of Computer Science and Engineering,
University of Asia Pacific
References
• Assembly Language Programming and
Organization of the IBM PC
--- Ytha Yu and Charles Marut
2
The Beginning !
• What is Assembly Language?
3
4
About Assembly
• Assembly is human-readable machine code
• Gives you complete control over the system's
resources
5
Why use it ?
• Direct hardware manipulation
• Access to specialized processor instructions
• Performance and efficiency
• Speed optimization
• Control the code behavior
6
Disadvantages ☹
• Hard and tedious
• Bug-prone
• Non-portable(machine dependent)
• Difficult to debug
7
A question ?
• In what kind of situations, assembly language
will be the only solution?
• An Operating System
• Drivers and communication with custom
hardware/electronics.
• An Compiler
• Optimizations
8
Definition from wiki
• An assembly language is a low-level programming
language for a computer, or other programmable
device, in which there is a very strong
(generally one-to-one) correspondence between
the language and the architecture's machine
code instructions. Each assembly language is
specific to a particular computer architecture, in
contrast to most high-level programming
languages, which are generally portable across
multiple architectures, but
require interpreting or compiling.
9
Chapter 1
Microcomputer Systems
10
The Components of a Microcomputer
System
• Typical components
– System unit
– Keyboard
– Display Screen
– Disk drives
• Functionally three parts
– CPU
– Memory circuits
– I/O circuits
11
12
Memory
• Bytes and Words
• Bit position
• Memory operations
• RAM and ROM
• Buses
13
14
CPU
15
16
I/O Ports
• Serial Ports
• Parallel Ports
17
Instruction Execution
• Fetch
– Fetch an instruction from memory
– Decode it
– Fetch data if needed
• Execute
– Perform operation on data
– Store result if needed
18
Instruction Execution
• The Process of executing an instruction
– 00000001 00000110 00000000
ADD AX Memory
operation Register Address
00000000
19
I/O Devices
• Magnetic Disks
• Keyboard
• Display Monitor
• Printers
20
• What is Emulator?
• In computers an emulator is a hardware
device or a program that pretends to be
another particular device or program.
• Example : emu8086, DOSBox 0.74
21
Simulator VS Emulator
• A simulator provides a fast and easy way to
set up a software environment for application
testing purposes without mimicking actual
hardware. An emulator takes things a step
further by emulating software as well as
hardware configurations.
22
Chapter 2
REPRESENTATION OF NUMBERS
AND CHARACTERS
23
Number Systems
• Binary Number System
• Hexadecimal Number System
• Decimal Number System
24
Conversion Between Number Systems
• Converting Binary and Hex to Decimal
• Converting Decimal to Binary and Hex
• Conversions between Hex and Binary
25
Addition and Subtraction
• Hexadecimal Addition Table
26
How integers are represented in the
Computer
• Unsigned integers
• Signed integers
– One’s complement
– Two’s complement
• Decimal Interpretation
27
Character Representation
• ASCII ( American Standard Code for
Information Interchange) code
• Normally 128 ASCII Codes
• 32-126 are printable
• 0 to 31 and 127 for control purposes
• For Extended set, there are 256 characters
28
Chapter 3
ORGANIZATION OF THE IBM
PERSONAL COMPUTERS
29
The Intel 8086 Family of
Microprocessors
• The 8086 and 8088 Microprocessors
• The 80186 and 80188 Microprocessors
• The 80286 Microprocessor
• The 80386 and 80386SX Microprocessors
• The 80486 and 80486SX Microprocessors
30
Organization of the 8086/8088
Microprocessors
• Registers
– 3 Types of registers
• Data Registers
• Address Registers
• Status Register
31
Data Registers
• AX (Accumulator Register)
• BX (Base Register)
• CX (Count Register)
• DX (Data Register)
32
Data Registers
33
Segment Registers(Address Registers)
34
Pointer and Index Registers, Instruction
pointers (Address Registers)
35
Segment Registers
• Memory Segment
• Segment: Offset Address
• Location of Segments
37
Overlapping Scenario
38
• If you have a segment A4FBh and offset
4872h. Then what is the 20 bit physical
address?
A4FB0h
+4872h
-------------
A9822h ( 20 bit physical address)
39
Organization of the PC
• The Operating System
– DOS (Disk Operating System)
• BIOS (Basic Input/Output System)
40
Memory Organization of the PC
• 8086/8088 has only 1MB of memory
• Not all memory for application programs
• Interrupt Vector, Video Display Memory etc
are needed
• IBM fixed all the positions and allowed all to
live happily
41
42
43
I/O ports addresses
• Interrupt controller (20h-21h)
• Keyboard controller (60h-63h)
• etc...
44
Start-up Operation
• Boot program
45
46