;	     32BIT  DOS  EXTENDER
;
; Written by Adam Seychell 	Wed 8-25-1993
;

.386

DATA32	SEGMENT PUBLIC 'data'	use32
CODE32_sel	dw 50h		; Selector Values
CODE16_sel	dw 58h
DATA_sel	dw 60h
TheSTACK_sel	dw 30h
VIDEO_sel	dw 28h
FLAT_CODE32_sel	dw 10h
FLAT_DATA_sel	dw 08h
XMS_sel		dw 18h
BASE_sel	dw 20h
PSP_sel		dw 48h

xms_usage	dd 0		; Requested size of XMS block in bytes.
xms_base	dd ?		; Linear base address of the XMS block.
Base_Segment	dw ?		; Real mode segment value for base memory.
PSP_segment	dw ?		; Real mode segment value for PSP segment.

align 4
v86_mesg   db ' Message printed in v86 mode ',10,13,36

DATA32 ENDS

CODE32	SEGMENT PUBLIC 'CODE' USE32
assume	DS:DATA32 , CS:CODE32

include		dos32.inc
start32:		; 32 bit code entry point.    DS -> data descripor

	mov	es,[xms_sel]		;Must load these with valid selectors
	mov	fs,[FLAT_DATA_sel]
	mov	gs,[video_sel]
        sti

		; Example to call a real mode interrupt

        mov	SS:real_DS,DATA32		; Set the DS reg for V86 mode
        mov 	edx,offset v86_mesg
	mov	ah,9
        dosint	21h


	mov ah,4ch		; Termiate the program
        int 21h


; The 16 hardware inetrrupts.
; If an IRQ accours in V86 mode the segment registers will contain same
; selector values as they were before the last V86 call. ( i.e dosint xx ).
IRQ0:	dosint 08h                      ;  8253  Timer 0
	iretd
IRQ1:	dosint 09h			;  8242 Keyboard
	iretd
IRQ2:	dosint 0Ah                      ; LPT 2 or  Vert Retrate (6845)
	iretd
IRQ3:	dosint 0Bh			; Serial communications ports 2 & 4
	iretd
IRQ4:	dosint 0Ch			; Serial communications ports 1 & 3
	iretd
IRQ5:	dosint 0Dh			; Reserved
	iretd
IRQ6:	dosint 0Eh			; NEC æPD765 Floppy Disk Controler
	iretd
IRQ7:	dosint 0Fh                      ; LPT 1
	iretd
IRQ8:	dosint 70h			; 6818 CMOS CLOCK
	iretd
IRQ9:	dosint 71h			; Reserved
	iretd
IRQ10:	dosint 72h			; Reserved
	iretd
IRQ11:	dosint 73h			; Reserved
	iretd
IRQ12:	dosint 74h			; Reserved
	iretd
IRQ13:	dosint 75h			; 80x87 Math Co-Pro exception.
	iretd
IRQ14:	dosint 76h			; Hard Drive Cotroller.
	iretd
IRQ15:	dosint 77h			; Reserved
	iretd


CODE32 ENDS

END