⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pm2a.asm

📁 TestOS - 带简单GUI的DOS扩展OS// 源代码// ASM// 英文
💻 ASM
字号:
;=========================================================;
; Real/Pmode                                     11/12/03 ;
;---------------------------------------------------------;
; DOS EXTREME OS V0.01                                    ;
; by Craig Bamford.                                       ;
;                                                         ;
; fasm pm os test EXE program  (DOS EXTREME)              ;
; fasm pm.asm pm.exe                                      ;
;                                                         ;                      
; Thanks to: Tomasz Grysztar,Christopher Giese            ;
; Alexei A. Frounze, smaffy.                              ;
;                                                         ;
;=========================================================;
format MZ		; code starts at offset 100h
;===============================================================================================;
;	16-bit real mode
;===============================================================================================;
	use16

        jmp  start

include '386.inc'

start:	
        push cs
	pop  ds
        call enable_A20
        xor  ebx,ebx
	mov  bx,ds                                                  ; BX=segment
	shl  ebx,4                                                  ; BX="linear" address of segment base
	mov  eax,ebx
	mov  [sys_code_1 + 2],ax                                    ; set base address of 32-bit segments
	mov  [sys_data_1 + 2],ax
	mov  [Real_code_1 + 2],ax                                   ; set base address of 16-bit segments
	mov  [Real_data_1 + 2],ax
	shr  eax,16
	mov  [sys_code_1 + 4],al
	mov  [sys_data_1 + 4],al
	mov  [Real_code_1 + 4],al
	mov  [Real_data_1 + 4],al

	mov  [sys_code_1 + 7],ah
	mov  [sys_data_1 + 7],ah
	mov  [Real_code_1 + 7],ah
	mov  [Real_data_1 + 7],ah

        add  ebx,gdt		                                  ; EBX=linear address of gdt
	mov  [gdtr + 2],ebx
	add  ebx,idt - gdt	                                  ; EBX=linear address of idt
	mov  [idtr + 2],ebx
        cli

	mov  ax,cs
	mov  [RealModeCS],ax
	

	mov  ax,0xB800
	mov  es,ax

	lgdt [gdtr]                                               ; VLoad the GDTR with the base address and limit of the GDT
        lidt [idtr]
	mov  eax,cr0                                              ; Set the PE [protected mode enable] bit in register CR0 
	or   al,1
	mov  cr0,eax
        

	jmp  sys_code:do_pm                                       ; jumps to do_pm


;===============================================================================================;
;	32-bit protected mode
;===============================================================================================;
use32
do_pm:

        xor  edi,edi
        xor  esi,esi

	mov  ax,sys_data
        mov  ds,ax
	mov  es,ax
	mov  fs,ax
	mov  gs,ax
	mov  ss,ax
        
	call remap_pic
        call unmask_irqs
        
        mov  ax,linear_sel
	mov  es,ax
        
        mov edi,0xb8000
        mov esi, stringZ
        call print_string

        mov esi, stringZ1
        call print_string

        mov esi, stringZ2
        call print_string

        mov esi, stringZ3
        call print_string

        mov esi, stringZ4
        call print_string
        ; call scroll
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
         mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
         mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
         mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ3
        call print_string
        mov esi, stringZ1
        call print_string
        mov esi, stringZ1
        call print_string
        call   cls_text
       ; mov edi,0xb8000
        mov esi, stringZ2
        call print_string

       ; mov  al,[screen_x]
       ; mov  ah,[screen_y]
        ;call set_cursor_pos
	; al = x, ah = y
	;mov  byte [es:dword 0xB8000],'0'

	;lea  esi,[msg1]                                             ; -> "Finally in protected mode!"
	;mov  edi,0xB8000 + (80 * 3 + 4) * 2                         ; row 3, column 4
	;mov  ecx,52
	;cld
	;rep  movsb
        
nogo: 
        jmp  nogo

;===============================================================================================;
; data
;===============================================================================================;
RealModeIP:
        dw 0

RealModeCS:
	dw 0

include 'A20.inc'
include 'pic.inc'
include 'msg.inc'
include 'TextMode.inc'
include 'errors.inc'
include 'isr.asm'
include 'TimeDate.inc'
;===============================================================================================;
;	global descriptor table (GDT)
;===============================================================================================;
gdtr:	dw gdt_end - gdt - 1	                                  ; GDT limit
	dd gdt                                                    ; (GDT base gets set above)

include 'gdt.asm'
;===============================================================================================;
;	interrupt descriptor table (IDT)
;===============================================================================================;

idtr:	dw idt_end - idt - 1	                                 ; IDT limit
	dd idt	

include 'idt.asm'	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -