;******************************************************************************* ; ; Functions from c7rt (\\products\public\boneyard\us\rellang\c700a.dos ; ;******************************************************************************* ;******************************************************************************* ;version.inc - defines current memory model ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; This file defines the current memory model being used. ; ;******************************************************************************* ?PLM= 0 ifdef mem_s memS equ 1 ; small model endif ifdef mem_m memM equ 1 ; medium model endif ifdef mem_c memC equ 1 ; compact model endif ifdef mem_l memL equ 1 ; large model endif ;******************************************************************************* ;******************************************************************************* ;cmacros.inc - assembly macros for interfacing to HHLs ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;******************************************************************************* comment $ cmacros - assembly macros for interfacing to HHLs Copyright (c) Microsoft Corporation. All rights reserved. $ if @Version gt 510 option m510, oldmacros else f510 equ <> endif .xcref ??_out ??_out MACRO string ifndef ?QUIET %out string endif ENDM if1 outif MACRO id,defval,onmsg,offmsg ifndef id ifb id=0 else id=defval endif endif if id id=1 ifnb ??_out endif else ifnb ??_out endif endif endm error MACRO msg bug %out E r r o r ----- msg ENDM ;??_out outif memS,0, outif memM,0, outif memL,0, outif memC,0, outif memH,0, memMOD= memS + memM + memL + memC + memH if memMOD ne 1 if memMOD eq 0 memS= 1 outif memS,0, else error endif endif sizeC= memM + memL + memH sizeD= memL + memC + (memH*2) outif ?DF,0, outif ?WIN,1, outif ?PLM,1, endif .XCREF .XCREF ?N,?AX,?AH,?AL,?BX,?BH .XCREF ?BL,?CX,?CH,?CL,?DX,?DH .XCREF ?DL,?SI,?DI,?ES,?DS,?BP .XCREF ?SP,?SS,?CS .XCREF ?RSL,?CPD,?argl,?argc,?BA .XCREF ?ACB,???,?PO .XCREF ?PAS,?PC .XCREF Uconcat,mPush,mPop .XCREF ?RI,?pp,?pp1,?al1 .XCREF ?aD,?AP,?Atal,?pd,?dd,?dd1,?ex1 .XCREF ?pg,?pg1,?aloc,?cs1,?cs2 .XCREF ?lb1,?lblpu .XCREF ?DF,?PLM,?WIN,?IA,?PU,?ADJ .CREF ?RSL = 0 ?CPD = 0 ?ArgL = 0 ?ArgC = 0 ?BA = 0 ?ACB = 0 ??? = 0 ?PO = 0 ?PAS = 0 ?PC = 0 ?IA = 0 ?PU = 0 ?ADJ = 0 ?lblpu = 0 ?N = 0000000000000000B ?AX = 0000000000000011B ?AH = 0000000000000001B ?AL = 0000000000000010B ?BX = 0000000000001100B ?BH = 0000000000000100B ?BL = 0000000000001000B ?CX = 0000000000110000B ?CH = 0000000000010000B ?CL = 0000000000100000B ?DX = 0000000011000000B ?DH = 0000000001000000B ?DL = 0000000010000000B ?SI = 0000000100000000B ?DI = 0000001000000000B ?ES = 0000010000000000B ?DS = 0000100000000000B ?BP = 0001000000000000B ?SP = 0010000000000000B ?SS = 0100000000000000B ?CS = 1000000000000000B uconcat macro n1,n2,o1,o2,p1,p2 n1&n2 o1&o2 p1&p2 endm mpush macro rV irp x, if rV AND ?&&x push x endif endm endm mpop macro rV irp x, if rV AND ?&&x pop x endif endm endm SAVE macro rL ?RSL = 0 ?RI ?RSL, endm smashes macro n,rL .xcref .xcref ?SM&n .cref ?SM&n = 0 ?RI ?SM&n, endm ?RI macro n,rL irp x, ifdef ?&&x n = n or ?&&x endif endm endm parmB macro nl ?pp <&nL>,,2,1 endm parmW macro nl ?pp <&nL>,,2,2 endm parmD macro nl ife ?PLM irp x, ?pp <&&x>,,0,4 ?pp ,,2,2 ?pp ,,2,2 endm else irp x, ?pp ,,2,2 ?pp ,,2,2 ?pp <&&x>,,0,4 endm endif endm parmQ macro nl ?pp <&nL>,,8,8 endm parmT macro nl ?pp <&nL>,,10,10 endm if sizeC parmCP macro nl parmD endm else parmCP macro nl parmW endm endif if sizeD parmDP macro nl parmD endm else parmDP macro nl parmW endm endif ?pp macro nL,t,l,s if ?CPD .xcref ife ?PLM irp x, ?pp1 x,,%?PO,%?adj,%(?PO+?adj) ?PO = ?PO + l .xcref ?T&&x ?T&&x = s endm else irp x, ?PO = ?PO + l ?pp1 x,,%?PO,%?adj,%(?PO+?adj) .xcref ?T&&x ?T&&x = s endm endif .cref else %out Parm(s) "&nl" declared outside proc def. endif endm ?pp1 macro n,t,o,a,b ife ?PLM n equ else n equ endif endm localB macro nL ?aLoc <&nL>,,1,1,0 endm localW macro nL ?aLoc <&nL>,,2,2,1 endm localD macro nL irp x, ?aLoc ,,2,2,1 ?aLoc ,,2,2,1 ?aLoc <&&x>,,0,4,1 endm endm localQ macro nL ?aLoc <&nL>,,8,8,1 endm localT macro nL ?aLoc <&nL>,,10,10,1 endm if sizeC localCP macro nL localD endm else localCP macro nL localW endm endif if sizeD localDP macro nL localD endm else localDP macro nL localW endm endif localV macro n,a ?aLoc <&n>,,%(&a),0,1 endm ?aLoc macro nL,t,l,s,a if ?CPD .xcref ??? = ??? + l if a ??? = ((??? + 1) AND 0FFFEH) endif irp x, ?aL1 x,,%??? .xcref ?T&&x ?T&&x = s endm .cref else %out Locals "&nl" declared outside procedure def. endif endm ?aL1 macro n,t,o if ?IA n equ else n equ endif endm globalB macro n,i,s ?aD ,1 ?dd n,1,,,, endm globalW macro n,i,s ?aD ,2 ?dd n,1,,,, endm globalD macro n,i,s ?aD ,4 ?dd n,1,,
,, endm globalQ macro n,i,s ?aD ,8 ?dd n,1,,,, endm globalT macro n,i,s ?aD ,10 ?dd n,1,,
,, endm if sizeC globalCP macro n,i,s globalD n,, endm else globalCP macro n,i,s globalW n,, endm endif if sizeD globalDP macro n,i,s globalD n,, endm else globalDP macro n,i,s globalW n,, endm endif staticB macro n,i,s ?aD ,1 ?dd n,0,,,, endm staticW macro n,i,s ?aD ,2 ?dd n,0,,,, endm staticD macro n,i,s ?aD ,4 ?dd n,0,,
,, endm staticQ macro n,i,s ?aD ,8 ?dd n,0,,,, endm staticT macro n,i,s ?aD ,10 ?dd n,0,,
,, endm if sizeC staticCP macro n,i,s staticD n,, endm else staticCP macro n,i,s staticW n,, endm endif if sizeD staticDP macro n,i,s staticD n,, endm else staticDP macro n,i,s staticW n,, endm endif ?dd macro n,p,t,d,i,s ife ?PLM n label t ?dd1 _&n,p,,, else ?dd1 n,p,,, endif endm ?dd1 macro n,p,d,i,s if p PUBLIC n endif ifb n d i else ifb n d s DUP (?) else n d s DUP (i) endif endif endm externB macro nL ?ex1 <&nL>,1, endm externW macro nL ?ex1 <&nL>,2, endm externD macro nL ?ex1 <&nL>,4, endm externQ macro nL ?ex1 <&nL>,8, endm externT macro nL ?ex1 <&nL>,10, endm externNP macro nL ?ex1 <&nL>,2, endm externFP macro nL ?ex1 <&nL>,4, endm if sizeC externP macro nL ?ex1 <&nL>,4, endm else externP macro nL ?ex1 <&nL>,2, endm endif if sizeC externCP macro nL ?ex1 <&nL>,4, endm else externCP macro nL ?ex1 <&nL>,2, endm endif if sizeD externDP macro nL ?ex1 <&nL>,4, endm else externDP macro nL ?ex1 <&nL>,2, endm endif ?ex1 macro nL,s,d irp x, .xcref .xcref ?T&&x .cref ?T&&x = s ife ?PLM extrn _&&x:&d x equ _&&x else extrn x:&d endif endm endm labelB macro nL ?lb1 <&nL>,1, endm labelW macro nL ?lb1 <&nL>,2, endm labelD macro nL ?lb1 <&nL>,4, endm labelQ macro nL ?lb1 <&nL>,8, endm labelT macro nL ?lb1 <&nL>,10, endm labelNP macro nL ?lb1 <&nL>,2, endm labelFP macro nL ?lb1 <&nL>,4, endm if sizeC labelP macro nL ?lb1 <&nL>,4, endm else labelP macro nL ?lb1 <&nL>,2, endm endif if sizeC labelCP macro nL ?lb1 <&nL>,4, endm else labelCP macro nL ?lb1 <&nL>,2, endm endif if sizeD labelDP macro nL ?lb1 <&nL>,4, endm else labelDP macro nL ?lb1 <&nL>,2, endm endif ?lb1 macro nL,s,d ?lblpu = 0 irp x, ifidn , ?lblpu = 1 else .xcref .xcref ?T&&x .cref ?T&&x = s ife ?PLM if ?lblpu public _&&x endif _&&x label &d x equ _&&x else if ?lblpu public x endif x label &d endif endif endm endm defB macro nL ?aD <&nL>,1 endm defW macro nL ?aD <&nL>,2 endm defD macro nL ?aD <&nL>,4 endm defQ macro nL ?aD <&nL>,8 endm defT macro nL ?aD <&nL>,10 endm if sizeC defCP macro nL defD endm else defCP macro nL defW endm endif if sizeD defDP macro nL defD endm else defDP macro nL defW endm endif ?aD macro nL,s irp x, .xcref .xcref ?T&&x .cref ?T&&x = s endm endm regPtr macro n,S,O .xcref .xcref ?T&n,?SR&n,?OR&n .cref ?T&n = 0FFFFH ?SR&n = 0 ?RI ?SR&n,<&S> ?OR&n = 0 ?RI ?OR&n,<&O> endm arg macro aArg irp x, ?argc = ?argc + 1 ?Atal ,%?argc endm endm ?Atal macro n,i .xcref .xcref ?ALI&i .cref ?ALI&i ¯o ?AP n &endm endm ?AP macro n ?argl = ?argl + 2 ifdef ?T&n ife ?T&n-1 push word ptr (n) exitm endif ife ?T&n-2 push n exitm endif ife ?T&n-4 push word ptr (n)+2 push word ptr (n) ?argl = ?argl + 2 exitm endif ife ?T&n-8 push word ptr (n)+6 push word ptr (n)+4 push word ptr (n)+2 push word ptr (n) ?argl = ?argl + 6 exitm endif ife ?T&n-0FFFFH mpush %(?SR&n) mpush %(?OR&n) ?argl = ?argl + 2 exitm endif ife ?T&n push word ptr (n) exitm endif endif push n endm ife ?PLM ccall macro n,a,extraArg ifnb Arg endif ifdef ?SM&n ?RSL = ?RSL AND ?SM&n endif mpush %?RSL ?argl = 0 ?ACB = ?argc rept ?argc uconcat ,%?ACB uconcat ,,,%?ACB ?ACB = ?ACB - 1 endm ife ?PLM ifb call _&n else call n endif else call n endif if ?argl add sp,?argl endif mpop %?RSL ?RSL = 0 ?argc = 0 ?argl = 0 endm else ccall macro n,a ifnb Arg endif ifdef ?SM&n ?RSL = ?RSL AND ?SM&n endif mpush %?RSL ?argl = 0 ?ACB = 1 rept ?argc uconcat ,%?ACB uconcat ,,,%?ACB ?ACB = ?ACB + 1 endm ife ?PLM call _&n else call n endif mpop %?RSL ?RSL = 0 ?argc = 0 ?argl = 0 endm endif cProc macro n,cla,s ?pd n,,,4 endm ?pd macro n,cla,a,i if ?CPD ?UTPE endif ?CPD = 1 ??? = 0 ?argc = 0 ?BA = 0 ?PO = 0 ?PU = 0 ?IA = 0 ?adj = i ?PAS = 0 ifnb ?RI ?PAS, endif ?PC = sizeC irp x, ifidn , ?PC = 1 endif ifidn , ?PC = 0 endif ifidn , ?PU = 1 endif endm if ?PC ?adj = ?adj + 2 endif ife ?PLM ife ?PC n label near else n label far endif ?pg <_&n>,%?PU,%?PC,%?PAS else ?pg ,%?PU,%?PC,%?PAS endif endm ?pg macro n,p,cla,a .xcref cBegin ¯o g .xcref ?pg1 ,c,a,%?PO ?CPD = 0 ?argc = 0 ?BA = 1 ??? = (???+1) AND 0FFFEH if p PUBLIC n endif ife cla n proc NEAR else n proc FAR endif ifidn , if ???+?PO+a ??_out endif else if ?IA mov ax,ds nop inc bp push bp mov bp,sp push ds mov ds,ax else push bp mov bp,sp endif if ??? sub sp,??? endif mPush a endif .cref purge cBegin &endm ?UTPE ¯o %out Unterminated Procedure Definition: "&n" &endm endm ?pg1 macro n,cla,a,o .xcref cEnd ¯o g .xcref ?BA = 0 ifidn , if o+a %out endif else mPop a if ?IA sub bp,2 mov sp,bp pop ds pop bp dec bp else ifdif , mov sp,bp endif pop bp endif ife ?PLM ret else ret o endif endif n endp .cref purge cEnd &endm .cref endm assumes macro s,g local assumed assumed = 0 ifidn , assume s&:_TEXT assumed = 1 endif ifidn , assume s&:_TEXT assumed = 1 endif ifidn , assume s&:dgroup assumed = 1 endif ifidn , assume s&:dgroup assumed = 1 endif ife assumed assume s&:&g endif endm createSeg macro n,ln,a,co,cla,grp ifnb n segment a co '&cla' else n segment a co endif n ends ?cs1 , ifnb grp group n endif endm defGrp macro nam endm ?cs1 macro n,ln begin&ln ¯o ?cs2 n segment &endm endm ?cs2 macro n sEnd ¯o dummy n ends &endm endm sBegin macro ln begin&ln endm ife ?DF createSeg _TEXT,code,word,public,CODE createSeg _DATA,data,word,public,DATA,DGROUP defGrp DGROUP codeOFFSET equ dataOFFSET equ endif errnz macro x if x errnz1 ,%(x) endif endm errnz1 macro x1,x2 = *ERRNZ* x1 = x2 endm errn$ macro l,x errnz ENDM callcrt MACRO funcname if sizeC push cs call near ptr (funcname) else call funcname endif ENDM ;******************************************************************************* ;******************************************************************************* ;cmphlp.inc - include to aid in generating compiler helpers ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; This file is a compiler helper include to aid in generating ; backwards compatible compiler helpers. ; ;******************************************************************************* callnahlpr MACRO nm ;;call non-assigning helper if sizeC push cs call near ptr __aF&nm else call near ptr __aN&nm endif ENDM DFLT MACRO tag,prfx,nm externP _a&prfx&tag&nm cProc _&tag&nm,,<> cBegin nogen jmp _a&prfx&tag&nm cEnd nogen ENDM DFLT2 MACRO tag,prfx,nm externP _a&prfx&tag&nm cProc _&tag&u&nm,,<> cBegin nogen cEnd nogen cProc _&tag&nm,,<> cBegin nogen jmp _a&prfx&tag&nm cEnd nogen ENDM ASGN MACRO nm ;;macro to fix up entry sequence of non ;;assigning code helpers if sizeC cProc _aF&nm,,<> cBegin else cProc _aN&nm,,<> cBegin endif ENDM aASGN MACRO nm ;;macro to fix up entry sequence of assigning ;;code helpers if memL eq 1 externP _aF&nm cProc _aFFa&nm,,<> cBegin endif if memM eq 1 externP _aF&nm cProc _aFNa&nm,,<> cBegin endif if memC eq 1 externP _aN&nm cProc _aNFa&nm,,<> cBegin endif if memS eq 1 externP _aN&nm cProc _aNNa&nm,,<> cBegin endif ENDM OLDSLEAZ MACRO ifdef lhdiff OLDASGN hdiff endif ifdef llshl OLDASGN lshl endif ifdef llshr OLDASGN lshr endif ifdef lulshr OLDASGN ulshr endif ifdef lldiv OLDASGN ldiv endif ifdef llmul OLDASGN2 lmul endif ifdef llrem OLDASGN lrem endif ifdef luldiv OLDASGN uldiv endif ifdef lulrem OLDASGN ulrem endif ENDM ;******************************************************************************* ;******************************************************************************* ;mm.inc - macros to write memory model dependent code ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; This file contains definitions of a number of macros which ; make the writing of memory model dependent code for the ; 8086 a little easier and more portable. ; ;******************************************************************************* ; general code & data size constants & macros if sizeD ; 4 byte data addresses DAT_ADDR_SZ = 4 BDAT_ADDR_SZ = 2 else ; 2 byte data addresses DAT_ADDR_SZ = 2 BDAT_ADDR_SZ = 4 endif if sizeC ; 4 byte code addresses TXT_ADDR_SZ = 4 else ; 2 byte code addresses TXT_ADDR_SZ = 2 endif ; Big/Little Endian Definitions for Long Integers LOWORD equ [0] HIWORD equ [2] ; All Model Definitions BPARGBAS equ TXT_ADDR_SZ+2 ; offset from BP to first argument ; macro for windows fixup with retf # return macro n org $-1 if sizeC db 0cah else db 0c2h endif dw n endm ;*******************************************************************************