; ; GRDP ; ; Copyright(c) LADsoft ; ; David Lindauer, gclind01@starbase.spd.louisville.edu ; ; ; Dispatch.asm ; ; Function: OS Function dispatcher ; Handles Call to Major function number ; Handles generic call to function number ; Handles keeping track of last known error ; ;MASM MODE .model small .386 include prints.ase PUBLIC TableDispatch, nofunction .code ; ; Core dispatch routine. Calls the subfunction indicated in AL ; and then set the return address to after the dispatch table ; This expects a subfunction code to be on the stack ; TableDispatch PROC ENTER 0,0 xchg bx,[bp+2] ; xchg ret address & ebx cmp al,cs:[bx] ; Limit check ja short noaction ; Error if too big ; Here we call the routine push offset _text:finishup ; Return address movzx eax,al movzx ebx,bx push WORD PTR cs:[ebx + 2 * eax + 2] ; Get code address to stack xchg bx,[bp+2] ; put things as they were mov ax,[bp + 4] ; Get the subkey cld ; Assume move dir up ret ; Go to subroutine noaction: xchg ebx,[bp+2] ; Put things as they were call nofunction ; Register bad function error finishup: ; Now we have to find the return address xchg bx,[bp+2] ; Get return address push eax movzx eax,word ptr cs:[bx] movzx ebx,bx lea ebx,[ebx + 2 * eax + 4] ; Get offset to return address pop eax xchg bx,[bp+2] ; Xchg with orig value of ebx LEAVE ret 2 TableDispatch ENDP nofunction PROC stc ; Set carry flag ret nofunction ENDP END