home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / BEGINASM.MAC next >
Encoding:
Text File  |  1989-03-31  |  5.4 KB  |  260 lines

  1. ;
  2. ;  BEGINASM.MAC  --  Compiler-dependent symbols and macros.
  3. ;
  4. ;  Version 6.00 (C)Copyright Blaise Computing Inc. 1987, 1988
  5.  
  6. include   compiler.mac           ; Specifies the C compiler and
  7.                    ; memory model.
  8.  
  9. ShortP equ 0               ; Short Pointer
  10. LongP  equ 1               ; Long Pointer
  11.  
  12. if BTINY
  13.     __TINY__ equ 1           ; For Turbo C's RULES.ASI
  14.     CodeT equ ShortP           ; CodeT -- Type of code (long or short)
  15.     DataT equ ShortP           ; DataT -- Type of data (long or short)
  16. endif
  17.  
  18. if BSMALL
  19.     __SMALL__ equ 1           ; For Turbo C's RULES.ASI
  20.     CodeT equ ShortP           ; CodeT -- Type of code (long or short)
  21.     DataT equ ShortP           ; DataT -- Type of data (long or short)
  22. endif
  23.  
  24. if BMEDIUM
  25.     __MEDIUM__ equ 1           ; For Turbo C's RULES.ASI
  26.     CodeT equ LongP           ; CodeT -- Type of code (long or short)
  27.     DataT equ ShortP           ; DataT -- Type of data (long or short)
  28. endif
  29.  
  30. if BCOMPACT
  31.     __COMPACT__ equ 1           ; For Turbo C's RULES.ASI
  32.     CodeT equ ShortP           ; CodeT -- Type of code (long or short)
  33.     DataT equ LongP           ; DataT -- Type of data (long or short)
  34. endif
  35.  
  36. if BLARGE
  37.     __LARGE__ equ 1; For Turbo C's RULES.ASI
  38.     CodeT equ LongP; CodeT -- Type of code (long or short)
  39.     DataT equ LongP; DataT -- Type of data (long or short)
  40. endif
  41.  
  42. if BHUGE
  43.     __HUGE__ equ 1 ; For Turbo C's RULES.ASI
  44.     CodeT equ LongP; CodeT -- Type of code (long or short)
  45.     DataT equ LongP; DataT -- Type of data (long or short)
  46. endif
  47.  
  48.  
  49. longData  equ (DataT eq LongP)
  50. longProg  equ (CodeT eq LongP)
  51.  
  52. shortData equ (DataT eq ShortP)
  53. shortProg equ (CodeT eq ShortP)
  54.  
  55. sizeChar       equ 1
  56. sizeCharOnStk  equ 2
  57. sizeDouble     equ 8
  58. sizeEnum       equ 2
  59. sizeFloat      equ 4
  60. sizeInt        equ 2
  61. sizeLong       equ 4
  62. sizeLongDouble equ 8
  63. sizeShort      equ 2
  64.  
  65. if longData
  66.     sizeDPointer equ 4
  67. else
  68.     sizeDPointer equ 2
  69. endif
  70.  
  71. if longProg
  72.     sizeCPointer equ 4
  73. else
  74.     sizeCPointer equ 2
  75. endif
  76.  
  77. beginCseg macro sname           ;;Begin code macro.
  78.     if shortProg
  79.     _TEXT segment byte public 'code'
  80.     assume cs:_TEXT
  81.     else
  82.     sname&_TEXT segment byte public 'code'
  83.     assume cs:sname&_TEXT
  84.     endif
  85.     endm
  86.  
  87. endCseg macro sname           ;;End code macro.
  88.     if shortProg
  89.     _TEXT ends
  90.     else
  91.     sname&_TEXT ends
  92.     endif
  93.     endm
  94.  
  95. beginDSeg macro sname           ;;Start a data segment
  96.     if BHUGE
  97.     sname&_DATA segment word public 'DATA'
  98.     else
  99.     _DATA segment word public 'DATA'
  100.     endif
  101.     endm
  102.  
  103. endDSeg macro sname           ;;End a data segment
  104.     if BHUGE
  105.     sname&_DATA ends
  106.     else
  107.     _DATA ends
  108.     endif
  109.     endm
  110.  
  111.  
  112. if MSC500
  113.     if longProg            ; Set up parameter offset.
  114.     stkoff equ 6
  115.     else
  116.     stkoff equ 4
  117.     endif
  118.  
  119.     makeName macro myname       ;;Create a symbol with underscore
  120.     myname&@ equ <_&myname>    ;; if necessary.
  121.     endm
  122.  
  123.     beginMod macro mname       ;;Begin module macro.
  124.     name mname
  125.     endm
  126.  
  127.     endMod macro mname           ;;End module macro.
  128.     ; end module mname
  129.     endm
  130.  
  131.     beginProc macro pname       ;;Begin procedure macro.
  132.     makeName pname
  133.     ifdef @Version
  134. %        public pname&@
  135.     else
  136.         public pname&@
  137.     endif
  138.     if longProg
  139.         pname&@ proc far
  140.     else
  141.         pname&@ proc near
  142.     endif
  143.     endm
  144.  
  145.     endProc macro pname        ;;End procedure macro.
  146.     pname&@ endp
  147.     endm
  148.  
  149.     pubSym macro vname,definition  ;;Define public variable.
  150.     makeName vname
  151.     public vname&@
  152. vname&@ definition
  153.     endm
  154.  
  155.     extSym macro vname,data_type   ;;Declare external variable.
  156.     makeName vname
  157.     extrn vname&@:data_type
  158.     endm
  159.  
  160.     extDPtr macro pname        ;;Declare external data pointer.
  161.     makeName pname
  162.     if longData
  163.         extrn pname&@:dword
  164.     else
  165.         extrn pname&@:word
  166.     endif
  167.     endm
  168.  
  169.     extCPtr macro pname        ;;Declare external code pointer.
  170.     makeName pname
  171.     if longProg
  172.         extrn pname&@:dword
  173.     else
  174.         extrn pname&@:word
  175.     endif
  176.     endm
  177.  
  178.     extProc macro pname        ;;Declare external function.
  179.     makeName pname
  180.     if longProg
  181.         extrn pname&@:far
  182.     else
  183.         extrn pname&@:near
  184.     endif
  185.     endm
  186. endif
  187.  
  188.  
  189. if TC100
  190.     include rules.asi
  191.  
  192.     if longProg            ; Set up parameter offset.
  193.     stkoff equ aParam
  194.     else
  195.     stkoff equ nearParam
  196.     endif
  197.  
  198.     beginMod macro mname       ;;Begin module macro.
  199.     name mname
  200.     endm
  201.  
  202.     endMod macro mname           ;;End module macro.
  203.     ; end module mname
  204.     endm
  205.  
  206.     beginProc macro pname       ;;Begin procedure macro.
  207.     PubProc@ pname,NOT_PASCAL
  208.     endm
  209.  
  210.     endProc macro pname        ;;End procedure macro.
  211.     EndProc@ pname,NOT_PASCAL
  212.     endm
  213.  
  214.     pubSym macro vname,definition  ;;Define public variable.
  215.     PubSym@ vname,<definition>,NOT_PASCAL
  216.     endm
  217.  
  218.     extSym macro vname,data_type   ;;Declare external variable.
  219.     ExtSym@ vname,data_type,NOT_PASCAL
  220.     endm
  221.  
  222.     extDPtr macro pname        ;;Declare external data pointer.
  223.     dPtrExt@ pname,NOT_PASCAL
  224.     endm
  225.  
  226.     extCPtr macro pname        ;;Declare external code pointer.
  227.     cPtrExt@ pname,NOT_PASCAL
  228.     endm
  229.  
  230.     extProc macro pname        ;;Declare external function.
  231.     ExtProc@ pname,NOT_PASCAL
  232.     endm
  233. endif
  234.  
  235.  
  236. beginProg macro zname           ;;Generic begin program macro.
  237.     beginMod zname
  238.     beginCseg zname
  239.     beginProc zname
  240.     endm
  241.  
  242. endProg macro zname           ;;Generic end program macro.
  243.     endProc zname
  244.     endCseg zname
  245.     endMod zname
  246.     endm
  247.  
  248.  
  249. popff  macro               ;; Simulate POPF instruction w/o bugs
  250.     local    do_call, do_iret
  251.     jmp    short do_call
  252.  
  253. do_iret:
  254.     iret               ;; Pop IP, CS, flags.
  255.  
  256. do_call:
  257.     push   cs           ;; Push CS
  258.     call   do_iret           ;; Push IP & jump.
  259.     endm
  260.