SlideShare a Scribd company logo
1 of 16
01/29/15 Protected Mode Assignment 1
Switching from Real to Protected Mode
• Programme Assignments
• Define Global Descriptor Table
• Main Programme Body
0000h
4Gb
x00h
01/29/15 Protected Mode Assignment 2
Programme Assignments
.386p
Code segment use16
Assume cs: code , ss: stack
realadd dd 0
taskadd dd 0
msg0 db ‘ in Real Mode ‘,0
msg1 db ‘ in Protected Model Mode ‘,0
msg2 db ‘ Back in Real Mode ‘,0
msg3 db ‘ < Your own declarations> ‘,0
x00h
01/29/15 Protected Mode Assignment 3
Define Global Descriptor Table
Code Segment cs_32
Data Segment ds_32
Extra Segment es_32
01/29/15 Protected Mode Assignment 4
Define Global Descriptor Table
<Code Segment cs_32>
------------------------------------------------------------------------------------------
cs_32: ; 08h
-----------------------------------------------------------------------------
dw 0ffffh ; segment Limit
c1: dw 00h ; Base Address 15:00
c2: db 00h ; Base Address 23:16
db 09Ah : b ’1001 1010’
db 00h ; b ‘ 0000 0000’
C3 db 00h ; Base Address 24:31
---------------------------------------------------------------------------------------------
01/29/15 Protected Mode Assignment 5
Define Global Descriptor Table
<Extra Segment es_32>
------------------------------------------------------------------------------------------
es_32: ; 10h
------------------------------------------------------------------------------------------
dw 0ffffh ; segment Limit
e1: dw 8000h ; Base Address 15:00
e2: db 0bh ; Base Address 23:16
db 092h : b ’1001 1010’
db 00h ; b ‘ 0000 0000’
e3 db 00h ; Base Address 24:31
---------------------------------------------------------------------------------------------
01/29/15 Protected Mode Assignment 6
Define Global Descriptor Table
<Data Segment ds_32>
------------------------------------------------------------------------------------------
ds_32: ; 18h
------------------------------------------------------------------------------------------
dw 0ffffh ; segment Limit
d1: dw 0000h ; Base Address 15:00
d2: db 00h ; Base Address 23:16
db 092h : b ’1001 1010’
db 00h ; b ‘ 0000 0000’
d3 db 00h ; Base Address 24:31
---------------------------------------------------------------------------------------------
01/29/15 Protected Mode Assignment 7
Global Descriptor Table
x00h
cs_32
es_32
ds_32
gdt_Start
cs_32(08h)
es_32(10h)
ds_32(18h)
gdt_End
Null Desc(0h)
01/29/15 Protected Mode Assignment 8
Global Descriptor Table
x00h
gdt_start:
cs_32:
es_32:
ds_32:
gdt_end:
gdt_reg label fword
gdt_limit dw gdt_end - gdt_start
gdt_base dd 0
cs_32(08h)
es_32(10h)
ds_32(18h)
gdt_End
Null Desc(0h)
gdt_Start
01/29/15 Protected Mode Assignment 9
Main Programme Body
Begin:
Display Some Message (Graphics Mode)
Set up Global Descriptor Table
Load Global Descriptor Table Register
Switch to Protected Mode
Jump to Protected Mode
Display Message
Switch to Real Mode
Exit:
pm:
rmd:
01/29/15 Protected Mode Assignment 10
Display Some Message (Graphics Mode)
Graphics Display B800h
es = B800
ds = cs
clear screen
si = msg0
di = (80 * Lines(hor) ) * 2
cx = length of Msg
Loop es: [di] = al = [si]
inc si ; inc di
loop cx
01/29/15 Protected Mode Assignment 11
Display Some Message (Graphics Mode)
ax = cs
lea si, realadd
mov word ptr [si+2],ax
lea ax,[rmd]
mov word ptr [si],ax
pm:
rmd:
01/29/15 Protected Mode Assignment 12
Set up Global Descriptor Table
ax = cs
eax << ax
ebx << eax
ebx << 4 ; Address is 20 bits
eax = ebx
c1 = d1 = ax
eax >> 16 ; Shift Right by 16
d2 = c2 = al
d3 = c3 = ah
----------------------------------------------------------------------
c1 , d1
c2 d2c3 , d3
01/29/15 Protected Mode Assignment 13
Load Global Descriptor Table Register
----------------------------------------------------------------------------------
eax = ax = cs
eax << 4
ebx << bx = gdt_Start
ebx = eax + ebx
cs:gdt_Base = ebx
lgdt cs:gdtreg
01/29/15 Protected Mode Assignment 14
Switch To Protected Mode
cr0<PE> = 1
{
eax = cr0
or al,01
cr0 = eax
}
jump to Protected Mode
pm:
es = 10
ds = 18
display as before using si di
pm:
rmd:
01/29/15 Protected Mode Assignment 15
Switch To Protected Mode
cr0<PE> = 1
{
eax = cr0
or al,01
` cr0 = eax
}
db oeah
dw pm
dw 08h
pm:
es = 10
ds = 18
display as before using si di
pm:
rmd:
01/29/15 Protected Mode Assignment 16
Main Programme Body
CR0<PE> = 0
jmp dword ptr realadd
rmd:
Display Data in Real Mode
Exit using int 21(4ch)
pm:
rmd:

More Related Content

Similar to Real to protected_mode

5asm the stackandsubroutines
5asm the stackandsubroutines5asm the stackandsubroutines
5asm the stackandsubroutinesRabi Iftikhar
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기Ji Hun Kim
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisitionazhar557
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasScyllaDB
 
Vectorization on x86: all you need to know
Vectorization on x86: all you need to knowVectorization on x86: all you need to know
Vectorization on x86: all you need to knowRoberto Agostino Vitillo
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3Motaz Saad
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksJinTaek Seo
 
Application specific Programming of the Texas Instruments ...
Application specific Programming of the Texas Instruments  ...Application specific Programming of the Texas Instruments  ...
Application specific Programming of the Texas Instruments ...butest
 
15CSL48 MP&MC manual
15CSL48 MP&MC manual15CSL48 MP&MC manual
15CSL48 MP&MC manualRLJIT
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)PROIDEA
 

Similar to Real to protected_mode (20)

ERTS UNIT 3.ppt
ERTS UNIT 3.pptERTS UNIT 3.ppt
ERTS UNIT 3.ppt
 
5asm the stackandsubroutines
5asm the stackandsubroutines5asm the stackandsubroutines
5asm the stackandsubroutines
 
Switching 2
Switching 2Switching 2
Switching 2
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Vectorization on x86: all you need to know
Vectorization on x86: all you need to knowVectorization on x86: all you need to know
Vectorization on x86: all you need to know
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
chapter 4
chapter 4chapter 4
chapter 4
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 
Application specific Programming of the Texas Instruments ...
Application specific Programming of the Texas Instruments  ...Application specific Programming of the Texas Instruments  ...
Application specific Programming of the Texas Instruments ...
 
XS Boston 2008 Debugging Xen
XS Boston 2008 Debugging XenXS Boston 2008 Debugging Xen
XS Boston 2008 Debugging Xen
 
15CSL48 MP&MC manual
15CSL48 MP&MC manual15CSL48 MP&MC manual
15CSL48 MP&MC manual
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
 

More from Akshay Nagpurkar (20)

4.osi model
4.osi model4.osi model
4.osi model
 
L6 mecse ncc
L6 mecse nccL6 mecse ncc
L6 mecse ncc
 
Tcp ip
Tcp ipTcp ip
Tcp ip
 
1 ip address
1 ip address1 ip address
1 ip address
 
1.network topology
1.network topology1.network topology
1.network topology
 
1.lan man wan
1.lan man wan1.lan man wan
1.lan man wan
 
Dcunit4 transmission media
Dcunit4 transmission mediaDcunit4 transmission media
Dcunit4 transmission media
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
 
234 rb trees2x2
234 rb trees2x2234 rb trees2x2
234 rb trees2x2
 
Ppl home assignment_unit4
Ppl home assignment_unit4Ppl home assignment_unit4
Ppl home assignment_unit4
 
Ppl home assignment_unit5
Ppl home assignment_unit5Ppl home assignment_unit5
Ppl home assignment_unit5
 
3 multiplexing-wdm
3 multiplexing-wdm3 multiplexing-wdm
3 multiplexing-wdm
 
2 multiplexing
2 multiplexing2 multiplexing
2 multiplexing
 
1 multiplexing
1 multiplexing1 multiplexing
1 multiplexing
 
Pcm pulse codemodulation-2
Pcm pulse codemodulation-2Pcm pulse codemodulation-2
Pcm pulse codemodulation-2
 
Modulation techniq of modem
Modulation techniq of modemModulation techniq of modem
Modulation techniq of modem
 
Ppl home assignment_unit3
Ppl home assignment_unit3Ppl home assignment_unit3
Ppl home assignment_unit3
 
Ppl home assignment_unit2
Ppl home assignment_unit2Ppl home assignment_unit2
Ppl home assignment_unit2
 

Recently uploaded

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Recently uploaded (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

Real to protected_mode

  • 1. 01/29/15 Protected Mode Assignment 1 Switching from Real to Protected Mode • Programme Assignments • Define Global Descriptor Table • Main Programme Body 0000h 4Gb x00h
  • 2. 01/29/15 Protected Mode Assignment 2 Programme Assignments .386p Code segment use16 Assume cs: code , ss: stack realadd dd 0 taskadd dd 0 msg0 db ‘ in Real Mode ‘,0 msg1 db ‘ in Protected Model Mode ‘,0 msg2 db ‘ Back in Real Mode ‘,0 msg3 db ‘ < Your own declarations> ‘,0 x00h
  • 3. 01/29/15 Protected Mode Assignment 3 Define Global Descriptor Table Code Segment cs_32 Data Segment ds_32 Extra Segment es_32
  • 4. 01/29/15 Protected Mode Assignment 4 Define Global Descriptor Table <Code Segment cs_32> ------------------------------------------------------------------------------------------ cs_32: ; 08h ----------------------------------------------------------------------------- dw 0ffffh ; segment Limit c1: dw 00h ; Base Address 15:00 c2: db 00h ; Base Address 23:16 db 09Ah : b ’1001 1010’ db 00h ; b ‘ 0000 0000’ C3 db 00h ; Base Address 24:31 ---------------------------------------------------------------------------------------------
  • 5. 01/29/15 Protected Mode Assignment 5 Define Global Descriptor Table <Extra Segment es_32> ------------------------------------------------------------------------------------------ es_32: ; 10h ------------------------------------------------------------------------------------------ dw 0ffffh ; segment Limit e1: dw 8000h ; Base Address 15:00 e2: db 0bh ; Base Address 23:16 db 092h : b ’1001 1010’ db 00h ; b ‘ 0000 0000’ e3 db 00h ; Base Address 24:31 ---------------------------------------------------------------------------------------------
  • 6. 01/29/15 Protected Mode Assignment 6 Define Global Descriptor Table <Data Segment ds_32> ------------------------------------------------------------------------------------------ ds_32: ; 18h ------------------------------------------------------------------------------------------ dw 0ffffh ; segment Limit d1: dw 0000h ; Base Address 15:00 d2: db 00h ; Base Address 23:16 db 092h : b ’1001 1010’ db 00h ; b ‘ 0000 0000’ d3 db 00h ; Base Address 24:31 ---------------------------------------------------------------------------------------------
  • 7. 01/29/15 Protected Mode Assignment 7 Global Descriptor Table x00h cs_32 es_32 ds_32 gdt_Start cs_32(08h) es_32(10h) ds_32(18h) gdt_End Null Desc(0h)
  • 8. 01/29/15 Protected Mode Assignment 8 Global Descriptor Table x00h gdt_start: cs_32: es_32: ds_32: gdt_end: gdt_reg label fword gdt_limit dw gdt_end - gdt_start gdt_base dd 0 cs_32(08h) es_32(10h) ds_32(18h) gdt_End Null Desc(0h) gdt_Start
  • 9. 01/29/15 Protected Mode Assignment 9 Main Programme Body Begin: Display Some Message (Graphics Mode) Set up Global Descriptor Table Load Global Descriptor Table Register Switch to Protected Mode Jump to Protected Mode Display Message Switch to Real Mode Exit: pm: rmd:
  • 10. 01/29/15 Protected Mode Assignment 10 Display Some Message (Graphics Mode) Graphics Display B800h es = B800 ds = cs clear screen si = msg0 di = (80 * Lines(hor) ) * 2 cx = length of Msg Loop es: [di] = al = [si] inc si ; inc di loop cx
  • 11. 01/29/15 Protected Mode Assignment 11 Display Some Message (Graphics Mode) ax = cs lea si, realadd mov word ptr [si+2],ax lea ax,[rmd] mov word ptr [si],ax pm: rmd:
  • 12. 01/29/15 Protected Mode Assignment 12 Set up Global Descriptor Table ax = cs eax << ax ebx << eax ebx << 4 ; Address is 20 bits eax = ebx c1 = d1 = ax eax >> 16 ; Shift Right by 16 d2 = c2 = al d3 = c3 = ah ---------------------------------------------------------------------- c1 , d1 c2 d2c3 , d3
  • 13. 01/29/15 Protected Mode Assignment 13 Load Global Descriptor Table Register ---------------------------------------------------------------------------------- eax = ax = cs eax << 4 ebx << bx = gdt_Start ebx = eax + ebx cs:gdt_Base = ebx lgdt cs:gdtreg
  • 14. 01/29/15 Protected Mode Assignment 14 Switch To Protected Mode cr0<PE> = 1 { eax = cr0 or al,01 cr0 = eax } jump to Protected Mode pm: es = 10 ds = 18 display as before using si di pm: rmd:
  • 15. 01/29/15 Protected Mode Assignment 15 Switch To Protected Mode cr0<PE> = 1 { eax = cr0 or al,01 ` cr0 = eax } db oeah dw pm dw 08h pm: es = 10 ds = 18 display as before using si di pm: rmd:
  • 16. 01/29/15 Protected Mode Assignment 16 Main Programme Body CR0<PE> = 0 jmp dword ptr realadd rmd: Display Data in Real Mode Exit using int 21(4ch) pm: rmd: