startup:
pushfd
pushad
pushedx
sgdt [esp-2]
popedx
moveax,edx ;EDX.EAX->GDT BASE
movecx, 3e8h
.ifdword ptr [eax+ecx+4]!=00cf9a00h ;3e8 ring0 code32
movbyte ptr [eax],0c3h ;ret
movdword ptr [eax+ecx],0000ffffh
movdword ptr [eax+ecx+4],00cf9a00h
.endif
push edx
sidt [esp-2]
pop edx
add edx,HOOKINT*8 ;edx->int 20h
.ifdword ptr [edx+2]!=0ee0003e8h;int 20 gate ->gdt base(ret)
movdword ptr[edx+2],0ee0003e8h
mov[edx],ax
shreax, 16
mov[edx+6], ax
.endif
popad
popfd
xoreax, eax
ret8
endstartup