SlideShare a Scribd company logo
Assembly Language for x86 Architecture
Ahmed M. Abed
Teaching Assistant – Islamic University of Gaza

aabed91@gmail.com
Agenda
•
•
•
•
•
•

Introduction
What is Assembly Language?
Why Assembly?
Basic Concepts
x86 Architecture Details
Basic Program Execution Registers

•
•
•
•

General-Purpose Registers
Segment Registers
EFLAGS Register
Status Flag
Introduction
• Each personal computer has a microprocessor that manages the computer's
arithmetical, logical and control activities.

• Each family of processors has its own set of instructions for handling various
operations.

•

getting input from keyboard - displaying information on screen-performing various
other jobs

• These set of instructions are called 'machine language instruction'
Introduction
• Processor understands only machine language instructions which are strings
of 1s and 0s.

• The low level assembly language is designed for a specific family of
processors that represents various instructions in symbolic code and a more
understandable form.
What is Assembly

• An assembly language is a low-level programming language for a computer,
or other programmable device.

• Assembly language is converted into executable machine code by a utility
program referred to as an assembler.
Why Assembly?
• An understanding of assembly language provides knowledge of:
•
•
•
•

Interface of programs with OS, processor and BIOS.
Representation of data in memory and other external devices.
How processor accesses and executes instruction.

How instructions accesses and process data
Why Assembly?

• It requires less memory and execution time
• It allows hardware-specific complex jobs in an easier way
• It is most suitable for writing interrupt service routines and other memory
resident programs
PC Hardware
• The main internal hardware of a PC consists of the processor, memory and
the registers.

•

The registers are processor components that hold data and address.

• To execute a program the system copies it from the external device into the
internal memory.

• The processor executes the program instructions
Instruction executions

• Fetching the instruction from memory
• Decoding or identifying the instruction
• Executing the instruction
Data Size
• The processor supports the following data sizes:
•
•
•
•

Word: a 2-byte data item
Double word: a 4-byte (32 bit) data item
Quad word: an 8-byte (64 bit) data item
Paragraph: a 16-byte (128 bit) area
x86 Architecture Details
• x86 processors have three primary modes of operation:
•

protected mode.

•

•
•

Virtual-8086 , is a special case of protected mode

real-address mode.

system management mode.
Protected Mode
• Protected mode is the native state of the processor, in which all instructions
and features are available.

• Programs are given separate memory areas named segments.
• The processor prevents programs from referencing memory outside their
assigned segments.
Real-Address Mode
• Real-address mode implements the programming environment of the Intel
8086 processor with a few extra features, such as the ability to switch into
other modes.

• Can be used to run an MS-DOS program that requires direct access to
system memory and hardware devices.

• Programs running in real-address mode can cause the operating system to
crash.
System Management Mode
• System Management mode (SMM) provides an operating system with a
mechanism for implementing functions such as power management and
system security.

• These functions are usually implemented by computer manufacturers who
customize the processor for a particular system setup.
Virtual-8086 Mode
• While in protected mode, the processor can directly execute real-address
mode software such as MS-DOS programs in a safe multitasking
environment.

• In other words, if an MS-DOS program crashes or attempts to write data
into the system memory area, it will not affect other programs running at
the same time.
Basic Program Execution Registers
• Registers are high-speed storage locations directly inside the CPU, designed
to be accessed at much higher speed than conventional memory.

•
•
•
•

There are eight general-purpose registers
Six segment registers
Processor status flags register (EFLAGS)
Instruction pointer (EIP).
Basic Program Execution Registers
General-purpose registers
• The general-purpose registers are primarily used for arithmetic and data
movement.
General-purpose registers
General-purpose registers
• Some general-purpose registers have specialized uses:
•

•
•
•
•

