;
; $Log: initrtns.asm,v $
; Revision 1.5  1998/09/07 21:23:00  jlawson
; fixed line breaks
;
; Revision 1.4  1998/06/26 08:39:23  cyruspatel
; Modified netware.cpp to use new GetTimesliceBaseline() function. Added
; netware.h to repository.
;
; Revision 1.2  1998/06/16 09:42:20  cyruspatel
; Fixed a couple of bugs relating to the init level. Should now initialize
; in correct order.
;
; Revision 1.1  1998/06/14 08:13:02  jlawson
; Incorportated Cyrus' NetWare specific stuff into the cvs tree
;

.386p
                PUBLIC  __InitRtns
                PUBLIC  __FiniRtns
                PUBLIC  _End_XI
                PUBLIC  _Start_XI
                PUBLIC  _End_YI
                PUBLIC  _Start_YI

DGROUP          GROUP   _DATA,XIB,XI,XIE,YIB,YI,YIE
_DATA           SEGMENT DWORD PUBLIC USE32 'DATA'
_DATA           ENDS
XIB             SEGMENT WORD PUBLIC USE32 'DATA'
_Start_XI:
XIB             ENDS
XI              SEGMENT WORD PUBLIC USE32 'DATA'
XI              ENDS
XIE             SEGMENT WORD PUBLIC USE32 'DATA'
_End_XI:
XIE             ENDS
YIB             SEGMENT WORD PUBLIC USE32 'DATA'
_Start_YI:
YIB             ENDS
YI              SEGMENT WORD PUBLIC USE32 'DATA'
YI              ENDS
YIE             SEGMENT WORD PUBLIC USE32 'DATA'
_End_YI:
YIE             ENDS

_TEXT           SEGMENT BYTE PUBLIC USE32 'CODE'
                ASSUME CS:_TEXT, DS:DGROUP, SS:DGROUP

callit:
                push      es
                mov       eax,dword ptr [esp+8H]
                cmp       dword ptr [eax],00000000H
                je        L$1
                push      ds
                pop       es
                call      dword ptr [eax]
L$1:
                pop       es
                ret       

__InitRtns:
                mov       al,0ffh
                
                push      ebx
                push      esi
                push      es
                sub       esp,00000004H
                mov       esi,offset _End_XI
                mov       byte ptr [esp],al
L$2:
                mov       eax,offset _Start_XI
                mov       dl,byte ptr [esp]
                mov       ebx,esi
L$3:
                cmp       eax,offset _End_XI
                jae       L$5
                cmp       byte ptr [eax],02H
                je        L$4
                mov       cl,byte ptr [eax+1H]
                cmp       dl,cl
                jb        L$4
                mov       ebx,eax
                mov       dl,cl
L$4:
                add       eax,00000006H
                jmp       L$3
L$5:
                cmp       ebx,offset _End_XI
                je        L$6
                lea       eax,[ebx+2H]
                push      eax
                call      callit
                add       esp,00000004H
                mov       byte ptr [ebx],02H
                jmp       L$2
L$6:
                add       esp,00000004H
                pop       es
                pop       esi
                pop       ebx
                ret       

__FiniRtns:
                mov       al,0
                mov       dl,0ffh

                push      ebx
                push      esi
                push      es
                sub       esp,00000008H
                mov       esi,offset _End_YI
                mov       byte ptr [esp+4H],al
                mov       byte ptr [esp],dl
L$7:
                mov       eax,offset _Start_YI
                mov       dl,byte ptr [esp+4H]
                mov       ebx,esi
L$8:
                cmp       eax,offset _End_YI
                jae       L$10
                cmp       byte ptr [eax],02H
                je        L$9
                mov       cl,byte ptr [eax+1H]
                cmp       dl,cl
                ja        L$9
                mov       ebx,eax
                mov       dl,cl
L$9:
                add       eax,00000006H
                jmp       L$8
L$10:
                cmp       ebx,offset _End_YI
                je        L$12
                mov       al,byte ptr [ebx+1H]
                cmp       al,byte ptr [esp]
                ja        L$11
                lea       eax,[ebx+2H]
                push      eax
                call      near ptr callit
                add       esp,00000004H
L$11:
                mov       byte ptr [ebx],02H
                jmp       L$7
L$12:
                add       esp,00000008H
                pop       es
                pop       esi
                pop       ebx
                ret       

_TEXT           ENDS

                END

