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

📄 pm2b.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
;===========================
        call  cls_text
        call  print_time
        mov   esi,nextline
        call  print_string
        call  print_date
m0:
        
       
   jmp m0

nogo: 
        jmp  nogo
convert:
       pusha                            ;start of convert
       mov  ah,al                   ;copy AL to AH
       and  ax,0f00fh               ;mask bits
       mov  cl,4                    ;CL=04 for shift
       shr  ah,cl                   ;shift right AH to get unpacked BCD
       or   ax, 3030h               ;combine with 30 to get ASCII
       xchg ah,al                   ;swap for ASCII storage convention
       mov  [val],ax                ;store the ASCII value in VAL
       popa 
       ret

;===============================================================================================;
; 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 + -