home *** CD-ROM | disk | FTP | other *** search
/ Internet MPEG Audio Archive / IMAA.mdf / util / dos / l3v100n / rsx / source / switch.asm < prev    next >
Assembly Source File  |  1994-01-19  |  2KB  |  81 lines

  1.     INCLUDE REGS386.INC
  2.         INCLUDE TRANS.INC
  3.  
  4.     .386p
  5.  
  6. DGROUP group _DATA
  7.  
  8. _DATA segment word public 'DATA' use16
  9.     extrn _cs16real: word
  10.     extrn _ds16real: word
  11.     _ts TRANS  <>              ; translation struct for r-mode switch
  12.     goProtectMode    dd    ?     ; Location of far call routine
  13. _DATA ends
  14.  
  15. _TEXT segment byte public 'CODE' use16
  16.         assume cs:_TEXT,ds:DGROUP
  17.  
  18. ;
  19. ;    void RealModeSwitch(void)
  20. ;
  21. public    _RealModeSwitch
  22. _RealModeSwitch proc near
  23.     pop    bx            ;Where to return from this procedure
  24.  
  25.     movzx    ebx, bx
  26.     movzx    esi, si
  27.     movzx    edi, di
  28.     movzx    ebp, bp
  29.     mov    dword ptr _ts.T_EBX, ebx
  30.     mov    dword ptr _ts.T_ESI, esi
  31.     mov    dword ptr _ts.T_EDI, edi
  32.     mov    dword ptr _ts.T_EBP, ebp
  33.  
  34.     mov    word ptr _ts.T_SP, sp
  35.     mov    word ptr _ts.T_IP, offset _TEXT:@@realModeEntry
  36.     mov    word ptr _ts.T_FLAGS, 0202h
  37.     mov    ax, _cs16real
  38.     mov    word ptr _ts.T_CS, ax
  39.     mov    ax, _ds16real
  40.     mov    word ptr _ts.T_DS, ax
  41.     mov    word ptr _ts.T_ES, ax
  42.     mov    word ptr _ts.T_SS, ax
  43.  
  44.     xor    ebx, ebx
  45.     xor    ecx, ecx
  46.     push    ds
  47.     pop    es
  48.     mov    di, offset DGROUP:_ts
  49.     movzx    edi, di
  50.     mov    ax,0301h
  51.     int    31h
  52.  
  53.     mov    esi, dword ptr _ts.T_ESI
  54.     mov    edi, dword ptr _ts.T_EDI
  55.     mov    ebp, dword ptr _ts.T_EBP
  56.     mov    sp, word ptr _ts.T_SP
  57.     jmp    word ptr _ts.T_EBX    ; stored by DPMIprotectedMode() below
  58. @@realModeEntry:
  59.     pop    goProtectMode    ; Address to return from real mode callback
  60.     push    bx        ; Address stored in realRegs above
  61.     ret            ; RealModeSwitch()
  62. _RealModeSwitch   endp
  63.  
  64. ;
  65. ;    void ProtectedModeSwitch(void)
  66. ;
  67. public    _ProtectedModeSwitch
  68. _ProtectedModeSwitch proc near
  69.     pop    bx              ;Return point (will be used in
  70.     mov    dword ptr _ts.T_EBX, ebx  ;  RealModeSwitch above)
  71.     mov    dword ptr _ts.T_ESI, esi
  72.     mov    dword ptr _ts.T_EDI, edi
  73.     mov    dword ptr _ts.T_EBP, ebp
  74.     mov    word ptr _ts.T_SP, sp
  75.     jmp    goProtectMode    ;Saved retf address from real mode callback
  76. _ProtectedModeSwitch endp
  77.  
  78. _TEXT    ends
  79.  
  80.     end
  81.