home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 4.ddi / NETBIOS / ASM.INC next >
Encoding:
Text File  |  1989-04-18  |  2.1 KB  |  118 lines

  1. comment !
  2.              *****                                *****
  3.              ***** PROLOGUE FOR ASSEMBLY LANGUAGE *****
  4.              *****                                *****
  5.  
  6.     This sets up the assembler for a small model -- two 64k segments --
  7.     one for code and one for data.  Also contains miscellaneous macros
  8.     for (1) abbreviating keywords (2) switching assembly segments and
  9.     (3) starting an exe program and forcing stack to DS segment.
  10.  
  11.     After inclusion of this model, the code segment is the active segment.
  12.  
  13.     Things found in here are:
  14.       abbreviations            WO BY DWO OFS ODG OTX 
  15.       constants            TRUE FALSE
  16.       assembly seg switchers    CSEG DSEG
  17.       end of module cleanup        END_MOD
  18.       int 21 macro            DOS
  19.       far ret macro            retf
  20.       push/pop register list    PUSHM POPM
  21. !
  22.  
  23. ;define segments and their order in memory
  24.  
  25. _TEXT segment word public 'CODE'
  26. _TEXT    ends
  27. CONST    segment word public 'CONST'
  28. CONST    ends
  29. _BSS    segment word public 'BSS'
  30. _BSS    ends
  31. _DATA    segment word public 'DATA'
  32. _DATA    ends
  33. STACK    segment para stack 'STACK'
  34. STACK    ends
  35.  
  36. ;all data in one group
  37. DGROUP    group CONST, _BSS, _DATA
  38.  
  39.  
  40. ;short-hand
  41. WO    equ    word ptr
  42. BY    equ    byte ptr
  43. DWO    equ    dword ptr
  44. OFS    equ    offset
  45. ODG    equ    offset DGROUP:
  46. OTX    equ    offset _TEXT:
  47.  
  48. TRUE    =    -1
  49. FALSE    =    0
  50.  
  51.  
  52. ;macro to revert to _TEXT segment
  53. CSEG macro
  54.   if @dataflag
  55.     _DATA ends
  56.     @dataflag = FALSE
  57.   endif
  58. endm
  59.  
  60. ;macro to switch to _DATA segment
  61. DSEG macro
  62.   if not @dataflag
  63.     _DATA segment
  64.     @dataflag = TRUE
  65.   endif
  66. endm
  67.  
  68. ;macro put at end to cleanup
  69. END_MOD macro
  70.   CSEG
  71.   _TEXT ends
  72. endm
  73.  
  74.  
  75.  
  76. ;dos function call
  77. DOS macro n
  78.   if (0ff00h and n) ne 0
  79.     mov    ax,n
  80.   else
  81.     mov ah,n
  82.   endif
  83.   int    21h
  84. endm
  85.  
  86. ;far ret macro
  87. retf macro n
  88.     local p1
  89.   p1 proc far
  90.     ret n
  91.   p1 endp
  92. endm
  93.  
  94. ;pushm regs macro
  95. ; PUSHM <r1,r2,...>
  96.  
  97. PUSHM macro rlist
  98.   irp x,<rlist>
  99.     push x
  100.   endm
  101. endm
  102.  
  103. ;popm regs macro
  104. ; POPM <r1,r2,...>
  105.  
  106. POPM macro rlist
  107.   irp x,<rlist>
  108.     pop x
  109.   endm
  110. endm
  111.  
  112.  
  113. ;leave includer in code segment, with cs,ds assumed set
  114. @dataflag = FALSE    ;flag for seg switching macros
  115. _TEXT    segment
  116.     assume cs:_TEXT, ds:DGROUP
  117.  
  118.