SlideShare a Scribd company logo
Assembly Language - Lab (2)
1
Agenda
What is Assembly Language?
Computer Organization
Main memory
Memory Modes:
 Real Mode (8086)
 Protected Mode (80386)
What is Assembly Language?
 Assembly Language is a low-level (machine‐level) programming
language that uses mnemonics instead of numeric codes (0’s, 1’s) to
simplify programming.
 For example, the instruction in machine language which means copy
the content from AX register to BX register is:
8B D8
While same instruction written in assembly is:
mov BX, AX
 Each statement in assembly code has a one-to-one relationship
with machine language instructions, in other words each statement
corresponds to a single machine code instruction.
3
 To run a program written in assembly language, we should have a
converter (or translator) which converts these labels and mnemonics
to their corresponding machine codes in 0’s and 1’s. This converter
is called an assembler.
4
Machine CodeAssemblerAssembly Code
To run a program
written in a high level
language we should
have a converter
called …..?
What is Assembly Language?
Computer Organization
Main
Memory
CPU
R2 R3R1
ALU
Control
unit
R4
Main Memory
 It is the place to store data (and instructions) temporarily.
 Each location (byte) in memory has content (value) and a unique
label (address).
 Often, memory is used in larger chunks than single bytes. As shown
below:
Main
Memory
Byte
Memory Modes:
Real Mode (8086) – 16 Bit Registers
CPU 8086
Register Size 16 bits
Main Memory 1 MByte
Program Segment 64 k
(220 𝑏𝑦𝑡𝑒)
Memory Modes:
Real Mode (8086) – 16 Bit Registers
4 General Purpose
 AX : Accumulator
 BX : Base
 CX: Count
 DX: Data
4 Index and Pointers
 DI: Destination Index
 SI : Source Index
 BP: Base Pointer
 SP : Stack pointer
 4 Segments registers
 DS: Data Segment.
 CS: Code Segment
 SS: Stack Segment
 ES: Extra Segment
 Instruction Pointers
 IP: Instruction Pointer
 Flags
 ZF , SF, OF, CF...
Memory Modes:
Real Mode (8086) – 16 Bit Registers
4 General Purpose
Each of these registers could be decomposed into two 8‐bit
registers.
AH and AL are dependent on AX. Changing AX’s value will change
AH and AL values and vice versa.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
Index and Pointers (SI, DI)
They are often used as pointers to memory items, but can be used
for other purposes as the general‐purpose registers. They cannot be
decomposed into 8‐bit registers.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
Index and Pointers (BP, SP)
They are used to point to data in the stack and are called the Base
Pointer and Stack Pointer, respectively.
Stack
BP
SP
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 4 Segments registers (CS, DS, SS, ES)
They keep the starting address of memory chunk used for different
parts of a program.
CS stands for Code Segment,
DS for Data Segment,
SS for Stack Segment, and
ES for Extra Segment. ES is used as a temporary segment register.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 Instruction Pointers (IP)
This register is used with the CS register to keep track of the
address of the next instruction to be executed by the CPU.
 Flags (ZF , SF, OF, CF...)
The FLAGS register stores important information about the results of
the last executed operation. This information is stored as individual
bits in this register. For example, there is a specific bit called the Zero
flag (Z flag). This Z flag is 1 if the result of the last operation was zero
otherwise Z flag is set to zero. Not all instructions modify the bits
in FLAGS.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 As shown before, memory in real mode (8086) is limited to only one
megabyte (220 bytes).
 Valid address range is from (in hex) 00000 to FFFFF. These addresses
require a 20‐bit number.
Will it fit in the
segment registers?
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 A program is often divided into 3 segments, which are Code, Data,
and Stack segments where its starting address is stored in segment
registers. And each of these segments must begins on a paragraph
boundary (i.e. its address is divisible by 16). Therefore, the starting
address of any segment always begins with four 0‐bits.
 In addition, an offset register is used to address memory locations
within each segment. The size of each segment is 64KB (𝟐 𝟏𝟔 𝒃𝒚𝒕𝒆) at
most.
Why?
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 To find the physical address (20‐bit) from segment‐offset pair, use the
following relation:
16 * segment register + offset register
 Multiplying by 16 is equivalent to left shifting the binary value 4 times. This
