1 ; part of virtual processor, emulator for FIFTH.
\r
16 badcpu db 'required 80386 or better',24h
\r
26 badmode db 'error: CPU in protected mode',24h
\r
28 mov ax,4300h ; check for XMS
\r
30 cmp al,80h ; XMS present?
\r
36 badxms db 'error: HIMEM.SYS not loaded',24h
\r
41 mov word [irq_5+2],es
\r
49 mov ax,4310h ; get XMS driver address
\r
51 mov word [xms_call],bx ; store XMS driver address
\r
52 mov word [xms_call+2],es
\r
54 mov ah,3 ; enable A20
\r
55 call far dword [xms_call]
\r
56 mov ah,8 ; get free extended memory size
\r
58 call far dword [xms_call]
\r
63 mov ah,9 ; allocate largest memory block
\r
64 call far dword [xms_call]
\r
66 mov ah,0Ch ; lock extended memory block
\r
67 call far dword [xms_call]
\r
70 mov [xms_addr],edx ; store memory block address
\r
77 mov ah, 0dh ; unlock extended memory block
\r
78 mov dx, [xms_handle]
\r
79 call far dword [xms_call]
\r
80 mov ah, 0ah ; free extended memory block
\r
81 call far dword [xms_call]
\r
84 mov dx, word [irq_5]
\r
85 mov ds, word [irq_5+2]
\r
92 mov al, 00001011b ; OCW3 - read IRQ in-service register
\r
95 test al, 00100000b ; is IRQ 5 in service?
\r
99 label irq_5 dword at $-4
\r
102 cli ; disable interrupts
\r
103 xor eax, eax ; calculate linear address of GDT
\r
107 mov dword [cs:GDTR+2],eax
\r
108 lgdt pword [cs:GDTR] ; load GDT register
\r
109 mov eax, cr0 ; switch to protected mode
\r
114 mov ax, 1 shl 3 ; load 32-bit data descriptor
\r
115 mov ds, ax ; to all data segment registers
\r
119 mov eax, cr0 ; switch back to real mode
\r
124 sti ; enable interrupts
\r
129 GDTR dw 2*8-1 ; limit of GDT
\r
130 dd ? ; linear address of GDT
\r
132 GDT rw 4 ; null descriptor
\r
133 dw 0FFFFh, 0, 9200h, 8Fh ; 32-bit data descriptor
\r
135 xms_call dd 0 ; XMS driver pointer
\r
136 xms_handle dw 0 ; handle of XMS memory block
\r
137 xms_addr dd 0 ; address to XMS block
\r