SlideShare une entreprise Scribd logo
1  sur  34
Chapter 2
Instruction Addressing and Execution
Recalling main concepts
Recalling main concepts
Recalling main concepts
• Segment: special areas defined to contain CODE,
DATA and STACK
• Paragraph boundary: location evenly divisible by 16
or 10H
Recalling main concepts
Stack Segment
Data Segment
Code Segment
SS
DS
CS
Segment
Registers
Types of programs
• *.COM and *.EXE files
• *.COM: consists of one segment containing code, data
and stack
• *.exe: separate code, data and stack segments
Loading *.exe program
• Access *.exe from disk
• 256-byte Program Segment Prefix (PSP) on a
paragraph boundary
• Store the program immediately following the PSP
• Load address of PSP in the DS & ES
• Load code segment in CS, set IP
• Load address of the stack to SS, set SP
• Transfer control to the program for execution
.model small,
.stack
.data
message db "Hello everybody! I am learning assembly
language!","$"
.code
main proc
mov ax, seg message
mov ds,ax
mov ah,09
lea dx,message
int 21h
mov ax,4c00h
int 21h
main endp
end main
Assembly
directive to
define
memory
model to use
in the
program
Real and Protected mode
Real Mode
16-bit
Protected
Mode
32-bit Protected
Mode
Segment base
address
20-bit
24-bit,
from
descriptor
32-bit,
from descriptor
Segment size
(limit)
16-bit, 64K
bytes (fixed)
16-bit, 1-64K
bytes
20-bit, 1-1M bytes or
4K-4G bytes
Segment
protection
no yes yes
Segment
register
segment base
address / 16
selector selector
Protected mode
-Is a type of memory utilization, available on
Intel 80286 and later
-Support:
protection: each program is protected
from interference from other programs.
extended memory : Enables a single
program to access more than 640K of memory.
virtual memory : Expands the address
space to over 1GB.
Multitasking:
Booting process
What is booting?
• The process of starting or restarting a computer
cold boot
Process of turning on
a computer after it
has been powered off
completely
warm boot
Process of
restarting a
computer that is
already powered on
Also called a warm
start
Booting process
How does a personal computer boot up?
processor
BIOS
hard disk
CD-ROM drive
(RAM) memory
modules
CMOS
floppy disk drive
Step 6
expansion cards
BIOS Boot process
BIOS routineFFFF0H
Interrupt
Vector
Table
BIOS Data
Areas
Access
the bootstrap
loader
Check ports
Initialize
devices
.model small,
.stack
.data
message db "Hello everybody! I am learning assembly
language!","$"
.code
main proc
mov ax, seg message
mov ds,ax
mov ah,09
lea dx,message
int 21h
mov ax,4c00h
int 21h
main endp
end main
Assembly
directive to
define stack
to use in the
program
STACK
• The word is from data structure
• Last In, First Out (LIFO) mechanism
• STACK in OS has three main functions:
• Contains return address
• Data
• Content of present registers
STACK
• PUSH
• Decrease SP by 2 and store a value there
• POP
• Return a value from stack and increase SP by 2
Lesson plan
• Review loading an *.exe file
• Concept of execution of instructions
• Practice:
• Execution of instructions
Access *.exe from disk
256-byte Program Segment Prefix (PSP)
on a paragraph boundary
Store the program immediately
following the PSP
Load address of PSP in the DS & ES
Load code segment in CS, set IP
Load address of the stack to SS, set SP
Transfer control to the program for
execution
Loading *.exe file
Loading *.exe file
• The sequence of segments (code, data, and stack)
is given
• SS: contains the address of the beginning of the
stack
• CS: contains the address of the beginning of the
code segment
• DS: contains the address of the beginning of the
data segment
• SP: contains the size of stack
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
PSP 2B360H
PSP size 100H
Offset 0H
SS 2B460H
(stored as
2B46)
2B46HSS
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
2B46HSS
PSP 2B360H
PSP size 100H
Offset 30H
70H
CS 2B500H
(stored as 2B50)
CS 2B50H
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
2B46HSS
CS 2B50H
2B36H
2B36H
DS
ES
SP 0030H
Instruction Execution and Addressing
• Executing an instruction include
• Fetch the next instruction, put to a queue (QUEUE: FIFO
vs. STACK LIFO)
• Decode the instruction
• Execute the instruction
Example
4AF0CS 0013IP
4AF13H
CS segment address: 4AF00H
IP offset: 0013H
________________________
+
Instruction address:
04B1DS
Example
4AF0CS 0013IP
4AF13H
A01200
Memory
04B1DS
Decode instruction:
AO: MOV [0012] to AL
Example
4AF0CS 0013IP
4AF13H
A01200
Memory
04B1DS
DS segment address:04B10H
IP offset: 0012H
________________________
+
Data address: 04B22H
Example
4AF0CS 0013IP
4AF13H
A01200
Memory
04B1DS
04B22Data address:
04B22H
| 1B
AXAX
AH AL
1B
Practice
• Viewing memory location using DEBUG
At DOS prompt, type: DEBUG
• Checking Serial and parallel port:
D 40:00
• Checking system equipment
D 40:10
Practice
• Viewing memory location using DEBUG
At DOS prompt, type: DEBUG
• Checking Serial and parallel port:
D 40:00
• Checking system equipment
D 40:10
Practice
• Viewing memory location using DEBUG
At DOS prompt, type: DEBUG
• Checking Serial and parallel port:
D 40:00
• Checking system equipment
22 C8 C822
reverse
Number of parallel printer ports=11(binary)=3 (15,14)
Number of serial ports=100(binary)=4 (11-9)
Number of diskette devices=00(binary)=1 (7,6)
Initial video mode =10 (5,4) (80x25 color)
Coprocessor present: 1 (1)
Diskette drive is present: 0 (0)
Practice (cont.)
• Checking the keyboard status
• D 40:17 (With Numlock and Caplock)
• Checking video status
• D 40:49
• D 40:84
Practice (cont.)
• Checking copyright notice & serial number
• D FE00:0
• Checking ROM BIOS date
D FFFF:5
Practice (cont.)
Running the first assembly program step by step
using EMU 8086

