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

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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.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)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

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: