Forframe.inc

Embed Size (px)

Citation preview

  • 8/16/2019 Forframe.inc

    1/16

  • 8/16/2019 Forframe.inc

    2/16

    ;;-------------------------------------------------------------------------; 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 bpsaveret0 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]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 si

    saveds1 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

  • 8/16/2019 Forframe.inc

    3/16

    ; 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 bpsaveret2 dd ? ;return address for far returnargtwo2 dd ? ;address of second operandargone2 dd ? ;first operand's addressframe2 endsofftwo2 equ argtwo2segtwo2 equ argtwo2 + 2offone2 equ argone2

    segone2 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, segm

    ented (16 bit) address;frame3 struc ;three arg struc for accessing stacksaveflags3 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 ends

    offthree3 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

  • 8/16/2019 Forframe.inc

    4/16

    ; 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 returnargfour4 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 argthree4

    segthree4 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, address offse

    t; 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 operand

    argthree5 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 + 2

  • 8/16/2019 Forframe.inc

    5/16

    offtwo5 equ argtwo5segtwo5 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, address 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 operand

    argfive6 dd ? ;address of fifth operandargfour6 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 argfour6segfour6 equ argfour6 + 2offthree6 equ argthree6

    segthree6 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 offse

    t; 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 disavesi7 dw ? ;save area for caller's sisaveds7 dw ? ;save area for caller's dssavebp7 dw ? ;save area for caller's bp

  • 8/16/2019 Forframe.inc

    6/16

    saveret7 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 argseven7segseven7 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, address 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 flags

    savedi8 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 address

    frame8 endsoffeight8 equ argeight8segeight8 equ argeight8 + 2offseven8 equ argseven8segseven8 equ argseven8 + 2offsix8 equ argsix8segsix8 equ argsix8 + 2offfive8 equ argfive8segfive8 equ argfive8 + 2offfour8 equ argfour8

  • 8/16/2019 Forframe.inc

    7/16

    segfour8 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 ds

    savebp9 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 operandargsix9 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 argnine9

    segnine9 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 + 2

    offtwo9 equ argtwo9segtwo9 equ argtwo9 + 2offone9 equ argone9segone9 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 !;

  • 8/16/2019 Forframe.inc

    8/16

    ; 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 disavedsi0 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 bp

    savedret1 dd ? ;return address for far returnretvaloffs1 dw ? ;offset (re DS) of storage for return valueargsone1 dd ? ;first arg - only arg: addresssframe1 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

  • 8/16/2019 Forframe.inc

    9/16

    ; 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 argssavedflags2 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 argsone2segsone2 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;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 value

    argsthree3 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 di

  • 8/16/2019 Forframe.inc

    10/16

    savedsi4 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 operandargstwo4 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 disavedsi5 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 operand

    argsthree5 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 argsone5

    segsone5 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;

  • 8/16/2019 Forframe.inc

    11/16

    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 returnretvaloffs6 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 argsfour6segsfour6 equ argsfour6 + 2offsthree6 equ argsthree6segsthree6 equ argsthree6 + 2offstwo6 equ argstwo6

    segstwo6 equ argstwo6 + 2offsone6 equ argsone6segsone6 equ argsone6 + 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; 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 stack

    savedflags7 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 operand

    argsone7 dd ? ;first operand's addresssframe7 endsoffsseven7 equ argsseven7segsseven7 equ argsseven7 + 2offssix7 equ argssix7segssix7 equ argssix7 + 2offsfive7 equ argsfive7segsfive7 equ argsfive7 + 2offsfour7 equ argsfour7segsfour7 equ argsfour7 + 2

  • 8/16/2019 Forframe.inc

    12/16

    offsthree7 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 dssavedbp8 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 operand

    argsseven8 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 operandargsone8 dd ? ;first operand's addresssframe8 endsoffseight8 equ argseight8segseight8 equ argseight8 + 2offsseven8 equ argsseven8segsseven8 equ argsseven8 + 2offssix8 equ argssix8

    segssix8 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 di

  • 8/16/2019 Forframe.inc

    13/16

    savedsi9 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 operandargsseven9 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 argsseven9segsseven9 equ argsseven9 + 2offssix9 equ argssix9segssix9 equ argssix9 + 2offsfive9 equ argsfive9

    segsfive9 equ argsfive9 + 2offsfour9 equ argsfour9segsfour9 equ argsfour9 + 2offsthree9 equ argsthree9segsthree9 equ argsthree9 + 2offstwo9 equ argstwo9segstwo9 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 match

    save macro  push bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  push ds ;versions 3.x, 4.x, 5.x require preservation of BP & DS  push si ;Some versions of MS C require preservation of SI, DI  push di  pushf ;some versions of MS C, FORTRAN require preservation of  mov bp,sp ;establishes stack frame pointing to saved flags  cld ; direction flag  endmrestore 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  pop di ; direction flag, some require preservation of SI, DI  pop si ; almost all require preservation of DS  pop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  pop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DS  endmksave macro  push bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  push ds ;versions 3.x, 4.x, 5.x require preservation of BP & DS  push si ;Some versions of MS C require preservation of SI, DI

  • 8/16/2019 Forframe.inc

    14/16

      push di  pushf ;some versions of MS C, FORTRAN require preservation of  mov bp,sp ;establishes stack frame pointing to saved flags  cld ; direction flag  endmkrestore 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  pop di ; direction flag, some require preservation of SI, DI  pop si ; almost all require preservation of DS  pop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  pop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DS  endmsave16 macro  push bp ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  push ds ;versions 3.x, 4.x, 5.x require preservation of BP & DS  push si ;Some versions of MS C require preservation of SI, DI  push di  pushf ;some versions of MS C, FORTRAN require preservation of  mov bp,sp ;establishes stack frame pointing to saved flags  cld ; direction flag  endm

    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  pop di ; direction flag, some require preservation of SI, DI  pop si ; almost all require preservation of DS  pop ds ;IBM FORTRAN v1.0,2.0 IBM Pascal v1.0,2.0 & MicroSoft  pop bp ;versions 3.x, 4.x, 5.x require preservation of BP & DS  endm;;RET_FAR MACRO

      DB 0CBH  ENDM;RET_FAR_POP MACRO X  DB 0CAH  DW X  ENDM;RET_NEAR MACRO  DB 0C3H  ENDM;RET_NEAR_POP MACRO X

      DB 0C2H  DW X  ENDM;SRET MACRO X  IFB   DB 0C3H  ELSE  DB 0C2H  DW X

  • 8/16/2019 Forframe.inc

    15/16

      ENDIF  ENDM;NRET MACRO X  IFB   DB 0C3H  ELSE  DB 0C2H  DW X  ENDIF  ENDM;LRET MACRO X  IFB   DB 0CBH  ELSE  DB 0CAH  DW X  ENDIF  ENDM;FRET MACRO X  IFB   DB 0CBH

      ELSE  DB 0CAH  DW X  ENDIF  ENDM;;;;*******************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

  • 8/16/2019 Forframe.inc

    16/16

    ;;  endm ;header;wswapeax macro  xchg al,ah  db 066h,00Fh,0C8h ; bswap eax  xchg al,ah  endm ;wswapeax;wswapebx macro  xchg bl,bh  db 066h,00Fh,0CBh ; bswap ebx  xchg bl,bh  endm ;wswapebx;wswapecx macro  xchg cl,ch  db 066h,00Fh,0C9h ; bswap ecx  xchg cl,ch  endm ;wswapecx;wswapedx macro  xchg dl,dh

      db 066h,00Fh,0CAh ; bswap edx  xchg dl,dh  endm ;wswapedx;wswapesi macro  xchg ax,si  xchg al,ah  db 066h,00Fh,0C8h ; bswap eax  xchg al,ah  xchg ax,si  endm ;wswapesi;wswapedi macro

      xchg ax,di  xchg al,ah  db 066h,00Fh,0C8h ; bswap eax  xchg al,ah  xchg ax,di  endm ;wswapedi;wswapebp macro  xchg ax,bp  xchg al,ah  db 066h,00Fh,0C8h ; bswap eax  xchg al,ah  xchg ax,bp

      endm ;wswapebp;;  .list