Contenu connexe

Tendances

NFS is an excellent way of sharing files between linux and other unix systems
NFS is an excellent way of sharing files between linux and other unix systemsNFS is an excellent way of sharing files between linux and other unix systems
NFS is an excellent way of sharing files between linux and other unix systemsAshish Mamgain
 
DNS server configurationDns server configuration
DNS server configurationDns server configurationDNS server configurationDns server configuration
DNS server configurationDns server configurationThamizharasan P
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os labFS Karimi
 
DNS Configuration
DNS ConfigurationDNS Configuration
DNS ConfigurationVinod Gour
 
101 4.2 maintain the integrity of filesystems
101 4.2 maintain the integrity of filesystems101 4.2 maintain the integrity of filesystems
101 4.2 maintain the integrity of filesystemsAcácio Oliveira
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirectsAcácio Oliveira
 
Memory map
Memory mapMemory map
Memory mapaviban
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting PresantionSameerNimkar
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line BasicsWe Ihaveapc
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1solgenomics
 

Tendances (20)

NFS is an excellent way of sharing files between linux and other unix systems
NFS is an excellent way of sharing files between linux and other unix systemsNFS is an excellent way of sharing files between linux and other unix systems
NFS is an excellent way of sharing files between linux and other unix systems
 
DNS server configurationDns server configuration
DNS server configurationDns server configurationDNS server configurationDns server configuration
DNS server configurationDns server configuration
 
Extensions
ExtensionsExtensions
Extensions
 
Basic linux day 3
Basic linux day 3Basic linux day 3
Basic linux day 3
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
DNS Configuration
DNS ConfigurationDNS Configuration
DNS Configuration
 
Linux
Linux Linux
Linux
 
101 4.2 maintain the integrity of filesystems
101 4.2 maintain the integrity of filesystems101 4.2 maintain the integrity of filesystems
101 4.2 maintain the integrity of filesystems
 
Linux commands
Linux commandsLinux commands
Linux commands
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
Basic Linux day 1
Basic Linux day 1Basic Linux day 1
Basic Linux day 1
 
Basic Linux day 6
Basic Linux day 6Basic Linux day 6
Basic Linux day 6
 
Linux
LinuxLinux
Linux
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Basic linux day 4
Basic linux day 4Basic linux day 4
Basic linux day 4
 
Memory map
Memory mapMemory map
Memory map
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting Presantion
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line Basics
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
 

