home *** CD-ROM | disk | FTP | other *** search
-
- PROCEDURE SetupJumpTable;
- {-initialize the names and offsets of the near procedures}
- {
- ***************************************************
- * The programmer must maintain the lists below to *
- * include all global procedure names that may be *
- * called from the MAIN code segment. *
- * This procedure should never be called directly *
- * within its own program. *
- ***************************************************
- }
- CONST
- {following string must be here to allow address to be found from Main Code}
- idstring : BigTurboString = 'SETJUMPTABLE FOLLOWS';
- BEGIN
- {
- *** EXAMPLES and COMMENTS ********************************************
- * Order is unimportant, except that procedures which are called most *
- * often from far segment should be first in list. *
- * Case of the string is important. Must be same as string passed to *
- * MakeLongCall (avoids overhead time of uppercasing every call). *
- * Fill in your own procedure names below. *
- **********************************************************************
- }
- pnames[1] := 'farproc1';
- poffsets[1] := Ofs(farproc1);
- pnames[2] := 'farproc2';
- poffsets[2] := Ofs(farproc2);
-
- {restore stack and do a FAR return to the main segment}
- INLINE(
- $8B/$E5/ {mov sp,bp}
- $5D/ {pop bp}
- $CB {ret far}
- );
- END; {SetupJumpTable}
-
- PROCEDURE FarCallHandler;
- {-pick up control from a far call and transfer to near procedure}
- CONST
- {following string must be here to allow address to be found from Main Code}
- idstring : BigTurboString = 'FARCALLHANDLER FOLLOWS';
- VAR
- i : Integer;
- procofs : Integer;
- procname : BigTurboString;
- BEGIN
- {get procname from the es:si pointer passed in}
- INLINE(
- $31/$C9/ {XOR CX,CX}
- $26/ {ES: }
- $8A/$0C/ {MOV CL,[SI]}
- $FE/$C1/ {INC CL}
- $BF/procname/ {MOV DI,ofs(procname)}
- $FC/ {CLD }
- $26/ {ES: }
- $AC/ {LODSB }
- $88/$03/ {MOV [BP+DI],AL}
- $47/ {INC DI}
- $E2/$F9 {LOOP 010B}
- );
- {match against the stored procnames}
- i := 0;
- REPEAT
- i := i+1;
- UNTIL (i > MaxNumProcs) OR (pnames[i] = procname);
- {error check}
- IF i > MaxNumProcs THEN BEGIN
- WriteLn(Con);
- WriteLn(Con, 'Far procedure ', procname, ' not found....');
- Halt;
- END;
- {check for stack space, later}
- {call the procedure}
- procofs := poffsets[i];
- INLINE(
- $C4/$46/< procofs/ {LES AX,procofs[BP]}
- $FF/$D0 {CALL AX}
- );
-
- {restore stack and FAR return}
- INLINE(
- $8B/$E5/ {mov sp,bp}
- $5D/ {pop bp}
- $CB {ret far}
- );
- END; {FarCallHandler}