home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / djgpp / go32 / tables.asm < prev    next >
Encoding:
Assembly Source File  |  1991-05-30  |  2.8 KB  |  154 lines

  1. ; This is file TABLES.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. ;    History:20,1
  16.     title    tables
  17.     .386p
  18.  
  19.     include    build.inc
  20.     include    segdefs.inc
  21.     include tss.inc
  22.     include gdt.inc
  23.     include idt.inc
  24.  
  25. ;------------------------------------------------------------------------
  26.  
  27.     start_data16
  28.  
  29.     extrn    _tss_ptr:word
  30.     extrn    _was_exception:word
  31.     extrn    _npx:byte
  32.  
  33.     public    _was_user_int
  34. _was_user_int    dw    0
  35.  
  36.     public    ivec_number
  37. ivec_number    db    ?
  38.  
  39. has_error    db    0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0
  40.  
  41.     end_data16
  42.  
  43. ;------------------------------------------------------------------------
  44.  
  45.     .286c
  46.     start_bss
  47.  
  48.     public    _gdt
  49. _gdt    label    gdt_s
  50.     db    type gdt_s * g_num dup (?)
  51.  
  52.     public    _idt
  53. _idt    label    idt_s
  54.     db    type idt_s * 256 dup (?)
  55.  
  56.     public    _i_tss
  57. _i_tss    label    tss_s
  58.     db    type tss_s dup (?)
  59.  
  60.     end_bss
  61.     .386p
  62.  
  63. ;------------------------------------------------------------------------
  64.  
  65.     start_code16
  66.  
  67. ivec    macro    n
  68.     push    ds
  69.     push    g_rdata
  70.     pop    ds
  71.     mov    ivec_number,n
  72.     pop    ds
  73.     db    0eah
  74.     dw    0, g_itss
  75.     endm
  76.  
  77.     public    _ivec0, _ivec1
  78. _ivec0:
  79.     ivec 0
  80. _ivec1:
  81.     x=1
  82.     rept 255
  83.      ivec x
  84.      x=x+1
  85.     endm
  86.  
  87.     public    _interrupt_common
  88. _interrupt_common:
  89.     cli
  90.     mov    bx,g_rdata
  91.     mov    ds,bx
  92.     mov    bx,_tss_ptr
  93.     mov    al,ivec_number
  94.     mov    [bx].tss_irqn,al
  95.     mov    esi,[bx].tss_esp
  96.     mov    fs,[bx].tss_ss        ; fs:esi -> stack
  97.     cmp    al,16
  98.     ja    has_no_error
  99.     mov    ah,0
  100.     mov    di,ax
  101.     cmp    has_error[di],0
  102.     je    has_no_error
  103.     mov    eax,fs:[esi]
  104.     mov    [bx].tss_error,eax
  105.     add    esi,4
  106. has_no_error:
  107.     mov    eax,fs:[esi]        ; eip
  108.     mov    [bx].tss_eip,eax
  109.     mov    eax,fs:[esi+4]
  110.     mov    [bx].tss_cs,ax
  111.     mov    eax,fs:[esi+8]
  112.     mov    [bx].tss_eflags,eax
  113.     add    esi,12
  114.     mov    [bx].tss_esp,esi    ; store corrected stack pointer
  115.  
  116.     mov    _was_exception,1
  117.  
  118.     jmpt    g_ctss            ; pass control back to real mode
  119.     jmp    _interrupt_common    ; it's a task
  120.  
  121.     extrn    graphics_fault:near
  122.  
  123.     public    _page_fault
  124. _page_fault:
  125.     cli
  126.     mov    bx,g_rdata
  127.     mov    ds,bx
  128.     mov    es,bx
  129.     mov    eax,cr2
  130. if 1
  131.     cmp    eax,0e0000000h
  132.     jb    regular_pf
  133.     cmp    eax,0e0300000h
  134.     ja    regular_pf
  135.     jmp    graphics_fault
  136. regular_pf:
  137. endif
  138.     mov    bx,_tss_ptr
  139.     mov    [bx].tss_irqn,14    ; page fault
  140.     mov    [bx].tss_cr2,eax
  141.     pop    eax
  142.     mov    [bx].tss_error,eax
  143.  
  144.     mov    _was_exception,1
  145.  
  146.     jmpt    g_ctss
  147.     jmp    _page_fault
  148.  
  149.     end_code16
  150.  
  151. ;------------------------------------------------------------------------
  152.  
  153.     end
  154.