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

📄 pmcd1.inc

📁 TestOS - 带简单GUI的DOS扩展OS// 源代码// ASM// 英文
💻 INC
字号:
;=========================================================;
; 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'
include "Ata_Atapi16.inc"
include 'A20.inc'             ;trying
start:	
        push  cs
	pop   ds
        push  ds
        pop   es
        call  GetAtaPiDrive
        call  Atapi_Address
        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   ss,ax
        nop
	mov   es,ax
	mov   fs,ax
	mov   gs,ax
	
;-----------------------------
        mov   ax,linear_sel
	mov   es,ax
      ;  mov   gs,ax
        
        jmp   inc_over2
;------------------------------
      ;  include 'TextMode.inc'
        include 'errors.inc'
        include 'msg.inc'
        include 'pic.inc'
        include 'isr.asm'
        include 'keyboard.inc'
        include 'keymaps.inc'
        include 'TextMode.inc'
        include 'TimeDate.inc'
;-------------------------------
        include 'Fdd.inc'
        include 'CdPlayer.inc'
        include 'vesa2_info.inc'
        include 'Ata_Atapi39.inc'
;------------------------------
inc_over2:        
	call  remap_pic
        call  unmask_irqs
        
       ; mov   ax,linear_sel
	;mov   es,ax
      ;  mov   ds,ax
;===========================
        jmp   inc_over3
;-------------------------------
       ; include 'Fdd.inc'
       ; include 'CdPlayer.inc'
       ; include 'vesa2_info.inc'
       ; include 'Ata_Atapi33.inc'
;-------------------------------
      
inc_over3:
        call  Fdd_motor_off
        ;call  Cd_player
;---------------------------------------------------------
pushad

   mov ax, 36  ;cx      ; ax = sector number
   mov bx, 18      ; bx = number of sectors per track
   div bx         ; al = ax / bx
   mov cl, al      ; cl = real sector number (cl is used by int 13)

   ; compute the head number: (sector_number/sector_per_track) just in ax mod number_of_heads
   ; and the track number:    (sector_number/sector_per_track) / number_of_heads

   xor ah, ah      ; del the rest of the div before
   mov bx, 2      ; bx = number of heads
   div bx         ; ah = rest of ( ax / bx ), al = ax / bx
   call  write_hex32
popad
;--------------------------------------------------------------
   mov ax, 10  ;cx      ; ax = sector number
   mov bx, 18      ; bx = number of sectors per track
   div bx         ; al = ax / bx
   mov cl, al      ; cl = real sector number (cl is used by int 13)

   ; compute the head number: (sector_number/sector_per_track) just in ax mod number_of_heads
   ; and the track number:    (sector_number/sector_per_track) / number_of_heads

   xor ah, ah      ; del the rest of the div before
   mov bx, 2      ; bx = number of heads
   div bl         ; ah = rest of ( ax / bx ), al = ax / bx
   call  write_hex32 
    
nogo: 
        jmp   nogo

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

RealModeCS:
	dw 0



;include 'A20.inc'
;include 'pic.inc'
;include 'msg.inc'
;include 'vesa2_info.inc'
;include 'TextMode.inc'
;include 'keyboard.inc'
;include 'keymaps.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'	
;include "Ata_Atapi33.inc"

⌨️ 快捷键说明

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