EAX is automatically used by multiplication and division instructions. It is often called
the extended accumulator register.
The CPU automatically uses ECX as a loop counter.
ESP addresses data on the stack. It is rarely used for ordinary arithmetic or data
transfer. It is often called the extended stack pointer register.
ESI and EDI are used by high-speed memory transfer instructions. They are sometimes
called the extended source index and extended destination index registers.
EBP is used by high-level languages to reference function parameters and local
variables on the stack. It should not be used for ordinary arithmetic or data transfer
except at an advanced level of programming. It is often called the extended frame
pointer register.
Segment Registers

• In real-address mode, 16-bit segment registers indicate base addresses of
preassigned memory areas named segments.

• In protected mode, segment registers hold pointers to segment descriptor
tables.
Instruction Pointer

• The EIP, or instruction pointer, register contains the address of the next
instruction to be executed.
EFLAGS Register

• The EFLAGS (or just Flags) register consists of individual binary bits that
control the operation of the CPU or reflect the outcome of some CPU
operation
Status Flags

• The Status flags reflect the outcomes of arithmetic and logical operations
performed by the CPU. They are the Overflow, Sign, Zero, Auxiliary Carry,
Parity, and Carry flags.
Status Flags
•
•
•
•
•

•

The Carry flag (CF) is set when the result of an unsigned arithmetic operation is too large to
fit into the destination.
The Overflow flag (OF) is set when the result of a signed arithmetic operation is too large or
too small to fit into the destination.
The Sign flag (SF) is set when the result of an arithmetic or logical operation generates a
negative result.
The Zero flag (ZF) is set when the result of an arithmetic or logical operation generates a
result of zero.
The Auxiliary Carry flag (AC) is set when an arithmetic operation causes a carry from bit 3 to
bit 4 in an 8-bit operand.
The Parity flag (PF) is set if the least-significant byte in the result contains an even number
of 1 bits. Otherwise, PF is clear. In general, it is used for error checking when there is a
possibility that data might be altered or corrupted.
x86 Memory Management

• x86 processors manage memory according to the basic modes of operation.
• Protected mode is the most robust and powerful, but it does restrict
application programs from directly accessing system hardware.
Real-Address Mode
• Only 1 MByte of memory can be addressed, from hexadecimal 00000 to
FFFFF.

• The processor can run only one program at a time.
• Application programs are permitted to access any memory location,
including addresses that are linked directly to system hardware.

• The MS-DOS operating system runs in real-address mode
Protected Mode
• The processor can run multiple programs at the same time.
• It assigns each process (running program) a total of 4 GByte of memory.
• Each program can be assigned its own reserved memory area
• Programs are prevented from accidentally accessing each other’s code and
data

More Related Content

What's hot (20)

PPS
Computer instructions
Anuj Modi
 
PPTX
Computer registers
DeepikaT13
 
PPT
Instruction Set Architecture (ISA)
Gaditek
 
PPTX
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
PPT
Cpu organisation
Er Sangita Vishwakarma
 
PPTX
Instruction cycle with interrupts
Shubham Jain
 
PPTX
Pipelining and vector processing
Kamal Acharya
 
PPTX
Types of Instruction Format
Dhrumil Panchal
 
PPTX
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
ATUL KUMAR YADAV
 
PDF
hardwired control unit ppt
SushmithaAcharya7
 
PPTX
instruction cycle ppt
sheetal singh
 
PPTX
ADDRESSING MODES
Sadaf Rasheed
 
PPT
Assembly language programming(unit 4)
Ashim Saha
 
PPTX
Control unit
Piyush Rochwani
 
PPTX
memory hierarchy
sreelakshmikv
 
PPTX
CISC & RISC Architecture
Suvendu Kumar Dash
 
PPT
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
PPTX
Instruction Cycle in Computer Organization.pptx
Yash346903
 
PPTX
Instruction Formats
RaaviKapoor
 
PPT
Data transfer and manipulation
Sanjeev Patel
 
Computer instructions
Anuj Modi
 
Computer registers
DeepikaT13
 
Instruction Set Architecture (ISA)
Gaditek
 
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Cpu organisation
Er Sangita Vishwakarma
 
Instruction cycle with interrupts
Shubham Jain
 
Pipelining and vector processing
Kamal Acharya
 
Types of Instruction Format
Dhrumil Panchal
 
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
ATUL KUMAR YADAV
 
hardwired control unit ppt
SushmithaAcharya7
 
instruction cycle ppt
sheetal singh
 
ADDRESSING MODES
Sadaf Rasheed
 
Assembly language programming(unit 4)
Ashim Saha
 
Control unit
Piyush Rochwani
 
memory hierarchy
sreelakshmikv
 
CISC & RISC Architecture
Suvendu Kumar Dash
 
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
Instruction Cycle in Computer Organization.pptx
Yash346903
 
Instruction Formats
RaaviKapoor
 
Data transfer and manipulation
Sanjeev Patel
 

Viewers also liked (20)

PPT
Assembly Language Lecture 1
Motaz Saad
 
PPT
Assembly Language Lecture 5
Motaz Saad
 
PPT
Types of instructions
ihsanjamil
 
PPT
Assembly Language Lecture 2
Motaz Saad
 
PDF
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
PPT
Computer Organization and Assembly Language
fasihuddin90
 
PPT
Assembly Language Programming Of 8085
techbed
 
PPT
Assembly Language Lecture 4
Motaz Saad
 
PPTX
Microprocessor chapter 9 - assembly language programming
Wondeson Emeye
 
PPT
Assembly Language Lecture 3
Motaz Saad
 
PDF
Assembly language 8086
John Cutajar
 
PPT
8086 assembly language
Mir Majid
 
PPT
Instruction codes and computer registers
Sanjeev Patel
 
PPTX
Computer instruction
Sanjeev Patel
 
PPTX
Register & Memory
Education Front
 
PDF
Instruction code
Dr. Abhineet Anand
 
PPTX
Conditional jump
Sandeep Kamath
 
PDF
8086 microprocessor lab manual
University of Technology - Iraq
 
PDF
Various type of register
Muhammad Taqi Hassan Bukhari
 
PDF
Microprocessor lecture 2
Md. Murshedul Arifeen
 
Assembly Language Lecture 1
Motaz Saad
 
Assembly Language Lecture 5
Motaz Saad
 
Types of instructions
ihsanjamil
 
Assembly Language Lecture 2
Motaz Saad
 
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
Computer Organization and Assembly Language
fasihuddin90
 
Assembly Language Programming Of 8085
techbed
 
Assembly Language Lecture 4
Motaz Saad
 
Microprocessor chapter 9 - assembly language programming
Wondeson Emeye
 
Assembly Language Lecture 3
Motaz Saad
 
Assembly language 8086
John Cutajar
 
8086 assembly language
Mir Majid
 
Instruction codes and computer registers
Sanjeev Patel
 
Computer instruction
Sanjeev Patel
 
Register & Memory
Education Front
 
Instruction code
Dr. Abhineet Anand
 
Conditional jump
Sandeep Kamath
 
8086 microprocessor lab manual
University of Technology - Iraq
 
Various type of register
Muhammad Taqi Hassan Bukhari
 
Microprocessor lecture 2
Md. Murshedul Arifeen
 
Ad

Similar to Part I:Introduction to assembly language (20)

PPTX
Lecture_3.1 Registers.pptx....................
XEON14
 
PDF
nasm_final
Muhammed Yazar Y
 
PPTX
amr_systemsdadwdsdasdsadsadsaaddsdw.pptx
ahmadtomizi95
 
PPTX
Coal (1)
talhashahid40
 
PPT
x86_1.ppt
jeronimored
 
PDF
CNIT 126 4: A Crash Course in x86 Disassembly
Sam Bowne
 
PPT
chapt_02.ppt
Ranaqamar6
 
PPT
microprocessor and its application with practical gaining.ppt
Prashantyelekar
 
PPTX
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Sam Bowne
 
PPTX
301 8086 (1) 301 8086 (1) 301 8086 (1) 301 8086 (1)
alcaidemariacecilia
 
