Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9 KiB

  1. page ,132
  2. subttl emstack.asm - Emulator Stack Management Area
  3. ;***
  4. ;emstack.asm - Emulator Stack Management Area
  5. ;
  6. ; Copyright (c) 1986-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Emulator Stack Management Area
  10. ;
  11. ; This Module contains Proprietary Information of Microsoft
  12. ; Corporation and should be treated as Confidential.
  13. ;
  14. ;Revision History:
  15. ; See emulator.hst
  16. ;
  17. ;*******************************************************************************
  18. ProfBegin STACK
  19. ;*********************************************************************;
  20. ; ;
  21. ; Emulator Stack Management Area ;
  22. ; ;
  23. ;*********************************************************************;
  24. ; The emulator maintains an "finite" stack of 12 byte registers.
  25. ; Stand-alone emulator has 1 chunk only.
  26. ; This is done using a list of finite length stack chunks, each of
  27. ; which has the following format:
  28. ; +00 first (deepest) 12 byte register
  29. ; +12 next 12 byte register
  30. ; (and so on through last possible register)
  31. ; MACROS used to manipulate the emulator/8087 memory stack
  32. ; This macro allocates a new TOS register, returns SI with its address.
  33. PUSHST MACRO
  34. local pushstok
  35. mov esi,[CURstk] ; 14 get address of current register
  36. cmp esi,[LIMstk] ; 15 is current register end of stack
  37. jne short pushstok ; 16 no, still room in stack
  38. call OverStk ; stack overflow error
  39. pushstok:
  40. add esi,Reg87Len ; 4 increment SI to next free register
  41. mov [CURstk],esi ; 15 set current top of stack
  42. ENDM ; 64 total
  43. ; This macro deallocates TOS register, returns SI with new TOS address.
  44. ; Note: assumes SI contains TOS address, CURstk
  45. ; BASstk converted back to a variable to enable macro use for 8087 stack
  46. ; handling. Brad Verheiden, 4-13-84.
  47. POPSTsi MACRO
  48. local popstok
  49. cmp esi,[BASstk] ; 15 was it last register in the chunk ?
  50. jnz short popstok ; 16 no, still room in current chunk
  51. call UnderStk ; stack underflow error
  52. popstok:
  53. sub esi,Reg87Len ; 4 decrement SI to previous register
  54. mov [CURstk],esi ; 15 set current top of stack
  55. ENDM ; 64 total
  56. POPST MACRO
  57. mov esi,[CURstk]
  58. POPSTsi
  59. ENDM
  60. ChangeDIfromTOStoNOS MACRO
  61. sub edi,Reg87Len
  62. ENDM
  63. page
  64. ; This area contains two procedures, OverStk and UnderStk,
  65. ; which generate a stack overflow error.
  66. ; OverStk: invoked within PUSHST macro
  67. ; on entry, the stack is full
  68. ; on return, SI contains address of base of stack
  69. ; UnderStk: invoked within POPST macro
  70. ; on entry, the stack is empty
  71. ; on return, SI contains address of base of stack
  72. pub OverStk
  73. OR byte ptr [CURerr+1],StackOverflow/256 ; raise stack overflow
  74. CMP [Have8087],0 ; Is 8087 present
  75. JZ short OverStkEnd ; No - don't touch AX
  76. OR AH,StackOverflow/256 ; Indicate memory overflow for 8087
  77. pub OverStkEnd
  78. RET ; finished
  79. pub UnderStk
  80. OR byte ptr [CURerr+1],StackUnderflow/256 ; raise stack underflow
  81. RET ; finished
  82. ProfEnd STACK