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

📄 itable.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
字号:
;**************************************************************************
;*                                                                        *
;*  ITABLE.ASM                                                            *
;*                                                                        *
;*  Copyright (c) 1999 National Semiconductor Corporation.                *
;*  All Rights Reserved.                                                  *
;*                                                                        *
;*  Function:                                                             *
;*      Default interrupt table.                                          *
;*                                                                        *
;*  $Revision:: 7                                                         $
;**************************************************************************

.486P

	INCLUDE MACROS.INC   	; Macros used throughout
	INCLUDE DEF.INC	 	; EQU Definitions
	INCLUDE PORT80.INC	; Post code Definitions

_TEXT SEGMENT PUBLIC use16 'CODE'
	EXTERN genericInt15:NEAR

;**************************************************************************
;*
;*	set_timer
;*
;*	pulse count = 1193180/(desired # of ticks per second)
;*	standard 18.2 ticks/sec = 1193180/18.2 = 65535 -> so set pulse
;*	count to 0 for 10000 ticks/sec, 1193180/10000 = 119.3 or
;*	approx. 0077h
;*
;*	Entry:
;*	  AX = pulse count value
;*
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
set_timer	PROC	NEAR
	cli
	push	ax
	mov	al, RW_CMD
	out	CMD_REG, al
	pop	ax

	out	CHAN_0, al
	mov	al,ah
	IOPAUSE
	out	CHAN_0, al
	IOPAUSE
	sti
	ret
set_timer	ENDP

ITABLE_FUNC struct 1
	INT_NUM		db ?
	INT_HANDLER	dw ?
ITABLE_FUNC  ENDS

;**************************************************************************
;*
;*	intTable
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
intTable PROC NEAR PUBLIC
	push	bx
	push	ax
	push	ds

; clear the equipment list in the bda
	push	40h
	pop	ds

	xor	ax, ax
	mov	ds:[10h], ax

	; also clear keyboard status flags
	mov ds:[17h], al
	mov ds:[18h], al
	mov ds:[96h], al

	; set memsize in bda since Disk-On-Chip uses it
	mov	ax, 027fh
	mov	ds:[13h], ax

	xor	ax, ax
	
;loop through interrupt vector table writing them all to
;the generic interrupt handler, 
	xor	bx, bx
	push	bx
	pop	ds

	mov	ah, 0f0h
	rol	eax, 16
	mov	ax, OFFSET genericInterrupt

GenericTable:
	mov	ds:[bx], eax
	add	bx, 4
	cmp	bx, 0400h 		; 256 int's
	jne	GenericTable

; then loop through and program all the ones we have handlers for
; all must be in the f000 segment
	mov	si, OFFSET ITABLE
HandledInts:
	xor	bx, bx
	mov	bl, BYTE PTR cs:(ITABLE_FUNC PTR [si]).INT_NUM
	shl	bx, 2

	mov	ax, WORD PTR cs:(ITABLE_FUNC PTR [si]).INT_HANDLER
	cmp	ax, 0ffffh 		; there shouldn't ever be a handler at f000:ffff
	jz	IntsProgrammed

	mov	ds:[bx], ax
	add	si, size ITABLE_FUNC
	jmp	HandledInts

IntsProgrammed:
	mov	al, 011h		; Enable PIC for PC usage
	out	PIC_MASTER_PORT0, al	; icw1
	out	PIC_SLAVE_PORT0, al

	mov	al, 08h			; icw2
	out	PIC_MASTER_PORT1, al
	mov	al, 070h
	out	PIC_SLAVE_PORT1, al

	mov	al, 04h			; icw3
	out	PIC_MASTER_PORT1, al
	mov	al, 02h
	out	PIC_SLAVE_PORT1, al

	mov	al, 01h			; icw4
	out	PIC_MASTER_PORT1, al
	out	PIC_SLAVE_PORT1, al

;;; in a WBT system this is not needed,  QNX etc... would probably like this.
	mov	ax, 0			; set back to 18.2 ticks/sec
	call	set_timer

	mov	dx, 21h
	in	al, dx
	mov	al, 10111000b

	IOPAUSE
	out	dx, al

	mov	dx, 0A1h
	in	al, dx
	mov	al, 11011111b
	IOPAUSE
	out	dx, al

	sti
	pop	ds
	pop	ax
	pop	bx
	jmp 	bx
intTable ENDP


ITABLE:
ITABLE_FUNC <000h, OFFSET int00p>
ITABLE_FUNC <001h, OFFSET int01p>
ITABLE_FUNC <002h, OFFSET int02p>
ITABLE_FUNC <003h, OFFSET int03p>
ITABLE_FUNC <004h, OFFSET int04p>
ITABLE_FUNC <005h, OFFSET int05p>
ITABLE_FUNC <006h, OFFSET int06p>
ITABLE_FUNC <007h, OFFSET int07p>
ITABLE_FUNC <008h, OFFSET int8_handler>
ITABLE_FUNC <009h, OFFSET hardwareInt1>
ITABLE_FUNC <00ah, OFFSET hardwareInt2>
ITABLE_FUNC <00bh, OFFSET hardwareInt3>
ITABLE_FUNC <00ch, OFFSET hardwareInt4>
ITABLE_FUNC <00dh, OFFSET hardwareInt5>
ITABLE_FUNC <00eh, OFFSET hardwareInt6>
ITABLE_FUNC <00fh, OFFSET hardwareInt7>
ITABLE_FUNC <015h, OFFSET genericInt15>
ITABLE_FUNC <016h, OFFSET int16p>
ITABLE_FUNC <070h, OFFSET hardwareInt8>
ITABLE_FUNC <071h, OFFSET hardwareInt9>
ITABLE_FUNC <072h, OFFSET hardwareInt10>
ITABLE_FUNC <073h, OFFSET hardwareInt11>
ITABLE_FUNC <074h, OFFSET hardwareInt12>
ITABLE_FUNC <075h, OFFSET hardwareInt13>
ITABLE_FUNC <076h, OFFSET hardwareInt14>
ITABLE_FUNC <077h, OFFSET hardwareInt15>
ITABLE_FUNC <000h, 0ffffh>


;**************************************************************************
;*
;*	genericInterrupt
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
genericInterrupt	PROC FAR PUBLIC
	iret
genericInterrupt	ENDP

;**************************************************************************
;*
;*	hardwareIntHigh
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
hardwareIntHigh	PROC FAR PUBLIC
	cli
	out	080h,al

	mov	al, 020h
	out	0A0h, al		; End of Int 
	out	020h, al		; End of Int

	pop	ax
	sti
	iret
hardwareIntHigh	ENDP

;**************************************************************************
;*
;*	hardwareIntLow
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
hardwareIntLow	PROC FAR PUBLIC

	cli
	out	080h,al

	mov	al, 020h
	out	020h, al		; End of Int

	pop	ax
	sti
	iret
hardwareIntLow	ENDP

;**************************************************************************
;*
;*	intxxp
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
intxxp	PROC NEAR
	out	080h,al
	nop
	pop	ax

	out	080h,al
	xchg	al, ah
	out	080h, al
	xchg	al, ah
	jmp	genericInterrupt

intxxp	ENDP


int00p PROC NEAR
	push	ax
	mov	al, 000h
	jmp	intxxp
int00p ENDP

int01p PROC NEAR
	push	ax
	mov	al, 001h
	jmp	intxxp
int01p ENDP

int02p PROC NEAR
	push	ax
	mov	al, 002h
	jmp	intxxp
int02p ENDP

int03p PROC NEAR
	push	ax
	mov	al, 003h
	jmp	intxxp
int03p ENDP

int04p PROC NEAR
	push	ax
	mov	al, 004h
	jmp	intxxp
int04p ENDP

int05p PROC NEAR
	push	ax
	mov	al, 005h
	jmp	intxxp
int05p ENDP

int06p PROC NEAR
	; no since in running more code after an int6
	mov	al, 006h
	out	080h,al
	nop
	pop	ax

	out	080h,al
	xchg	al, ah
	out	080h, al
	xchg	al, ah

	; Halt everything here
	jmp $
int06p ENDP

int07p PROC NEAR
	push	ax
	mov	al, 007h
	jmp	intxxp
int07p ENDP

;**************************************************************************
;*
;*	int8_handler
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
int8_handler PROC NEAR
	push	eax
	push	ecx
	push	ds
	push	dx
	push	bx
	mov	ax, 40h
	mov	ds, ax
	ASSUME	ds:nothing

	inc	WORD PTR ds:[6Ch]
	jnz	check_rollover
	inc	WORD PTR ds:[6Eh]

check_rollover:
	cmp	WORD PTR ds:[6Eh], 018h
	jnz	time_flop
	cmp	WORD PTR ds:[6Ch], 0b0h
	jnz	time_flop

	mov	WORD PTR ds:[6Eh], 0
	mov	WORD PTR ds:[6Ch], 0
	mov	BYTE PTR ds:[70h], 1

time_flop:	cmp	BYTE PTR ds:[40h], 0
	je	time_flop_done
	dec	BYTE PTR ds:[40h]
	jnz	time_flop_done
	mov	dx, 3f2h
	mov	al, 0
	out	dx, al
	and	BYTE PTR ds:[3fh], 0f0h

time_flop_done:
	int	1ch

	mov	al, 20h
	out	20h, al

	pop	bx
	pop	dx
	pop	ds
	pop	ecx
	pop	eax
	iret
int8_handler ENDP

int16p PROC NEAR
; This is a fake keyboard handler which just makes sure DOS doesn't
; think the shift key is being held down (thus by-passing the startup
; files) when it boots up.
	mov	ax, 0000h		; clear flags so "shift" is not seen as pressed
	cmp	ax, 0000h		; make zero flag 1 ("no key is available")
	jmp	genericInterrupt
int16p ENDP

hardwareInt0   PROC NEAR
	push	ax
	mov	al, 000h
	jmp	hardwareIntLow
hardwareInt0   ENDP

hardwareInt1   PROC NEAR
	push	ax
	mov	al, 001h
	jmp	hardwareIntLow
hardwareInt1   ENDP

hardwareInt2   PROC NEAR
	push	ax
	mov	al, 002h
	jmp	hardwareIntLow
hardwareInt2   ENDP

hardwareInt3   PROC NEAR
	push	ax
	mov	al, 003h
	jmp	hardwareIntLow
hardwareInt3   ENDP

hardwareInt4   PROC NEAR
	push	ax
	mov	al, 004h
	jmp	hardwareIntLow
hardwareInt4   ENDP

hardwareInt5   PROC NEAR
	push	ax
	mov	al, 005h
	jmp	hardwareIntLow
hardwareInt5   ENDP

hardwareInt6   PROC NEAR
	push	ax
	mov	al, 006h
	jmp	hardwareIntLow
hardwareInt6   ENDP

hardwareInt7   PROC NEAR
	push	ax
	mov	al, 007h
	jmp	hardwareIntLow
hardwareInt7   ENDP

hardwareInt8   PROC NEAR
	push	ax
	mov	al, 008h
	jmp	hardwareIntHigh
hardwareInt8   ENDP

hardwareInt9   PROC NEAR
	push	ax
	mov	al, 009h
	jmp	hardwareIntHigh
hardwareInt9   ENDP

hardwareInt10  PROC NEAR
	push	ax
	mov	al, 010h
	jmp	hardwareIntHigh
hardwareInt10  ENDP

hardwareInt11  PROC NEAR
	push	ax
	mov	al, 011h
	jmp	hardwareIntHigh
hardwareInt11  ENDP

hardwareInt12  PROC NEAR
	push	ax
	mov	al, 012h
	jmp	hardwareIntHigh
hardwareInt12  ENDP

hardwareInt13  PROC NEAR
	push	ax
	mov	al, 013h
	jmp	hardwareIntHigh
hardwareInt13  ENDP

hardwareInt14  PROC NEAR
	push	ax
	mov	al, 014h
	jmp	hardwareIntHigh
hardwareInt14  ENDP

hardwareInt15  PROC NEAR
	push	ax
	mov	al, 015h
	jmp	hardwareIntHigh
hardwareInt15  ENDP


_TEXT ENDS

END

⌨️ 快捷键说明

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