done to return the four 0 bits which not stored physically in the segment
register.
Why do we
multiply by
16?
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 Examples:
1. Segment Register: 047C
Offset Register: 0048
Physical address: 047C0 + 0048 = 04808
2. Segment Register: 047D
Offset Register: 0038
Physical address: 047D0 + 0038 = 04808
And we can also get the same address when we add 047E0 with
0028.
Same
address!
Memory Modes:
Real Mode (8086) – 16 Bit Registers
Disadvantages:
1. A single segment can only contain 64K of memory (the upper
limit of the 16‐bit offset register).
2. Each byte in memory does not have a unique segmented
address.
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
CPU 80386
Register Size 32 bits
Main Memory 4 Gbyte
Program Segment 4 Gbyte
(232 𝑏𝑦𝑡𝑒)
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
 In 386 CPU, registers become 32‐bit wide except segment
registers (selectors) remain 16‐bits as they are.
 Two new 16‐bit segment registers are also added, FS and GS.
 This extension made the single segment size up to 4GB.
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
So how does a segment register store the 32‐bit
address of memory?
 Segment register is interpreted differently in protected mode. It is
interpreted as an index into a descriptor table than a register
stores the starting address of the segment.
 Descriptor table: is a table containing physical addresses of all
segments beside some other information about these segments. It
is stored in memory and its location is stored in a special register.
(local or global)
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
.
.
.
16 bits CS Register
32 bits Address of the CS in
Memory
Main
Memory
Descriptor Table
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
 As explained before, this mode allows the program segment to be
of size 4GB, so only one segment of only one program can take the
whole memory size to its own?
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
 For that problem protected mode uses a technique called virtual
memory.
 The basic idea of virtual memory system is to only keep the data and
code in physical memory that programs are currently using.
 Other data and code are stored temporarily on disk until they are
needed again.
Memory Modes:
Protected Mode (80386) – 32 Bit Registers
 Furthermore, segments can be divided into smaller 4K‐sized units
called pages, so each segment can be divided to 220 pages.
 The virtual memory system works with pages now instead of
segments.
Questions?
27
Thank you 
28

More Related Content

What's hot

The Intel 8086 microprocessor
The Intel 8086 microprocessorThe Intel 8086 microprocessor
The Intel 8086 microprocessor
George Thomas
 
Chapter 6 hardware structure of 8086
Chapter 6  hardware structure of 8086Chapter 6  hardware structure of 8086
Chapter 6 hardware structure of 8086
SHREEHARI WADAWADAGI
 
26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architectureSaurabh Jain
 
Intel 8086 microprocessor
Intel 8086 microprocessorIntel 8086 microprocessor
Intel 8086 microprocessor
Ravi Yasas
 
Register Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorRegister Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorNikhil Kumar
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
Md. Hasnat Shoheb
 
Amp
AmpAmp
Basics of 8086
Basics of 8086Basics of 8086
Basics of 8086
PDFSHARE
 
8086 Microprocessor
8086 Microprocessor8086 Microprocessor
8086 Microprocessor
Avinash Rouniyar
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
Poojith Chowdhary
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
Vatsal Dave
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086
Estiak Khan
 
8086 handout for chapter one and two
8086 handout for chapter one and two8086 handout for chapter one and two
8086 handout for chapter one and twohaymanotyehuala
 
8086 microprocessor
8086 microprocessor8086 microprocessor
8086 microprocessor
ganeshbehera6
 
Architecture of 8086
Architecture of 8086Architecture of 8086
Architecture of 8086
MOHAN MOHAN
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
prasadpawaskar
 

What's hot (19)

The Intel 8086 microprocessor
The Intel 8086 microprocessorThe Intel 8086 microprocessor
The Intel 8086 microprocessor
 
Chapter 6 hardware structure of 8086
Chapter 6  hardware structure of 8086Chapter 6  hardware structure of 8086
Chapter 6 hardware structure of 8086
 
8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware
 
26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture
 
Intel 8086 microprocessor
Intel 8086 microprocessorIntel 8086 microprocessor
Intel 8086 microprocessor
 
Register Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorRegister Organisation of 8086 Microprocessor
Register Organisation of 8086 Microprocessor
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
 