Similaire à Instruction addressing and execution

Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Buffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackBuffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackTomer Zait
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
Microprocessors-based systems (under graduate course) Lecture 7 of 9
Microprocessors-based systems (under graduate course) Lecture 7 of 9 Microprocessors-based systems (under graduate course) Lecture 7 of 9
Microprocessors-based systems (under graduate course) Lecture 7 of 9 Randa Elanwar
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Programming segment 8086 Memory model 8086
Programming segment 8086 Memory model 8086Programming segment 8086 Memory model 8086
Programming segment 8086 Memory model 8086FazalHameed14
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.pptJaya Chavan
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computerKirby Fabro
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadYogesh Deshpande
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuEstelaJeffery653
 

Similaire à Instruction addressing and execution (20)

Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Lec05
Lec05Lec05
Lec05
 
Buffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackBuffer overflow – Smashing The Stack
Buffer overflow – Smashing The Stack
 
01 isa
01 isa01 isa
01 isa
 
MASM.pptx
MASM.pptxMASM.pptx
MASM.pptx
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
Lec06
Lec06Lec06
Lec06
 
Microprocessors-based systems (under graduate course) Lecture 7 of 9
Microprocessors-based systems (under graduate course) Lecture 7 of 9 Microprocessors-based systems (under graduate course) Lecture 7 of 9
Microprocessors-based systems (under graduate course) Lecture 7 of 9
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
 
Programming segment 8086 Memory model 8086
Programming segment 8086 Memory model 8086Programming segment 8086 Memory model 8086
Programming segment 8086 Memory model 8086
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.ppt
 
Kirby, Fabro
Kirby, FabroKirby, Fabro
Kirby, Fabro
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computer
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_upload
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structu
 

Dernier

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Dernier (20)

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

Instruction addressing and execution

  • 4. Recalling main concepts • Segment: special areas defined to contain CODE, DATA and STACK • Paragraph boundary: location evenly divisible by 16 or 10H
  • 5. Recalling main concepts Stack Segment Data Segment Code Segment SS DS CS Segment Registers
  • 6. Types of programs • *.COM and *.EXE files • *.COM: consists of one segment containing code, data and stack • *.exe: separate code, data and stack segments
  • 7. Loading *.exe program • Access *.exe from disk • 256-byte Program Segment Prefix (PSP) on a paragraph boundary • Store the program immediately following the PSP • Load address of PSP in the DS & ES • Load code segment in CS, set IP • Load address of the stack to SS, set SP • Transfer control to the program for execution
  • 8. .model small, .stack .data message db "Hello everybody! I am learning assembly language!","$" .code main proc mov ax, seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21h main endp end main Assembly directive to define memory model to use in the program
  • 9. Real and Protected mode Real Mode 16-bit Protected Mode 32-bit Protected Mode Segment base address 20-bit 24-bit, from descriptor 32-bit, from descriptor Segment size (limit) 16-bit, 64K bytes (fixed) 16-bit, 1-64K bytes 20-bit, 1-1M bytes or 4K-4G bytes Segment protection no yes yes Segment register segment base address / 16 selector selector
  • 10. Protected mode -Is a type of memory utilization, available on Intel 80286 and later -Support: protection: each program is protected from interference from other programs. extended memory : Enables a single program to access more than 640K of memory. virtual memory : Expands the address space to over 1GB. Multitasking:
  • 11. Booting process What is booting? • The process of starting or restarting a computer cold boot Process of turning on a computer after it has been powered off completely warm boot Process of restarting a computer that is already powered on Also called a warm start
  • 12. Booting process How does a personal computer boot up? processor BIOS hard disk CD-ROM drive (RAM) memory modules CMOS floppy disk drive Step 6 expansion cards
  • 13. BIOS Boot process BIOS routineFFFF0H Interrupt Vector Table BIOS Data Areas Access the bootstrap loader Check ports Initialize devices
  • 14. .model small, .stack .data message db "Hello everybody! I am learning assembly language!","$" .code main proc mov ax, seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21h main endp end main Assembly directive to define stack to use in the program
  • 15. STACK • The word is from data structure • Last In, First Out (LIFO) mechanism • STACK in OS has three main functions: • Contains return address • Data • Content of present registers
  • 16. STACK • PUSH • Decrease SP by 2 and store a value there • POP • Return a value from stack and increase SP by 2
  • 17. Lesson plan • Review loading an *.exe file • Concept of execution of instructions • Practice: • Execution of instructions
  • 18. Access *.exe from disk 256-byte Program Segment Prefix (PSP) on a paragraph boundary Store the program immediately following the PSP Load address of PSP in the DS & ES Load code segment in CS, set IP Load address of the stack to SS, set SP Transfer control to the program for execution Loading *.exe file
  • 19. Loading *.exe file • The sequence of segments (code, data, and stack) is given • SS: contains the address of the beginning of the stack • CS: contains the address of the beginning of the code segment • DS: contains the address of the beginning of the data segment • SP: contains the size of stack
  • 21. Practice 2B360H PSP Stack Segment Data Segment Code Segment Memory PSP 2B360H PSP size 100H Offset 0H SS 2B460H (stored as 2B46) 2B46HSS
  • 22. Practice 2B360H PSP Stack Segment Data Segment Code Segment Memory 2B46HSS PSP 2B360H PSP size 100H Offset 30H 70H CS 2B500H (stored as 2B50) CS 2B50H
  • 23. Practice 2B360H PSP Stack Segment Data Segment Code Segment Memory 2B46HSS CS 2B50H 2B36H 2B36H DS ES SP 0030H
  • 24. Instruction Execution and Addressing • Executing an instruction include • Fetch the next instruction, put to a queue (QUEUE: FIFO vs. STACK LIFO) • Decode the instruction • Execute the instruction
  • 25. Example 4AF0CS 0013IP 4AF13H CS segment address: 4AF00H IP offset: 0013H ________________________ + Instruction address: 04B1DS
  • 27. Example 4AF0CS 0013IP 4AF13H A01200 Memory 04B1DS DS segment address:04B10H IP offset: 0012H ________________________ + Data address: 04B22H
  • 29. Practice • Viewing memory location using DEBUG At DOS prompt, type: DEBUG • Checking Serial and parallel port: D 40:00 • Checking system equipment D 40:10
  • 30. Practice • Viewing memory location using DEBUG At DOS prompt, type: DEBUG • Checking Serial and parallel port: D 40:00 • Checking system equipment D 40:10
  • 31. Practice • Viewing memory location using DEBUG At DOS prompt, type: DEBUG • Checking Serial and parallel port: D 40:00 • Checking system equipment 22 C8 C822 reverse Number of parallel printer ports=11(binary)=3 (15,14) Number of serial ports=100(binary)=4 (11-9) Number of diskette devices=00(binary)=1 (7,6) Initial video mode =10 (5,4) (80x25 color) Coprocessor present: 1 (1) Diskette drive is present: 0 (0)
  • 32. Practice (cont.) • Checking the keyboard status • D 40:17 (With Numlock and Caplock) • Checking video status • D 40:49 • D 40:84
  • 33. Practice (cont.) • Checking copyright notice & serial number • D FE00:0 • Checking ROM BIOS date D FFFF:5
  • 34. Practice (cont.) Running the first assembly program step by step using EMU 8086

