All pastes #495666 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-18 21:51 UTC
rendered paste body
	page 60, 132
	.386
	
	title	DOS Driver
	
DGROUP	group	_DATA, CONST, _BSS, _TEXT


_DATA	segment word public 'DATA'
	assume ds:DGROUP
		
		
; DEVICE HEADER
public	_deviceheader
	org	0
	
_deviceheader	label	word
next_dev	dd	-1
attribute	dw	0e000h
strategy	dw	DGROUP:_strategy
interrupt	dw	DGROUP:_interrupt
dev_name	db	'ASAD    '

; REQUEST HEADER
public	_rhptr
_rhptr		equ	$
rh_ofs		dw	?
rh_seg		dw	?

; BIG STACK
stack_ptr	dw	?
stack_seg	dw	?

newstack	db	100h dup(?)
newstacktop	label	word

_DATA	ends


CONST	segment word public 'CONST'
	assume ds:DGROUP
CONST	ends


_BSS	segment word public 'BSS'
	assume ds:DGROUP
_BSS	ends


_TEXT	segment word public 'CODE'
	assume cs:DGROUP,ds:DGROUP
	
public	_strategy
_strategy	proc	far
	
	mov	cs:rh_seg, es
	mov	cs:rh_ofs, bx
	ret
	
_strategy	endp


public	_interrupt
_interrupt	proc	far

	cld
	pusha
	
	; new big stack
	cli
	mov	cs:stack_ptr, sp
	mov	cs:stack_seg, ss
	mov	ax, cs
	mov	ss, ax
	mov	sp, newstacktop
	sti
	
	mov	ax, cs:rh_seg
	mov	es, ax
	mov	bx, cs:rh_ofs
	

	mov	ax, 0
	mov	al, es:[bx]+2	; request hdr command
	
	push	ax
	call	_isr_in_c
	
	; put old stack back
	cli
	mov	ss, cs:stack_seg
	mov	sp, cs:stack_ptr
	sti
	
	popa
	ret
	
	EXTRN	_isr_in_c:near
	
_interrupt	endp

_TEXT		ends
		end