PPTX
X86 Architecture
IGZ Software house
 
PPTX
It322 intro 1
J Cza Àkera
 
DOCX
digital communication,micro processor,pulse and digital circuits
Manasa Mona
 
PPTX
Assembly language.pptx
ShaistaRiaz4
 
PPT
microprocessor
ATTO RATHORE
 
DOC
8086 handout for chapter one and two
haymanotyehuala
 
DOC
8051 microcontroller
haymanotyehuala
 
PDF
8086 Microprocessor
Vijay Kumar
 
PPTX
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
Md. Hasnat Shoheb
 
Lecture_3.1 Registers.pptx....................
XEON14
 
nasm_final
Muhammed Yazar Y
 
amr_systemsdadwdsdasdsadsadsaaddsdw.pptx
ahmadtomizi95
 
Coal (1)
talhashahid40
 
x86_1.ppt
jeronimored
 
CNIT 126 4: A Crash Course in x86 Disassembly
Sam Bowne
 
chapt_02.ppt
Ranaqamar6
 
microprocessor and its application with practical gaining.ppt
Prashantyelekar
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Sam Bowne
 
301 8086 (1) 301 8086 (1) 301 8086 (1) 301 8086 (1)
alcaidemariacecilia
 
X86 Architecture
IGZ Software house
 
It322 intro 1
J Cza Àkera
 
digital communication,micro processor,pulse and digital circuits
Manasa Mona
 
Assembly language.pptx
ShaistaRiaz4
 
microprocessor
ATTO RATHORE
 
8086 handout for chapter one and two
haymanotyehuala
 
8051 microcontroller
haymanotyehuala
 
8086 Microprocessor
Vijay Kumar
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
Md. Hasnat Shoheb
 
Ad

Recently uploaded (20)

PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Part I:Introduction to assembly language

  • 1. Assembly Language for x86 Architecture Ahmed M. Abed Teaching Assistant – Islamic University of Gaza [email protected]
  • 2. Agenda • • • • • • Introduction What is Assembly Language? Why Assembly? Basic Concepts x86 Architecture Details Basic Program Execution Registers • • • • General-Purpose Registers Segment Registers EFLAGS Register Status Flag
  • 3. Introduction • Each personal computer has a microprocessor that manages the computer's arithmetical, logical and control activities. • Each family of processors has its own set of instructions for handling various operations. • getting input from keyboard - displaying information on screen-performing various other jobs • These set of instructions are called 'machine language instruction'
  • 4. Introduction • Processor understands only machine language instructions which are strings of 1s and 0s. • The low level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.
  • 5. What is Assembly • An assembly language is a low-level programming language for a computer, or other programmable device. • Assembly language is converted into executable machine code by a utility program referred to as an assembler.
  • 6. Why Assembly? • An understanding of assembly language provides knowledge of: • • • • Interface of programs with OS, processor and BIOS. Representation of data in memory and other external devices. How processor accesses and executes instruction. How instructions accesses and process data
  • 7. Why Assembly? • It requires less memory and execution time • It allows hardware-specific complex jobs in an easier way • It is most suitable for writing interrupt service routines and other memory resident programs
  • 8. PC Hardware • The main internal hardware of a PC consists of the processor, memory and the registers. • The registers are processor components that hold data and address. • To execute a program the system copies it from the external device into the internal memory. • The processor executes the program instructions
  • 9. Instruction executions • Fetching the instruction from memory • Decoding or identifying the instruction • Executing the instruction
  • 10. Data Size • The processor supports the following data sizes: • • • • Word: a 2-byte data item Double word: a 4-byte (32 bit) data item Quad word: an 8-byte (64 bit) data item Paragraph: a 16-byte (128 bit) area
  • 11. x86 Architecture Details • x86 processors have three primary modes of operation: • protected mode. • • • Virtual-8086 , is a special case of protected mode real-address mode. system management mode.
  • 12. Protected Mode • Protected mode is the native state of the processor, in which all instructions and features are available. • Programs are given separate memory areas named segments. • The processor prevents programs from referencing memory outside their assigned segments.
  • 13. Real-Address Mode • Real-address mode implements the programming environment of the Intel 8086 processor with a few extra features, such as the ability to switch into other modes. • Can be used to run an MS-DOS program that requires direct access to system memory and hardware devices. • Programs running in real-address mode can cause the operating system to crash.
  • 14. System Management Mode • System Management mode (SMM) provides an operating system with a mechanism for implementing functions such as power management and system security. • These functions are usually implemented by computer manufacturers who customize the processor for a particular system setup.
  • 15. Virtual-8086 Mode • While in protected mode, the processor can directly execute real-address mode software such as MS-DOS programs in a safe multitasking environment. • In other words, if an MS-DOS program crashes or attempts to write data into the system memory area, it will not affect other programs running at the same time.
  • 16. Basic Program Execution Registers • Registers are high-speed storage locations directly inside the CPU, designed to be accessed at much higher speed than conventional memory. • • • • There are eight general-purpose registers Six segment registers Processor status flags register (EFLAGS) Instruction pointer (EIP).
  • 18. General-purpose registers • The general-purpose registers are primarily used for arithmetic and data movement.
  • 20. General-purpose registers • Some general-purpose registers have specialized uses: • • • • • EAX is automatically used by multiplication and division instructions. It is often called the extended accumulator register. The CPU automatically uses ECX as a loop counter. ESP addresses data on the stack. It is rarely used for ordinary arithmetic or data transfer. It is often called the extended stack pointer register. ESI and EDI are used by high-speed memory transfer instructions. They are sometimes called the extended source index and extended destination index registers. EBP is used by high-level languages to reference function parameters and local variables on the stack. It should not be used for ordinary arithmetic or data transfer except at an advanced level of programming. It is often called the extended frame pointer register.
  • 21. Segment Registers • In real-address mode, 16-bit segment registers indicate base addresses of preassigned memory areas named segments. • In protected mode, segment registers hold pointers to segment descriptor tables.
  • 22. Instruction Pointer • The EIP, or instruction pointer, register contains the address of the next instruction to be executed.
  • 23. EFLAGS Register • The EFLAGS (or just Flags) register consists of individual binary bits that control the operation of the CPU or reflect the outcome of some CPU operation
  • 24. Status Flags • The Status flags reflect the outcomes of arithmetic and logical operations performed by the CPU. They are the Overflow, Sign, Zero, Auxiliary Carry, Parity, and Carry flags.
  • 25. Status Flags • • • • • • The Carry flag (CF) is set when the result of an unsigned arithmetic operation is too large to fit into the destination. The Overflow flag (OF) is set when the result of a signed arithmetic operation is too large or too small to fit into the destination. The Sign flag (SF) is set when the result of an arithmetic or logical operation generates a negative result. The Zero flag (ZF) is set when the result of an arithmetic or logical operation generates a result of zero. The Auxiliary Carry flag (AC) is set when an arithmetic operation causes a carry from bit 3 to bit 4 in an 8-bit operand. The Parity flag (PF) is set if the least-significant byte in the result contains an even number of 1 bits. Otherwise, PF is clear. In general, it is used for error checking when there is a possibility that data might be altered or corrupted.
  • 26. x86 Memory Management • x86 processors manage memory according to the basic modes of operation. • Protected mode is the most robust and powerful, but it does restrict application programs from directly accessing system hardware.
  • 27. Real-Address Mode • Only 1 MByte of memory can be addressed, from hexadecimal 00000 to FFFFF. • The processor can run only one program at a time. • Application programs are permitted to access any memory location, including addresses that are linked directly to system hardware. • The MS-DOS operating system runs in real-address mode
  • 28. Protected Mode • The processor can run multiple programs at the same time. • It assigns each process (running program) a total of 4 GByte of memory. • Each program can be assigned its own reserved memory area • Programs are prevented from accidentally accessing each other’s code and data