Forframe.mac

Embed Size (px)

Citation preview

  • 8/16/2019 Forframe.mac

    1/16

    ;; (c) 1997, 1981-1994 Kevin G. Rhoads - all rights reserved.;; FORTRAN stack frame structures for MASM, originally written for; IBM FORTRAN v1.0 & IBM MASM v1.0 - (c) Kevin G. Rhoads, 1981 & 1982.; save/restore macros, code header & near/far returns added, and frame; structures extended 1986 for MicroSoft FORTRAN v3.2 & v3.3 - (c) 1986; Kevin G. Rhoads. Note that these stack frame structures have been; tested with IBM FORTRAN v1.0, v2.0; MicroSoft FORTRAN v3.2, 3.3, 3.31, 4.1 & 5.1; They are also suited for interface to IBM Pascal v1.0 & 2.0; MicroSoft Pascal; v3.3 & 3.31 provided arguments are passed by reference (i.e., VARS) or are; addresses passed by value -- FORTRAN expects pass by reference & large model; (segment:offset) addresses; These definitions are also suitable for QuickBasic 4.5, MS C 5.1, 6.0, C/C++ 7; VC 1.0, 1.5 with appropriate definitions on the calling side.;; The first set of FRAME definitions are suitable for returning BYTEs/CHARs/INTs/LONGs; For returning REALs/FLOATs &c see SFRAME definitions in latter half of file.;;-------------------------------------------------------------------------; RETURN OF FLOATS OR NON-TRIVIAL STRUCTS IS OFTEN STRANGE -- see SFRAME; definitions after FRAME definitions.

    ;-------------------------------------------------------------------------;; Originally designed for FAR, 16bit calling (all stack based).; These should also work for NEAR, 32bit, STACK based calling with minor mods; [ see FRAME32.MAC ];

    .xlist;; TYPE 1 - simple return value; frame struc for no arg subroutine; FORTRAN/Pascal external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer)

    ; one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame0 struc ;frame for stack accesssaveflags0 dw ? ;save area for caller's flagssavedi0 dw ? ;save area for caller's disavesi0 dw ? ;save area for caller's sisaveds0 dw ? ;save area for caller's dssavebp0 dw ? ;save area for caller's bp

    saveret0 dd ? ;return address for far returnframe0 ends;; frame structure for 1 arg subroutine; FORTRAN/Pascal external subroutine calling convention; segment:[offset] address provided on stack for arg; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]

  • 8/16/2019 Forframe.mac

    2/16

    char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame1 struc ;frame for stack access - 1 argsaveflags1 dw ? ;save area for caller's flagssavedi1 dw ? ;save area for caller's disavesi1 dw ? ;save area for caller's sisaveds1 dw ? ;save area for caller's dssavebp1 dw ? ;save area for caller's bpsaveret1 dd ? ;return address for far returnargone1 dd ? ;first arg - only arg: addressframe1 endsoffone1 equ argone1segone1 equ argone1 + 2;; frame declaration for two arg subroutine; FORTRAN/Pascal calling conventions for external procedure; segment:[offset] address provided on stack for arg; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer)

    ; one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame2 struc ;frame structure for stack - two argssaveflags2 dw ? ;save area for caller's flagssavedi2 dw ? ;save area for caller's disavesi2 dw ? ;save area for caller's sisaveds2 dw ? ;save area for caller's dssavebp2 dw ? ;save area for caller's bp

    saveret2 dd ? ;return address for far returnargtwo2 dd ? ;address of second operandargone2 dd ? ;first operand's addressframe2 endsofftwo2 equ argtwo2segtwo2 equ argtwo2 + 2offone2 equ argone2segone2 equ argone2 + 2;; frame struc for three arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] address provided on stack for arg; FORTRAN external procedure calling convention

    ; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame3 struc ;three arg struc for accessing stack

  • 8/16/2019 Forframe.mac

    3/16

    saveflags3 dw ? ;save area for caller's flagssavedi3 dw ? ;save area for caller's disavesi3 dw ? ;save area for caller's sisaveds3 dw ? ;save area for caller's dssavebp3 dw ? ;save area for caller's bpsaveret3 dd ? ;return address for far returnargthree3 dd ? ;address of third operandargtwo3 dd ? ;address of second operandargone3 dd ? ;first operand's addressframe3 endsoffthree3 equ argthree3segthree3 equ argthree3 + 2offtwo3 equ argtwo3segtwo3 equ argtwo3 + 2offone3 equ argone3segone3 equ argone3 + 2;; frame struc for four arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]

    char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame4 struc ;four arg struc for accessing stacksaveflags4 dw ? ;save area for caller's flagssavedi4 dw ? ;save area for caller's disavesi4 dw ? ;save area for caller's sisaveds4 dw ? ;save area for caller's dssavebp4 dw ? ;save area for caller's bpsaveret4 dd ? ;return address for far return

    argfour4 dd ? ;address of fourth operandargthree4 dd ? ;address of third operandargtwo4 dd ? ;address of second operandargone4 dd ? ;first operand's addressframe4 endsofffour4 equ argfour4segfour4 equ argfour4 + 2offthree4 equ argthree4segthree4 equ argthree4 + 2offtwo4 equ argtwo4segtwo4 equ argtwo4 + 2offone4 equ argone4segone4 equ argone4 + 2

    ;; frame struc for five arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, addre

  • 8/16/2019 Forframe.mac

    4/16

    ss offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame5 struc ;five arg struc for accessing stacksaveflags5 dw ? ;save area for caller's flagssavedi5 dw ? ;save area for caller's disavesi5 dw ? ;save area for caller's sisaveds5 dw ? ;save area for caller's dssavebp5 dw ? ;save area for caller's bpsaveret5 dd ? ;return address for far returnargfive5 dd ? ;address of fifth operandargfour5 dd ? ;address of fourth operandargthree5 dd ? ;address of third operandargtwo5 dd ? ;address of second operandargone5 dd ? ;first operand's addressframe5 endsofffive5 equ argfive5segfive5 equ argfive5 + 2offfour5 equ argfour5segfour5 equ argfour5 + 2offthree5 equ argthree5segthree5 equ argthree5 + 2offtwo5 equ argtwo5

    segtwo5 equ argtwo5 + 2offone5 equ argone5segone5 equ argone5 + 2;; frame struc for six arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, addre

    ss offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame6 struc ;six arg struc for accessing stacksaveflags6 dw ? ;save area for caller's flagssavedi6 dw ? ;save area for caller's disavesi6 dw ? ;save area for caller's sisaveds6 dw ? ;save area for caller's dssavebp6 dw ? ;save area for caller's bpsaveret6 dd ? ;return address for far returnargsix6 dd ? ;address of sixth operandargfive6 dd ? ;address of fifth operand

    argfour6 dd ? ;address of fourth operandargthree6 dd ? ;address of third operandargtwo6 dd ? ;address of second operandargone6 dd ? ;first operand's addressframe6 endsoffsix6 equ argsix6segsix6 equ argsix6 + 2offfive6 equ argfive6segfive6 equ argfive6 + 2offfour6 equ argfour6

  • 8/16/2019 Forframe.mac

    5/16

    segfour6 equ argfour6 + 2offthree6 equ argthree6segthree6 equ argthree6 + 2offtwo6 equ argtwo6segtwo6 equ argtwo6 + 2offone6 equ argone6segone6 equ argone6 + 2;; frame struc for seven arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame7 struc ;seven arg struc for accessing stacksaveflags7 dw ? ;save area for caller's flagssavedi7 dw ? ;save area for caller's di

    savesi7 dw ? ;save area for caller's sisaveds7 dw ? ;save area for caller's dssavebp7 dw ? ;save area for caller's bpsaveret7 dd ? ;return address for far returnargseven7 dd ? ;address of seventh operandargsix7 dd ? ;address of sixth operandargfive7 dd ? ;address of fifth operandargfour7 dd ? ;address of fourth operandargthree7 dd ? ;address of third operandargtwo7 dd ? ;address of second operandargone7 dd ? ;first operand's addressframe7 endsoffseven7 equ argseven7

    segseven7 equ argseven7 + 2offsix7 equ argsix7segsix7 equ argsix7 + 2offfive7 equ argfive7segfive7 equ argfive7 + 2offfour7 equ argfour7segfour7 equ argfour7 + 2offthree7 equ argthree7segthree7 equ argthree7 + 2offtwo7 equ argtwo7segtwo7 equ argtwo7 + 2offone7 equ argone7segone7 equ argone7 + 2

    ;; frame struc for eight arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, addre

  • 8/16/2019 Forframe.mac

    6/16

    ss offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;frame8 struc ;eight arg struc for accessing stacksaveflags8 dw ? ;save area for caller's flagssavedi8 dw ? ;save area for caller's disavesi8 dw ? ;save area for caller's sisaveds8 dw ? ;save area for caller's dssavebp8 dw ? ;save area for caller's bpsaveret8 dd ? ;return address for far returnargeight8 dd ? ;address of eighth operandargseven8 dd ? ;address of seventh operandargsix8 dd ? ;address of sixth operandargfive8 dd ? ;address of fifth operandargfour8 dd ? ;address of fourth operandargthree8 dd ? ;address of third operandargtwo8 dd ? ;address of second operandargone8 dd ? ;first operand's addressframe8 endsoffeight8 equ argeight8segeight8 equ argeight8 + 2offseven8 equ argseven8segseven8 equ argseven8 + 2

    offsix8 equ argsix8segsix8 equ argsix8 + 2offfive8 equ argfive8segfive8 equ argfive8 + 2offfour8 equ argfour8segfour8 equ argfour8 + 2offthree8 equ argthree8segthree8 equ argthree8 + 2offtwo8 equ argtwo8segtwo8 equ argtwo8 + 2offone8 equ argone8segone8 equ argone8 + 2;

    ; frame struc for nine arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; simple return value (1, 2 or 4 bytes - char, int, long or pointer); one byte return in AL character*1, logical*1 integer*1 or [C]char; two byte return in AX integer*2, logical*2 or [C] short, address offset; four byte return in DX:AX integer*4, logical*4 or [C] long, segmented (16 bit) address;

    frame9 struc ;nine arg struc for accessing stacksaveflags9 dw ? ;save area for caller's flagssavedi9 dw ? ;save area for caller's disavesi9 dw ? ;save area for caller's sisaveds9 dw ? ;save area for caller's dssavebp9 dw ? ;save area for caller's bpsaveret9 dd ? ;return address for far returnargnine9 dd ? ;address of ninth operandargeight9 dd ? ;address of eighth operandargseven9 dd ? ;address of seventh operand

  • 8/16/2019 Forframe.mac

    7/16

    argsix9 dd ? ;address of sixth operandargfive9 dd ? ;address of fifth operandargfour9 dd ? ;address of fourth operandargthree9 dd ? ;address of third operandargtwo9 dd ? ;address of second operandargone9 dd ? ;first operand's addressframe9 endsoffnine9 equ argnine9segnine9 equ argnine9 + 2offeight9 equ argeight9segeight9 equ argeight9 + 2offseven9 equ argseven9segseven9 equ argseven9 + 2offsix9 equ argsix9segsix9 equ argsix9 + 2offfive9 equ argfive9segfive9 equ argfive9 + 2offfour9 equ argfour9segfour9 equ argfour9 + 2offthree9 equ argthree9segthree9 equ argthree9 + 2offtwo9 equ argtwo9segtwo9 equ argtwo9 + 2offone9 equ argone9

    segone9 equ argone9 + 2;;; TYPE 2 - float or non-trivial return value;;!on return the retval offset must be in AX and the restored DS value in DX !;; MS FORTRAN/MS Pascal return convention for REAL*4 REAL*8 and with MS C for; STRUCTs, RECORDS &c (MS C floats and doubles are returned in global __fac; but then SEG:OFF of __fac must be in DX:AX as here);; CALLER allocates storage for return value in DGROUP segment(s) (DS on entry); and pushes offset before pushing addresses of args (all frames here based on

    ; large model, pass by reference (FORTRAN default, Pascal with VARS)); to return value copy to return value location AND RETURN WITH SEGMENT:OFFSET; OF RETURN VALUE LOCATION IN DX:AX !!!!! (w/o this last caller goes to flooby; space and gets garbage);; IBM FORTRAN v1 and v2, IBM Pascal v1 and v2 use essentially same conventions;; Borland C uses something like this for 3 byte and 5 or larger byte structs; Borland C returns all 1 byte values in AL, 2 bytes in AX, and 4 bytes in DX:AX; except floats; floats, doubles and long doubles are returned on 8087 ST(0) stack top;

    ;; frame struc for no arg subroutine; FORTRAN/Pascal external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; before CALLing routine;sframe0 struc ;frame for stack accesssavedflags0 dw ? ;save area for caller's flagssaveddi0 dw ? ;save area for caller's di

  • 8/16/2019 Forframe.mac

    8/16

    savedsi0 dw ? ;save area for caller's sisavedds0 dw ? ;save area for caller's dssavedbp0 dw ? ;save area for caller's bpsavedret0 dd ? ;return address for far returnretvaloffs0 dw ? ;offsset (re DS) of storage for return valuesframe0 ends;; frame structure for 1 arg subroutine; FORTRAN/Pascal external subroutine calling convention; segment:[offsset] address provided on stack for arg; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe1 struc ;frame for stack access - 1 argsavedflags1 dw ? ;save area for caller's flagssaveddi1 dw ? ;save area for caller's disavedsi1 dw ? ;save area for caller's sisavedds1 dw ? ;save area for caller's dssavedbp1 dw ? ;save area for caller's bpsavedret1 dd ? ;return address for far returnretvaloffs1 dw ? ;offset (re DS) of storage for return valueargsone1 dd ? ;first arg - only arg: address

    sframe1 endsoffsone1 equ argsone1segsone1 equ argsone1 + 2;; frame declaration for two arg subroutine; FORTRAN/Pascal calling conventions for external procedure; segment:[offset] address provided on stack for arg; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe2 struc ;frame structure for stack - two args

    savedflags2 dw ? ;save area for caller's flagssaveddi2 dw ? ;save area for caller's disavedsi2 dw ? ;save area for caller's sisavedds2 dw ? ;save area for caller's dssavedbp2 dw ? ;save area for caller's bpsavedret2 dd ? ;return address for far returnretvaloffs2 dw ? ;offset (re DS) of storage for return valueargstwo2 dd ? ;address of second operandargsone2 dd ? ;first operand's addresssframe2 endsoffstwo2 equ argstwo2segstwo2 equ argstwo2 + 2offsone2 equ argsone2

    segsone2 equ argsone2 + 2;; frame struc for three arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] address provided on stack for arg; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;

  • 8/16/2019 Forframe.mac

    9/16

    sframe3 struc ;three arg struc for accessing stacksavedflags3 dw ? ;save area for caller's flagssaveddi3 dw ? ;save area for caller's disavedsi3 dw ? ;save area for caller's sisavedds3 dw ? ;save area for caller's dssavedbp3 dw ? ;save area for caller's bpsavedret3 dd ? ;return address for far returnretvaloffs3 dw ? ;offset (re DS) of storage for return valueargsthree3 dd ? ;address of third operandargstwo3 dd ? ;address of second operandargsone3 dd ? ;first operand's addresssframe3 endsoffsthree3 equ argsthree3segsthree3 equ argsthree3 + 2offstwo3 equ argstwo3segstwo3 equ argstwo3 + 2offsone3 equ argsone3segsone3 equ argsone3 + 2;; frame struc for four arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double)

    ; caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe4 struc ;four arg struc for accessing stacksavedflags4 dw ? ;save area for caller's flagssaveddi4 dw ? ;save area for caller's disavedsi4 dw ? ;save area for caller's sisavedds4 dw ? ;save area for caller's dssavedbp4 dw ? ;save area for caller's bpsavedret4 dd ? ;return address for far returnretvaloffs4 dw ? ;offset (re DS) of storage for return valueargsfour4 dd ? ;address of fourth operandargsthree4 dd ? ;address of third operand

    argstwo4 dd ? ;address of second operandargsone4 dd ? ;first operand's addresssframe4 endsoffsfour4 equ argsfour4segsfour4 equ argsfour4 + 2offsthree4 equ argsthree4segsthree4 equ argsthree4 + 2offstwo4 equ argstwo4segstwo4 equ argstwo4 + 2offsone4 equ argsone4segsone4 equ argsone4 + 2;; frame struc for five arg subroutine

    ; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe5 struc ;five arg struc for accessing stacksavedflags5 dw ? ;save area for caller's flagssaveddi5 dw ? ;save area for caller's di

  • 8/16/2019 Forframe.mac

    10/16

    savedsi5 dw ? ;save area for caller's sisavedds5 dw ? ;save area for caller's dssavedbp5 dw ? ;save area for caller's bpsavedret5 dd ? ;return address for far returnretvaloffs5 dw ? ;offset (re DS) of storage for return valueargsfive5 dd ? ;address of fifth operandargsfour5 dd ? ;address of fourth operandargsthree5 dd ? ;address of third operandargstwo5 dd ? ;address of second operandargsone5 dd ? ;first operand's addresssframe5 endsoffsfive5 equ argsfive5segsfive5 equ argsfive5 + 2offsfour5 equ argsfour5segsfour5 equ argsfour5 + 2offsthree5 equ argsthree5segsthree5 equ argsthree5 + 2offstwo5 equ argstwo5segstwo5 equ argstwo5 + 2offsone5 equ argsone5segsone5 equ argsone5 + 2;; frame struc for six arg subroutine; FORTRAN/Pascal external procedure call convention

    ; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe6 struc ;six arg struc for accessing stacksavedflags6 dw ? ;save area for caller's flagssaveddi6 dw ? ;save area for caller's disavedsi6 dw ? ;save area for caller's sisavedds6 dw ? ;save area for caller's dssavedbp6 dw ? ;save area for caller's bpsavedret6 dd ? ;return address for far return

    retvaloffs6 dw ? ;offset (re DS) of storage for return valueargssix6 dd ? ;address of sixth operandargsfive6 dd ? ;address of fifth operandargsfour6 dd ? ;address of fourth operandargsthree6 dd ? ;address of third operandargstwo6 dd ? ;address of second operandargsone6 dd ? ;first operand's addresssframe6 endsoffssix6 equ argssix6segssix6 equ argssix6 + 2offsfive6 equ argsfive6segsfive6 equ argsfive6 + 2offsfour6 equ argsfour6

    segsfour6 equ argsfour6 + 2offsthree6 equ argsthree6segsthree6 equ argsthree6 + 2offstwo6 equ argstwo6segstwo6 equ argstwo6 + 2offsone6 equ argsone6segsone6 equ argsone6 + 2;; frame struc for seven arg subroutine; FORTRAN/Pascal external procedure call convention

  • 8/16/2019 Forframe.mac

    11/16

    ; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe7 struc ;seven arg struc for accessing stacksavedflags7 dw ? ;save area for caller's flagssaveddi7 dw ? ;save area for caller's disavedsi7 dw ? ;save area for caller's sisavedds7 dw ? ;save area for caller's dssavedbp7 dw ? ;save area for caller's bpsavedret7 dd ? ;return address for far returnretvaloffs7 dw ? ;offset (re DS) of storage for return valueargsseven7 dd ? ;address of seventh operandargssix7 dd ? ;address of sixth operandargsfive7 dd ? ;address of fifth operandargsfour7 dd ? ;address of fourth operandargsthree7 dd ? ;address of third operandargstwo7 dd ? ;address of second operandargsone7 dd ? ;first operand's addresssframe7 endsoffsseven7 equ argsseven7segsseven7 equ argsseven7 + 2

    offssix7 equ argssix7segssix7 equ argssix7 + 2offsfive7 equ argsfive7segsfive7 equ argsfive7 + 2offsfour7 equ argsfour7segsfour7 equ argsfour7 + 2offsthree7 equ argsthree7segsthree7 equ argsthree7 + 2offstwo7 equ argstwo7segstwo7 equ argstwo7 + 2offsone7 equ argsone7segsone7 equ argsone7 + 2;

    ; frame struc for eight arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double); caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe8 struc ;eight arg struc for accessing stacksavedflags8 dw ? ;save area for caller's flagssaveddi8 dw ? ;save area for caller's disavedsi8 dw ? ;save area for caller's sisavedds8 dw ? ;save area for caller's ds

    savedbp8 dw ? ;save area for caller's bpsavedret8 dd ? ;return address for far returnretvaloffs8 dw ? ;offset (re DS) of storage for return valueargseight8 dd ? ;address of eighth operandargsseven8 dd ? ;address of seventh operandargssix8 dd ? ;address of sixth operandargsfive8 dd ? ;address of fifth operandargsfour8 dd ? ;address of fourth operandargsthree8 dd ? ;address of third operandargstwo8 dd ? ;address of second operand

  • 8/16/2019 Forframe.mac

    12/16

    argsone8 dd ? ;first operand's addresssframe8 endsoffseight8 equ argseight8segseight8 equ argseight8 + 2offsseven8 equ argsseven8segsseven8 equ argsseven8 + 2offssix8 equ argssix8segssix8 equ argssix8 + 2offsfive8 equ argsfive8segsfive8 equ argsfive8 + 2offsfour8 equ argsfour8segsfour8 equ argsfour8 + 2offsthree8 equ argsthree8segsthree8 equ argsthree8 + 2offstwo8 equ argstwo8segstwo8 equ argstwo8 + 2offsone8 equ argsone8segsone8 equ argsone8 + 2;; frame struc for nine arg subroutine; FORTRAN/Pascal external procedure call convention; segment:[offset] addresses provided on stack for args; FORTRAN external procedure calling convention; complex return value (struct, record, float or double)

    ; caller has allocated space for retval in DS and pushed offset; after last arg and before CALLing routine;sframe9 struc ;nine arg struc for accessing stacksavedflags9 dw ? ;save area for caller's flagssaveddi9 dw ? ;save area for caller's disavedsi9 dw ? ;save area for caller's sisavedds9 dw ? ;save area for caller's dssavedbp9 dw ? ;save area for caller's bpsavedret9 dd ? ;return address for far returnretvaloffs9 dw ? ;offset (re DS) of storage for return valueargsnine9 dd ? ;address of ninth operandargseight9 dd ? ;address of eighth operand

    argsseven9 dd ? ;address of seventh operandargssix9 dd ? ;address of sixth operandargsfive9 dd ? ;address of fifth operandargsfour9 dd ? ;address of fourth operandargsthree9 dd ? ;address of third operandargstwo9 dd ? ;address of second operandargsone9 dd ? ;first operand's addresssframe9 endsoffsnine9 equ argsnine9segsnine9 equ argsnine9 + 2offseight9 equ argseight9segseight9 equ argseight9 + 2offsseven9 equ argsseven9

    segsseven9 equ argsseven9 + 2offssix9 equ argssix9segssix9 equ argssix9 + 2offsfive9 equ argsfive9segsfive9 equ argsfive9 + 2offsfour9 equ argsfour9segsfour9 equ argsfour9 + 2offsthree9 equ argsthree9segsthree9 equ argsthree9 + 2offstwo9 equ argstwo9

  • 8/16/2019 Forframe.mac

    13/16

    segstwo9 equ argstwo9 + 2offsone9 equ argsone9segsone9 equ argsone9 + 2;;;; NB - if modifications are made to the save/restore macros the frame; definitions above must be modified to matchsave macro

    push bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpush ds ;versions 3.x, 4.x, 5.x require preservation of BP & DSpush si ;Some versions of MS C require preservation of SI, DIpush dipushf ;some versions of MS C, FORTRAN require preservation ofmov bp,sp ;establishes stack frame pointing to saved flagscld ; direction flagendm

    restore macro; mov sp,bp ;restore stack frame from local storage allocation; ;this is commented out because it is unnecessary -; ;no local storage is allocated

    popf ;some versions of MS C, FORTRAN require preservation ofpop di ; direction flag, some require preservation of SI, DIpop si ; almost all require preservation of DS

    pop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DSendm

    ksave macropush bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpush ds ;versions 3.x, 4.x, 5.x require preservation of BP & DSpush si ;Some versions of MS C require preservation of SI, DIpush dipushf ;some versions of MS C, FORTRAN require preservation ofmov bp,sp ;establishes stack frame pointing to saved flagscld ; direction flagendm

    krestore macro

    ; mov sp,bp ;restore stack frame from local storage allocation; ;this is commented out because it is unnecessary -; ;no local storage is allocated

    popf ;some versions of MS C, FORTRAN require preservation ofpop di ; direction flag, some require preservation of SI, DIpop si ; almost all require preservation of DSpop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DSendm

    save16 macropush bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpush ds ;versions 3.x, 4.x, 5.x require preservation of BP & DSpush si ;Some versions of MS C require preservation of SI, DI

    push dipushf ;some versions of MS C, FORTRAN require preservation ofmov bp,sp ;establishes stack frame pointing to saved flagscld ; direction flagendm

    restore16 macro; mov sp,bp ;restore stack frame from local storage allocation; ;this is commented out because it is unnecessary -; ;no local storage is allocated

    popf ;some versions of MS C, FORTRAN require preservation of

  • 8/16/2019 Forframe.mac

    14/16

    pop di ; direction flag, some require preservation of SI, DIpop si ; almost all require preservation of DSpop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoftpop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DSendm

    ;;RET_FAR MACRO

    DB 0CBHENDM

    ;RET_FAR_POP MACRO X

    DB 0CAHDW XENDM

    ;RET_NEAR MACRO

    DB 0C3HENDM

    ;RET_NEAR_POP MACRO X

    DB 0C2HDW XENDM

    ;SRET MACRO XIFB

    DB 0C3HELSE

    DB 0C2HDW X

    ENDIFENDM

    ;NRET MACRO X

    IFB DB 0C3H

    ELSE DB 0C2HDW X

    ENDIFENDM

    ;LRET MACRO X

    IFB DB 0CBH

    ELSEDB 0CAHDW X

    ENDIF

    ENDM;FRET MACRO X

    IFB DB 0CBH

    ELSEDB 0CAHDW X

    ENDIFENDM

  • 8/16/2019 Forframe.mac

    15/16

    ;;;;*******************header ******************************;;code header macro defined here;header macro;;DATA segment WORD PUBLIC 'DATA' USE16DATA ends

     _DATA SEGMENT WORD PUBLIC 'DATA' USE16 _DATA ENDSCONST SEGMENT WORD PUBLIC 'CONST' USE16SEG_FAC DW SEG __facCONST ENDS

     _BSS SEGMENT WORD PUBLIC 'BSS' USE16 _BSS ENDS

    DGROUP GROUP CONST, _BSS, _DATA, DATA

    EXTRN __fac:QWORD

    ;C7 OR LATEREXTRN __fltused:ABS;C6 OR EARLIER;EXTRN __fltused:NEAR;code segment WORD PUBLIC 'CODE' USE16

    assume cs:code,ds:dgroup,es:NOTHING,ss:dgroup;;

    endm ;header;wswapeax macro

    xchg al,ah

    db 066h,00Fh,0C8h ; bswap eaxxchg al,ahendm ;wswapeax

    ;wswapebx macro

    xchg bl,bhdb 066h,00Fh,0CBh ; bswap ebxxchg bl,bhendm ;wswapebx

    ;wswapecx macro

    xchg cl,chdb 066h,00Fh,0C9h ; bswap ecx

    xchg cl,chendm ;wswapecx

    ;wswapedx macro

    xchg dl,dhdb 066h,00Fh,0CAh ; bswap edxxchg dl,dhendm ;wswapedx

    ;wswapesi macro

  • 8/16/2019 Forframe.mac

    16/16

    xchg ax,sixchg al,ahdb 066h,00Fh,0C8h ; bswap eaxxchg al,ahxchg ax,siendm ;wswapesi

    ;wswapedi macro

    xchg ax,dixchg al,ahdb 066h,00Fh,0C8h ; bswap eaxxchg al,ahxchg ax,diendm ;wswapedi

    ;wswapebp macro

    xchg ax,bpxchg al,ahdb 066h,00Fh,0C8h ; bswap eaxxchg al,ahxchg ax,bpendm ;wswapebp

    ;;

    .list;