home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 October
/
VPR9710A.ISO
/
BENCH
/
DJ1SRC_K
/
105
/
TABLES.ASM
< prev
next >
Wrap
Assembly Source File
|
1997-05-01
|
3KB
|
163 lines
; This is file TABLES.ASM
;
; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
;
; This file is distributed under the terms listed in the document
; "copying.dj", available from DJ Delorie at the address above.
; A copy of "copying.dj" should accompany this file; if not, a copy
; should be available from where this file was obtained. This file
; may not be distributed without a verbatim copy of "copying.dj".
;
; This file is distributed WITHOUT ANY WARRANTY; without even the implied
; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;
; 97/05/01 Kimio Itoh(kitoh@nn.iij4u.or.jp) modified
; for reduce binary size and for dead code elimination.
; History:20,1
title tables
.386p
include build.inc
include segdefs.inc
include tss.inc
include gdt.inc
include idt.inc
;------------------------------------------------------------------------
start_data16
extrn _tss_ptr:word
extrn _was_exception:word
extrn _npx:byte
public ivec_number
ivec_number dw ?
has_error db 0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0
end_data16
;------------------------------------------------------------------------
.286c
start_bss
public _gdt
_gdt label gdt_s
db type gdt_s * g_num dup (?)
public _idt
_idt label idt_s
db type idt_s * 256 dup (?)
public _i_tss
_i_tss label tss_s
db type tss_s dup (?)
end_bss
.386p
;------------------------------------------------------------------------
start_code16
sound macro
local wait_loop
local wait_loop1
mov al,033h
out 061h,al
mov ecx,100000h
wait_loop:
loopd wait_loop
mov al,032h
out 61h,al
mov ecx,100000h
wait_loop1:
loop wait_loop1
endm
public _ivec0, _ivec1
_ivec0:
push ds ; 1 byte
call ivec_common ; 3 bytes
_ivec1:
rept 255
push ds ; 1 byte
call ivec_common ; 3 bytes
endm
ivec_common:
push g_rdata
pop ds
pop ivec_number
sub ivec_number, offset _ivec1; pushes address *after* call
shr ivec_number, 2
pop ds
jmpt g_itss
public _interrupt_common
_interrupt_common:
cli
mov bx,g_rdata
mov ds,bx
mov bx,_tss_ptr
mov ax,ivec_number
mov [bx].tss_irqn,al
mov esi,[bx].tss_esp
mov fs,[bx].tss_ss ; fs:esi -> stack
cmp al,16
ja has_no_error
mov di,ax
cmp has_error[di],0
je has_no_error
mov eax,fs:[esi]
mov [bx].tss_error,eax
add esi,4
has_no_error:
mov eax,fs:[esi] ; eip
mov [bx].tss_eip,eax
mov eax,fs:[esi+4]
mov [bx].tss_cs,ax
mov eax,fs:[esi+8]
mov [bx].tss_eflags,eax
add esi,12
mov [bx].tss_esp,esi ; store corrected stack pointer
mov _was_exception,1
jmpt g_ctss ; pass control back to real mode
cli
jmp _interrupt_common ; it's a task
extrn graphics_fault:near
public _page_fault
_page_fault:
cli
mov bx,g_rdata
mov ds,bx
mov es,bx
mov eax,cr2
cmp eax,0e0000000h
jb regular_pf
cmp eax,0e0300000h
ja regular_pf
jmp graphics_fault
regular_pf:
mov bx,_tss_ptr
mov [bx].tss_irqn,14 ; page fault
mov [bx].tss_cr2,eax
pop eax
mov [bx].tss_error,eax
mov eax,0
mov cr2,eax ; so we can tell INT 0D from page fault
mov _was_exception,1
jmpt g_ctss
jmp _page_fault
end_code16
;------------------------------------------------------------------------
end