home *** CD-ROM | disk | FTP | other *** search
/ Software Collection (I) / TOOLS.iso / f30 / source / srmacros.inc < prev    next >
Encoding:
Text File  |  1993-03-23  |  4.2 KB  |  134 lines

  1.  
  2. ; Macros which may be required for proper re-assembly
  3.  
  4. IF (target EQ 'M4')
  5. ;-----------------------------------------------------------------------------
  6. ;  MASM 4.0 does not allow retf and retn, allowed by current assemblers.
  7. ;  These marcos, convert RETF and RETN into data bytes that are acceptable
  8. ;  to MASM 4.0.
  9.  
  10.  
  11. retf            macro   ret_count               ; Fixup for Assembler
  12.                 if      ret_count+0 GT 1
  13.                 db      0CAh
  14.                 dw      ret_count
  15.                 else
  16.                 db      0CBh
  17.                 endif
  18. endm
  19.  
  20. retn            macro  ret_count
  21.                 if     ret_count+0 GT 1
  22.                 db     0C2h
  23.                 dw     ret_count
  24.                 else
  25.                 db     0C3h
  26.                 endif
  27. endm
  28.  
  29. ENDIF
  30.  
  31.  
  32. IF (target EQ 'M4') OR (target EQ 'M5') 
  33. ;-----------------------------------------------------------------------------
  34. ; Due to a bug in earlier MASM assemblers, the valid instruction type 
  35. ; "mov segreg, reg"  cannot be used, if the register is not AX.  
  36. ; For example:  mov  es, bx
  37.  
  38. movseg          macro reg16, unused, Imm16      ; Fixup for Assembler
  39.                 ifidn  <reg16>, <bx>            
  40.                 db     0BBh                     
  41.                 endif                           
  42.                 ifidn  <reg16>, <cx>            
  43.                 db     0B9h                     
  44.                 endif
  45.                 ifidn  <reg16>, <dx>
  46.                 db     0BAh
  47.                 endif
  48.                 ifidn  <reg16>, <si>
  49.                 db     0BEh
  50.                 endif
  51.                 ifidn  <reg16>, <di>
  52.                 db     0BFh
  53.                 endif
  54.                 ifidn  <reg16>, <bp>
  55.                 db     0BDh
  56.                 endif
  57.                 ifidn  <reg16>, <sp>
  58.                 db     0BCh
  59.                 endif
  60.                 ifidn  <reg16>, <BX>
  61.                 db     0BBH
  62.                 endif
  63.                 ifidn  <reg16>, <CX>
  64.                 db     0B9H
  65.                 endif
  66.                 ifidn  <reg16>, <DX>
  67.                 db     0BAH
  68.                 endif
  69.                 ifidn  <reg16>, <SI>
  70.                 db     0BEH
  71.                 endif
  72.                 ifidn  <reg16>, <DI>
  73.                 db     0BFH
  74.                 endif
  75.                 ifidn  <reg16>, <BP>
  76.                 db     0BDH
  77.                 endif
  78.                 ifidn  <reg16>, <SP>
  79.                 db     0BCH
  80.                 endif
  81.                 dw     seg Imm16
  82. endm
  83.  
  84. ENDIF
  85.  
  86.  
  87. IF (target EQ 'T3') or (target EQ 'T2')
  88. ;-----------------------------------------------------------------------------
  89. ; Some assemblers, like TASM, check each far call, to see if the subroutine is 
  90. ; in the same segment as the call.  If so, rather than produce the standard 
  91. ; five byte far call, they push cs, and call near.  For byte identical code, 
  92. ; this macro forces the standard far call.  
  93.  
  94. calls           macro   dummy1, dummy2, slocation
  95.                 db      9Ah                     ; forced call far instruction
  96.                 dw      offset slocation, seg slocation
  97. endm
  98.  
  99. ENDIF
  100.  
  101.  
  102.  
  103. IFE (target EQ 'NO')
  104. ;-----------------------------------------------------------------------------
  105. ;  Some compilers and some assemblers will code a call that goes to a far
  106. ;  subroutine in the same segment as:
  107. ;
  108. ;               PUSH    CS
  109. ;               CALL    near
  110. ;
  111. ;  This saves one byte, and is slightly faster.  If the assembler you are
  112. ;  using (i.e. MASM, Optasm) does not do this automatically, the following
  113. ;  macros are used to code the same information.  In other words, the binary
  114. ;  file has "PUSH CS, CALL near", and Sourcer ensures the same instructions
  115. ;  are used!  (macro CALLF)
  116. ;
  117.  
  118. callf           macro   location
  119.                 push    cs
  120.                 call    near ptr location
  121. endm
  122.  
  123. ;  Some compilers generate an unnecessary DS override on the call instruction
  124. ;  when compacting the CALLF type function.  Macro CALLFX handles this case.
  125.  
  126. callfx          macro   location
  127.                 push    cs
  128.                 db      3Eh
  129.                 call    near ptr location
  130. endm
  131.  
  132. ENDIF
  133.  
  134.