Lecture2
Lecture2Lecture2
Lecture2
 
Amp
AmpAmp
Amp
 
Basics of 8086
Basics of 8086Basics of 8086
Basics of 8086
 
8086 Microprocessor
8086 Microprocessor8086 Microprocessor
8086 Microprocessor
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086
 
8086 handout for chapter one and two
8086 handout for chapter one and two8086 handout for chapter one and two
8086 handout for chapter one and two
 
8086 microprocessor
8086 microprocessor8086 microprocessor
8086 microprocessor
 
Architecture of 8086
Architecture of 8086Architecture of 8086
Architecture of 8086
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 

Viewers also liked

[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
Nora Youssef
 
[ASM]Lab3
[ASM]Lab3[ASM]Lab3
[ASM]Lab3
Nora Youssef
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
Syed Zaid Irshad
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroaki
asmtanka
 
Affective computing
Affective computingAffective computing
Affective computingAnkit Moonka
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
Nora Youssef
 
[ASM] Lab1
[ASM] Lab1[ASM] Lab1
[ASM] Lab1
Nora Youssef
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
Motaz Saad
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly languageAhmed M. Abed
 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
Shehrevar Davierwala
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
Motaz Saad
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Frankie Jones
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
Education Front
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 

Viewers also liked (16)

[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
 
[ASM]Lab3
[ASM]Lab3[ASM]Lab3
[ASM]Lab3
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroaki
 
Affective computing
Affective computingAffective computing
Affective computing
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
[ASM] Lab1
[ASM] Lab1[ASM] Lab1
[ASM] Lab1
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 

Similar to [ASM] Lab2

Architecture_of_80386_Microprocessor - Inroduction
Architecture_of_80386_Microprocessor - InroductionArchitecture_of_80386_Microprocessor - Inroduction
Architecture_of_80386_Microprocessor - Inroduction
rajasekarandpm
 
80386.pptx
80386.pptx80386.pptx
Architecture of 80386(www.munnuz.co.cc)
Architecture of 80386(www.munnuz.co.cc)Architecture of 80386(www.munnuz.co.cc)
Architecture of 80386(www.munnuz.co.cc)
muneer.k
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386yash sawarkar
 
80386
8038680386
Internal microprocessor architecture
Internal microprocessor architectureInternal microprocessor architecture
Internal microprocessor architecture
University of Gujrat, Pakistan
 
Chapter 2
Chapter 2Chapter 2
Advanced micro -processor
Advanced micro -processorAdvanced micro -processor
Advanced micro -processor
Hinal Lunagariya
 
microprocessor_part_3_compressed_1588259301.pdf
microprocessor_part_3_compressed_1588259301.pdfmicroprocessor_part_3_compressed_1588259301.pdf
microprocessor_part_3_compressed_1588259301.pdf
ssuserd21262
 
physical_address segmentation.pdf
physical_address segmentation.pdfphysical_address segmentation.pdf
physical_address segmentation.pdf
Swapnil511014
 
Architecture_of_80386_Micropro-An Introduction
Architecture_of_80386_Micropro-An IntroductionArchitecture_of_80386_Micropro-An Introduction
Architecture_of_80386_Micropro-An Introduction
rajasekarandpm
 
Presentation on 8086 microprocessor
Presentation on 8086 microprocessorPresentation on 8086 microprocessor
Presentation on 8086 microprocessor
Diponkor Bala
 
Lect 8 updated (1)
Lect 8 updated (1)Lect 8 updated (1)
Lect 8 updated (1)
talhashahid40
 
digital communication,micro processor,pulse and digital circuits
digital communication,micro processor,pulse and digital circuitsdigital communication,micro processor,pulse and digital circuits
digital communication,micro processor,pulse and digital circuitsManasa Mona
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
Siraj Ahmed
 
introduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's applicationintroduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's application
DrVikasMahor
 

Similar to [ASM] Lab2 (20)

110 ec0644
110 ec0644110 ec0644
110 ec0644
 
Architecture_of_80386_Microprocessor - Inroduction
Architecture_of_80386_Microprocessor - InroductionArchitecture_of_80386_Microprocessor - Inroduction
Architecture_of_80386_Microprocessor - Inroduction
 
80386.pptx
80386.pptx80386.pptx
80386.pptx
 
Architecture of 80386(www.munnuz.co.cc)
Architecture of 80386(www.munnuz.co.cc)Architecture of 80386(www.munnuz.co.cc)
Architecture of 80386(www.munnuz.co.cc)
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386
 
80386
8038680386
80386
 
Internal microprocessor architecture
Internal microprocessor architectureInternal microprocessor architecture
Internal microprocessor architecture
 
8051 microcontroller
 8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Advanced micro -processor
Advanced micro -processorAdvanced micro -processor
Advanced micro -processor
 
microprocessor_part_3_compressed_1588259301.pdf
microprocessor_part_3_compressed_1588259301.pdfmicroprocessor_part_3_compressed_1588259301.pdf
microprocessor_part_3_compressed_1588259301.pdf
 
physical_address segmentation.pdf
physical_address segmentation.pdfphysical_address segmentation.pdf
physical_address segmentation.pdf
 
8086
80868086
8086
 
Architecture_of_80386_Micropro-An Introduction
Architecture_of_80386_Micropro-An IntroductionArchitecture_of_80386_Micropro-An Introduction
Architecture_of_80386_Micropro-An Introduction
 
Presentation on 8086 microprocessor
Presentation on 8086 microprocessorPresentation on 8086 microprocessor
Presentation on 8086 microprocessor
 
Lect 8 updated (1)
Lect 8 updated (1)Lect 8 updated (1)
Lect 8 updated (1)
 
Chapter2d
Chapter2dChapter2d
Chapter2d
 
digital communication,micro processor,pulse and digital circuits
digital communication,micro processor,pulse and digital circuitsdigital communication,micro processor,pulse and digital circuits
digital communication,micro processor,pulse and digital circuits
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
introduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's applicationintroduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's application
 

More from Nora Youssef

Welcome to dragons’ land
Welcome to dragons’ landWelcome to dragons’ land
Welcome to dragons’ land
Nora Youssef
 
[SpLab1]Review
[SpLab1]Review[SpLab1]Review
[SpLab1]Review
Nora Youssef
 
[SpLab2]Arrays
[SpLab2]Arrays[SpLab2]Arrays
[SpLab2]Arrays
Nora Youssef
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]Structures
Nora Youssef
 
[SpLab5] Pointers II
[SpLab5] Pointers II[SpLab5] Pointers II
[SpLab5] Pointers II
Nora Youssef
 
[SpLab4]Pointers I
[SpLab4]Pointers I[SpLab4]Pointers I
[SpLab4]Pointers I
Nora Youssef
 
[SpLab7]Functions I
[SpLab7]Functions I[SpLab7]Functions I
[SpLab7]Functions I
Nora Youssef
 
[Splab8]Functions II
[Splab8]Functions II[Splab8]Functions II
[Splab8]Functions II
Nora Youssef
 
[SpLab9]Functions III
[SpLab9]Functions III[SpLab9]Functions III
[SpLab9]Functions III
Nora Youssef
 
[ASM]Lab8
[ASM]Lab8[ASM]Lab8
[ASM]Lab8
Nora Youssef
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
Nora Youssef
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
Nora Youssef
 

More from Nora Youssef (13)

Welcome to dragons’ land
Welcome to dragons’ landWelcome to dragons’ land
Welcome to dragons’ land
 
[SpLab1]Review
[SpLab1]Review[SpLab1]Review
[SpLab1]Review
 
[SpLab2]Arrays
[SpLab2]Arrays[SpLab2]Arrays
[SpLab2]Arrays
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]Structures
 
