4 Intro To Assembly 1
4 Intro To Assembly 1
(CS2523)
• Estimated sales of
250,000
1. Operating Systems:
Assembly language is often used in the
development of operating systems, as it
provides low-level access to the system's
hardware and is capable of executing
critical operations that are not possible
with higher-level languages.
Reasons for using Assembly Language
2. Device Drivers:
Assembly language is used to develop
device drivers, which are software
components that allow a computer to
interact with specific hardware devices.
Reasons for using Assembly Language
3. Embedded Systems:
Assembly language is widely used in the
development of embedded systems,
such as microcontrollers and other
specialized devices that have limited
processing power and memory.
Reasons for using Assembly Language
4. Performance-critical applications:
Assembly language can be used to
optimize performance-critical sections of
code in high-performance applications,
such as video games, simulations, and
scientific computing.
Reasons for using Assembly Language
5. Reverse Engineering:
Assembly language is often used in
reverse engineering, as it provides a
detailed understanding of the
underlying machine code and can be
used to analyze malware, debug
software, and study the internal
workings of operating systems and
other software.
Reasons for using Assembly Language
These were some examples of the real-world use of
assembly language.
00000000
00000001
Binary Vertical
Dimensions
Addresses
=
Of
Size of
00100100
Cells
00100101 20
Addressing Data in Memory
Intel Personal Computer (PC) addresses its memory
according to bytes. (Every byte has a unique
address beginning with 0)
23
Word Representation
• The instruction add ax,bx the value shown by the list file i.e. fir.lst is
01D8 this is a two byte instruction and 01 is the opcode of add and
the D8 shows two registers ie ax,bx
• Representation in Memory
Representation 1
Little Endian
MSB LSB
Notation
3 2 1 0
Representation 2
Big Endian
LSB MSB
Notation
0 1 2 3
Bus Interconnection Scheme
...ha?
Some buzz words
CISC – Complex Instruction Set Computers
• Refers to number and complexity of instructions
• Improvements was: Multiply and Divide
• The number of instruction increased from
• 45 on 4004 to:
• 246 on 8085
• 20,000 on 8086 and 8088
• What is a Bus?
• A communication pathway connecting two or more devices
• A number of channels in one bus
• e.g. 32 bit data bus is 32 separate single bit channels
Computer Organization
• Carries data
• Interrupt request
• Clock signals
Basic Computer Organization
Processor Memory
I/O
34
Basic Computer Organization
35
Basic Computer Organization
36
Basic Computer Organization
Address Bus
Data Bus
Processor Memory
Control Bus
37
Big and Yellow?
Pipelining
Registers
Inside The 8088/8086…pipelining
Pipelining
Two ways to make CPU process information faster:
Increase the working frequency – technology dependent
Change the internal architecture of the CPU
Pipelining is to allow CPU to fetch and execute at the same time
Inside The 8088/8086…pipelining
50
Registers
Registers:
1. Benefits of Registers.
2. Types of Registers.
3. General Purpose Registers.
52
CPU Architecture of 8086/8088c
53
CPU Architecture of 8086/8088c
The 8086/8088 microprocessor consists of four functional units.
1) Execution unit (EU): decodes and executes machine
instructions.
2) Arithmetic and logic unit (ALU): performs math and logical
data storage.
4) Bus interface unit (BIU): handles all communications with the
54
I/O via system bus and maintains instruction queue.
In the World of Computer,
Registers are no more like childhood notebooks…
55
Basic Computer Organization
REGISTERS
56
Registers in Assembly Language:
57
Basic Computer Organization
58
Houses:
Memory
Buses Allocations in
RAM
59
Main Memory OR RAM
Suppose this is a processor
Basic Computer Organization
60
To calculate the sum,
We first declare a variable.
By this, memory for variable is allocated in the memory
61
Basic Computer Organization
62
Communication via Buses
64
Memory has sent the first number
The following same procedure would repeat
to get the second number from memory
1. First message would be sent via Control Bus if we want to read a second
number.
2. At the same time, processor would send the address via Address Bus to tell that
from this address of memory, send me the number.
3. Then Memory would place the second number in the Data Bus.
What would happen to the first number which was already present in the Data Bus???
That first number would be wasted. As Data Bus now would have the second number.
So, that was the issue. When Data Bus would get second number, then the first number
would get vanished.
To calculate the sum of two numbers, processor would need two numbers at the same
time.
To solve this problems, registers were developed.
65
Registers
If processor has to take data from RAM, then how many steps
processor has to perform?
Processor send message via Control Bus, send address via Address
to RAM, and then processor waits for the RAM to send data via
Data Bus.
It is time saving for processor to get data directly from registers. So,
68
processing gets faster because of registers.
Inside The 8088/8086…registers
Types of Registers AX
To store information temporarily 16-bit register
AH AL
8-bit reg. 8-bit reg.
Category Bits Register Names
Extended Register
Word Register
EAX EBP AX BP AH AL
EBX ESI BX SI BH BL
ECX EDI CX DI CH CL
EDX ESP DX SP DH DL
Bits 16-31 Bits 8-15 Bits 0-7
OR Destination
CPU word size/ CPU width: It means how many no. of bits that can be
processed by CPU.
Size of Accumulator decides the size of CPU word size.
74
Common thing in General Purpose Registers:
All the General Purpose Registers can be used to take
inputs, to display outputs and to store intermediate results.
We store data in General Purpose Registers with the help of
instructions.
75
1. AX: Accumulator Register involves in each operation:
Also if we want to store address of other memory location, for this purpose again
accumulator can be used.
76
2. BX: Base Register:
Suppose you have created an Array “A” in the memory. Then name of the array
i.e. A would represent the starting address of the array. Starting address is also
known as Base Address. Base Address is used to store the starting address of any
Data Structure.
0 1 2 3 4 5
78
4. DX: Destination Register:
It is basically used for destinations. We can store the final output of the operations in it.