home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tc20 / emuvars.asi < prev    next >
Text File  |  1988-08-28  |  5KB  |  159 lines

  1. ;    emuVars.asi        last modified :- 13 Jul 88
  2.  
  3. ;    Turbo-C Run Time Library    version 2.0
  4.  
  5. ;    Copyright (c) 1986,87,88 by Borland International Inc.
  6. ;    All Rights Reserved.
  7.  
  8. ;    This file is designed to be included both by the start-up
  9. ;    module (C0.asm, for TC) and by the emulator.  The data is
  10. ;    actually allocated in startup, and externally referenced
  11. ;    from the emulator.
  12.  
  13. ;    4/15/88 ah:
  14. ;    Modified for Turbo Pascal using _Pascal_ conditional.
  15. ;    7/13/88 rss:
  16. ;    Data initialization removed, moved to emualor FINIT code.
  17. ;    Added Safety Stamp so debugger can detect emulator.
  18.  
  19. IFNDEF    _Pascal_    ; if Turbo C version
  20.  
  21. IFNDEF    _InsideEmu87_
  22.     PUBLIC    emws_limitSP,    emws_initialSP,
  23.     PUBLIC    emws_saveVector,emws_nmiVector
  24.     PUBLIC    emws_status,    emws_control,    emws_TOS,    emws_adjust
  25.     PUBLIC    emws_fixSeg,    emws_BPsafe
  26.     PUBLIC    emws_stamp, emws_version
  27.  
  28.     IF _Strict87_
  29.         PUBLIC    emws_instrnPtr, emws_dataPtr, emws_instruction 
  30.     ENDIF
  31. ENDIF
  32.  
  33. ; The Use of Interrupt Vectors
  34.  
  35. ;    There are 11 interrupt vectors.  The first 8 map onto the 8 floating
  36. ;    point instruction patterns:
  37.  
  38. ;        {WAIT    ESC n } -->  INT (34h + n), where n is in (0..7)
  39.  
  40. ;    No segment prefixes may apply to these patterns.
  41.  
  42. ;    The ninth interrupt provides instructions with segment prefixes:
  43.  
  44. ;        {WAIT    ES: ESC n } --> INT (3Ch), byte (C0h + n)
  45. ;        {WAIT    CS: ESC n } --> INT (3Ch), byte (80h + n)
  46. ;        {WAIT    SS: ESC n } --> INT (3Ch), byte (40h + n)
  47. ;        {WAIT    DS: ESC n } --> INT (3Ch), byte (00h + n)
  48.  
  49.  
  50. ;    The tenth interrupt corresponds to the sequence NOP, FWAIT, and
  51. ;    is a no-op for emulation purposes.
  52.  
  53. ;    The eleventh interrupt provides Borland-defined shortcuts.
  54.  
  55.  
  56.  
  57. ;    Data space is actually allocated in the stack segment by C0.asm,
  58. ;    the start-up module, and accessed by the emulator via externs.
  59. ;    It is initialized during the first emulated FINIT instruction.
  60.  
  61. IFNDEF    _InsideEmu87_        ; if we are building C0.obj
  62.  
  63. ; Allocate a set of 8 iNDP registers, plus extras for workspace
  64.  
  65. emws_limitSP    label    word
  66.  
  67.     db    (16 * 12) DUP (?)
  68.  
  69. emws_initialSP    label    word
  70.  
  71. ; Append a spare for underflow situations.
  72.  
  73.     dw    6 dup (?)
  74.  
  75.  
  76. emws_saveVector dd    ?    ; prior contents of NMI vector
  77. emws_nmiVector    dd    ?    ; PC/AT error vector for 80287 exceptions
  78.  
  79. emws_status    dw    ?    ; result of comparisons
  80. emws_control    dw    ?    ; processing options and exceptions.
  81.  
  82. emws_TOS    dw    ?    ; current level of e87 register stack
  83. emws_adjust    dw    ?    ; adjusts TOS at exit
  84.  
  85. emws_fixSeg    dw    ?    ; selector implied by segFix
  86. emws_BPsafe    dw    ?    ; keep BP --> userRegs here for safety.
  87. emws_stamp    dd    ?    ; after initialization, 'emu', 87h
  88. emws_version    dw    ?    ; 1 for TC2, TP5; 2 for TB2
  89.  
  90. IF _Strict87_
  91.     emws_instrnPtr    dd    ?    ; used with error recovery
  92.     emws_dataPtr    dd    ?    ; --------- " ------------
  93.     emws_instruction     dw    ?    ; bytes swapped, used for error recovery
  94. ENDIF
  95.  
  96. ELSE            ; _InsideEmu87_, we are building the emulator
  97.  
  98.     EXTRN    emws_limitSP    : WORD
  99.     EXTRN    emws_initialSP    : WORD
  100.     EXTRN    emws_saveVector : DWORD
  101.     EXTRN    emws_nmiVector    : DWORD
  102.     EXTRN    emws_status    : WORD
  103.     EXTRN    emws_control    : WORD
  104.     EXTRN    emws_TOS    : WORD
  105.     EXTRN    emws_adjust    : WORD
  106.     EXTRN    emws_fixSeg    : WORD
  107.     EXTRN    emws_BPsafe    : WORD
  108.     EXTRN    emws_stamp    : DWORD
  109.     EXTRN    emws_version    : WORD
  110.  
  111.     IF _Strict87_
  112.         EXTRN    emws_instrnPtr    : DWORD
  113.         EXTRN    emws_dataPtr    : DWORD
  114.         EXTRN    emws_instruction: DWORD
  115.     ENDIF
  116.  
  117.     EmuAssume@    MACRO    aSeg
  118.         ASSUME    aSeg : SEG emws_TOS
  119.     ENDM
  120.     EmuNothing@    MACRO    aSeg
  121.         ASSUME    aSeg : NOTHING
  122.     ENDM
  123. ENDIF
  124.  
  125. ELSE            ; _Pascal_, Turbo Pascal version
  126.  
  127. ; Turbo Pascal's linker does not allow explicit references to the
  128. ; stack segment, so instead of the above PUBLICs and EXTRNs we
  129. ; define the following equates for the emulators variables. These
  130. ; declarations cause the assembler to use DS as the default segment
  131. ; register, so an SS: override MUST be coded in places where DS is
  132. ; not yet set up.
  133.  
  134. ; Note: The Turbo Pascal runtime library assumes that an FINIT will
  135. ; correctly initialize all emulator variables. Turbo Pascal never
  136. ; initializes them, nor does it ever directly reference any of them.
  137.  
  138. emws_limitSP    equ    (word ptr DS: 0)
  139. emws_initialSP    equ    (word ptr DS: 192)
  140. emws_saveVector equ    (dword ptr DS: 204)
  141. emws_nmiVector    equ    (dword ptr DS: 208)
  142. emws_status    equ    (word ptr DS: 212)
  143. emws_control    equ    (word ptr DS: 214)
  144. emws_TOS    equ    (word ptr DS: 216)
  145. emws_adjust    equ    (word ptr DS: 218)
  146. emws_fixSeg    equ    (word ptr DS: 220)
  147. emws_BPsafe    equ    (word ptr DS: 222)
  148. emws_stamp    equ    (word ptr DS: 224)
  149. emws_version    equ    (word ptr DS: 228)
  150.  
  151. EmuAssume@    MACRO    aSeg
  152.     ASSUME    aSeg : NOTHING
  153. ENDM
  154. EmuNothing@    MACRO    aSeg
  155.     ASSUME    aSeg : NOTHING
  156. ENDM
  157.  
  158. ENDIF
  159.