[SpLab5] Pointers II
[SpLab5] Pointers II[SpLab5] Pointers II
[SpLab5] Pointers II
 
[SpLab4]Pointers I
[SpLab4]Pointers I[SpLab4]Pointers I
[SpLab4]Pointers I
 
[SpLab7]Functions I
[SpLab7]Functions I[SpLab7]Functions I
[SpLab7]Functions I
 
[Splab8]Functions II
[Splab8]Functions II[Splab8]Functions II
[Splab8]Functions II
 
[SpLab9]Functions III
[SpLab9]Functions III[SpLab9]Functions III
[SpLab9]Functions III
 
[ASM]Lab8
[ASM]Lab8[ASM]Lab8
[ASM]Lab8
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 
Abstract
AbstractAbstract
Abstract
 

Recently uploaded

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

[ASM] Lab2

  • 2. Agenda What is Assembly Language? Computer Organization Main memory Memory Modes:  Real Mode (8086)  Protected Mode (80386)
  • 3. What is Assembly Language?  Assembly Language is a low-level (machine‐level) programming language that uses mnemonics instead of numeric codes (0’s, 1’s) to simplify programming.  For example, the instruction in machine language which means copy the content from AX register to BX register is: 8B D8 While same instruction written in assembly is: mov BX, AX  Each statement in assembly code has a one-to-one relationship with machine language instructions, in other words each statement corresponds to a single machine code instruction. 3
  • 4.  To run a program written in assembly language, we should have a converter (or translator) which converts these labels and mnemonics to their corresponding machine codes in 0’s and 1’s. This converter is called an assembler. 4 Machine CodeAssemblerAssembly Code To run a program written in a high level language we should have a converter called …..? What is Assembly Language?
  • 6. Main Memory  It is the place to store data (and instructions) temporarily.  Each location (byte) in memory has content (value) and a unique label (address).  Often, memory is used in larger chunks than single bytes. As shown below: Main Memory Byte
  • 7. Memory Modes: Real Mode (8086) – 16 Bit Registers CPU 8086 Register Size 16 bits Main Memory 1 MByte Program Segment 64 k (220 𝑏𝑦𝑡𝑒)
  • 8. Memory Modes: Real Mode (8086) – 16 Bit Registers 4 General Purpose  AX : Accumulator  BX : Base  CX: Count  DX: Data 4 Index and Pointers  DI: Destination Index  SI : Source Index  BP: Base Pointer  SP : Stack pointer  4 Segments registers  DS: Data Segment.  CS: Code Segment  SS: Stack Segment  ES: Extra Segment  Instruction Pointers  IP: Instruction Pointer  Flags  ZF , SF, OF, CF...
  • 9. Memory Modes: Real Mode (8086) – 16 Bit Registers 4 General Purpose Each of these registers could be decomposed into two 8‐bit registers. AH and AL are dependent on AX. Changing AX’s value will change AH and AL values and vice versa.
  • 10. Memory Modes: Real Mode (8086) – 16 Bit Registers Index and Pointers (SI, DI) They are often used as pointers to memory items, but can be used for other purposes as the general‐purpose registers. They cannot be decomposed into 8‐bit registers.
  • 11. Memory Modes: Real Mode (8086) – 16 Bit Registers Index and Pointers (BP, SP) They are used to point to data in the stack and are called the Base Pointer and Stack Pointer, respectively. Stack BP SP
  • 12. Memory Modes: Real Mode (8086) – 16 Bit Registers  4 Segments registers (CS, DS, SS, ES) They keep the starting address of memory chunk used for different parts of a program. CS stands for Code Segment, DS for Data Segment, SS for Stack Segment, and ES for Extra Segment. ES is used as a temporary segment register.
  • 13. Memory Modes: Real Mode (8086) – 16 Bit Registers  Instruction Pointers (IP) This register is used with the CS register to keep track of the address of the next instruction to be executed by the CPU.  Flags (ZF , SF, OF, CF...) The FLAGS register stores important information about the results of the last executed operation. This information is stored as individual bits in this register. For example, there is a specific bit called the Zero flag (Z flag). This Z flag is 1 if the result of the last operation was zero otherwise Z flag is set to zero. Not all instructions modify the bits in FLAGS.
  • 14. Memory Modes: Real Mode (8086) – 16 Bit Registers  As shown before, memory in real mode (8086) is limited to only one megabyte (220 bytes).  Valid address range is from (in hex) 00000 to FFFFF. These addresses require a 20‐bit number. Will it fit in the segment registers?
  • 15. Memory Modes: Real Mode (8086) – 16 Bit Registers  A program is often divided into 3 segments, which are Code, Data, and Stack segments where its starting address is stored in segment registers. And each of these segments must begins on a paragraph boundary (i.e. its address is divisible by 16). Therefore, the starting address of any segment always begins with four 0‐bits.  In addition, an offset register is used to address memory locations within each segment. The size of each segment is 64KB (𝟐 𝟏𝟔 𝒃𝒚𝒕𝒆) at most. Why?
  • 16. Memory Modes: Real Mode (8086) – 16 Bit Registers  To find the physical address (20‐bit) from segment‐offset pair, use the following relation: 16 * segment register + offset register  Multiplying by 16 is equivalent to left shifting the binary value 4 times. This done to return the four 0 bits which not stored physically in the segment register. Why do we multiply by 16?
  • 17. Memory Modes: Real Mode (8086) – 16 Bit Registers  Examples: 1. Segment Register: 047C Offset Register: 0048 Physical address: 047C0 + 0048 = 04808 2. Segment Register: 047D Offset Register: 0038 Physical address: 047D0 + 0038 = 04808 And we can also get the same address when we add 047E0 with 0028. Same address!
  • 18. Memory Modes: Real Mode (8086) – 16 Bit Registers Disadvantages: 1. A single segment can only contain 64K of memory (the upper limit of the 16‐bit offset register). 2. Each byte in memory does not have a unique segmented address.
  • 19. Memory Modes: Protected Mode (80386) – 32 Bit Registers CPU 80386 Register Size 32 bits Main Memory 4 Gbyte Program Segment 4 Gbyte (232 𝑏𝑦𝑡𝑒)
  • 20. Memory Modes: Protected Mode (80386) – 32 Bit Registers  In 386 CPU, registers become 32‐bit wide except segment registers (selectors) remain 16‐bits as they are.  Two new 16‐bit segment registers are also added, FS and GS.  This extension made the single segment size up to 4GB.
  • 21. Memory Modes: Protected Mode (80386) – 32 Bit Registers So how does a segment register store the 32‐bit address of memory?  Segment register is interpreted differently in protected mode. It is interpreted as an index into a descriptor table than a register stores the starting address of the segment.  Descriptor table: is a table containing physical addresses of all segments beside some other information about these segments. It is stored in memory and its location is stored in a special register. (local or global)
  • 22. Memory Modes: Protected Mode (80386) – 32 Bit Registers . . . 16 bits CS Register 32 bits Address of the CS in Memory Main Memory Descriptor Table
  • 23. Memory Modes: Protected Mode (80386) – 32 Bit Registers  As explained before, this mode allows the program segment to be of size 4GB, so only one segment of only one program can take the whole memory size to its own?
  • 24. Memory Modes: Protected Mode (80386) – 32 Bit Registers  For that problem protected mode uses a technique called virtual memory.  The basic idea of virtual memory system is to only keep the data and code in physical memory that programs are currently using.  Other data and code are stored temporarily on disk until they are needed again.
  • 25. Memory Modes: Protected Mode (80386) – 32 Bit Registers  Furthermore, segments can be divided into smaller 4K‐sized units called pages, so each segment can be divided to 220 pages.  The virtual memory system works with pages now instead of segments.
  • 26.

Editor's Notes

  1. Compiler
  2. Four-bit computer architectures use groups of four bits as their fundamental unit. Such architectures were used in early microprocessors and pocket calculators and continue to be used in some microcontrollers
  3. 2^16 at most so as to be able to use a 16-bit register for representing this amount of bytes (Locations)
  4.  FS and GS have no hardware-assigned uses but they can be used like the ES register
  5. 1. 4 GByte ( 0 to FFFFFFFFh). 2. 1 MByte (0 to FFFFFh). 3. Linear (absolute). 4. 09600h. 5. 0CFF0h. 6. 32 bits. 7. SS register. 8. Local descriptor table. 9. Global descriptor table. 10. The total size of all programs loaded into memory can exceed the amount of physical memory installed in the computer. 11. This is an open-ended question, of course. It is a fact that MS-DOS first had to run on the 8086/8088 processors, which only supported Real-address mode. When later processors came out that supported Protected mode, my guess is that Microsoft wanted MS-DOS to continue to run on the older processors. Otherwise, customers with older computers would refuse to upgrade to new versions of MS-DOS. 12. The following segment-offset addresses point to the same linear address: 0640:0100 and 0630:0200.