Notes de l'éditeur

  1. COM is small, (small utility program or can be a resident program). We will focus on EXE program in this course.
  2. There are several types of memory: Memory model TINY , SMALL , COMPACT , MEDIUM , LARGE , HUGE , or FLAT . Determines size of code and data pointers. This field is required. The model does, however, control segment defaults and determine whether data and code are near or far by default, as indicated in the following table. The model does not control the type of instructions that we can use.
  3. Interest part: father of Ctrl-Alt-Del: david Bradley, long time employee of IBM, who also has a Ph.D in EE from Purdue in Indiana
  4. How does a personal computer boot up? Step 1: The power supply sends a signal to components in the system unit. Step 2: The processor looks for the BIOS (Basic Input/Output system) Step 3: The BIOS performs the POST, which checks components such as the mouse, keyboard connectors, and expansion cards. (Power On Self Test) Step 4: The results of the POST are compared with data in the CMOS chip. (battery power) Step 5: The BIOS looks for the system files in drive A (floppy disk drive) and then drive C (hard disk). Step 6: The boot program loads the kernel of the operating system into RAM from storage (hard disk). The operating system in memory takes control of the computer. Step 7: The operating system loads configuration information and displays the desktop on the screen. The operating system executes programs in the StartUp folder Registry - Several files that contain the system configuration information Registry is constantly accessed during the computer's operation StartUp folder - Contains a list of programs that open automatically when you boot the computer
  5. Internally, processor enters the reset state, clear all memory location to zero, perform a parity check of a memory, set CS to FFFFH, IP to zero. The first address to execute is FFFF0H (entry point of BIOS in ROM) Identify & Initialized devices. Established the tables: IVT (Interrupt Vector Table) and BIOS data area (status of attached devices) -Determine if the disk containing the system file is available.
  6. Queue