home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 06 / alib / asm.inc < prev    next >
Text File  |  1991-08-22  |  2KB  |  151 lines

  1.     .xlist
  2.     page    63,128
  3.  
  4.     .model    small
  5.     ASSUME    ds:nothing
  6.     includelib alib
  7.  
  8.  
  9. bptr            equ    byte ptr
  10. wptr            equ    word ptr
  11. dptr            equ    dword ptr
  12.  
  13. stdin            equ    0
  14. stdout            equ    1
  15. stderr            equ    2
  16.  
  17. EXIT_SUCCESS        equ    0
  18. EXIT_FAILURE        equ    1
  19.  
  20. FILENAME_MAX        equ    80
  21. FOPEN_MAX        equ    20
  22.  
  23. ZER0            equ    0
  24.  
  25. NULL_POINTER        equ    0
  26. NULL_HANDLE        equ    0
  27.  
  28. NULL_CHAR        equ    0
  29. BEL_CHAR        equ    7
  30. BS_CHAR            equ    8
  31. TAB_CHAR        equ    9
  32. HT_CHAR            equ    9
  33. NL_CHAR            equ    10
  34. LF_CHAR            equ    10    ; linefeed
  35. VT_CHAR            equ    11
  36. FF_CHAR            equ    12
  37. CR_CHAR            equ    13    ; carriage return
  38. ESC_CHAR        equ    27
  39. SPACE_CHAR        equ    ' '
  40.  
  41. NEWLINE_CHARS        equ    0A0Dh
  42.  
  43. BLOCK_SIZE        equ    16384    ; size of an EMS block
  44.  
  45. DGROUP_REGISTER        equ    ss    ; this register assumed to be DGROUP
  46.  
  47.  
  48. ; MACROs
  49.  
  50. ; smart CMP marco
  51. ;
  52. cmpx    macro    dst,src
  53.     if    src eq 0
  54.     or    dst,dst
  55.     else
  56.     cmp    dst,src
  57.     endif
  58.     endm
  59.  
  60.  
  61. ; smart MOV macro
  62. ;
  63. movx    macro    dst,src
  64.     ifidn    <src>,<DGROUP_SEGMENT>
  65.     push    ss
  66.     pop    dst
  67.     exitm
  68.     endif
  69.  
  70.     if    (type src) eq 0            ; if register or constant AND
  71.     if    ((.type src) and 11100b) eq 0    ; if not any register      AND
  72.     if    src eq 0            ; if source is zero
  73.     sub    dst,dst                ; then efficiently 0 register
  74.     exitm
  75.     endif
  76.     endif
  77.     endif
  78.  
  79.     mov    dst,src
  80.     endm
  81.  
  82.  
  83. ; OPTASM macros
  84. ;
  85.     IFNDEF    .date    ; if not OPTASM
  86.     .sall        ; don't show macro contents
  87.  
  88. extb    macro    a,b,c,d,e,f,g,h,i,j,k
  89.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  90.     ifnb    <xx>
  91.     extrn    xx:byte
  92.     else
  93.     exitm
  94.     endif
  95.     endm
  96.     endm
  97.  
  98. extd    macro    a,b,c,d,e,f,g,h,i,j,k
  99.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  100.     ifnb    <xx>
  101.     extrn    xx:dword
  102.     else
  103.     exitm
  104.     endif
  105.     endm
  106.     endm
  107.  
  108. extn    macro    a,b,c,d,e,f,g,h,i,j,k
  109.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  110.     ifnb    <xx>
  111.     extrn    xx:near
  112.     else
  113.     exitm
  114.     endif
  115.     endm
  116.     endm
  117.  
  118. extw    macro    a,b,c,d,e,f,g,h,i,j,k
  119.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  120.     ifnb    <xx>
  121.     extrn    xx:word
  122.     else
  123.     exitm
  124.     endif
  125.     endm
  126.     endm
  127.  
  128. pushm    macro    a,b,c,d,e,f,g,h,i,j,k
  129.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  130.     ifnb    <xx>
  131.     push    xx
  132.     else
  133.     exitm
  134.     endif
  135.     endm
  136.     endm
  137.  
  138. popm    macro    a,b,c,d,e,f,g,h,i,j,k
  139.     irp    xx,<a,b,c,d,e,f,g,h,i,j,k>
  140.     ifnb    <xx>
  141.     pop    xx
  142.     else
  143.     exitm
  144.     endif
  145.     endm
  146.     endm
  147.  
  148.     ENDIF        ; end MASM/TASM macros
  149.  
  150.     .list        ; end of asm.inc
  151.