home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / psp_io / include / macro.inc < prev   
Text File  |  1994-04-22  |  5KB  |  142 lines

  1. ;****************************************************************************
  2. ;                               M A C R O . I N C
  3. ;============================================================================
  4. ;       Commonly used macros to be included in assembly language routines.
  5. ;****************************************************************************
  6.  
  7. ;===============================================================
  8. ; Macro:        =*=DOS_21H=*=
  9. ;---------------------------------------------------------------
  10. ; Task:         Call dos interrupt 21h.
  11. ; Input:        none
  12. ; Output:       none
  13. ; Registers:    none
  14. ;================================================================
  15. MACRO   DOS_21H
  16.         int     21h             ;; Call dos interrupt 21h.
  17. ENDM
  18.  
  19. ;===============================================================
  20. ; Macro:        =*=Function=*=
  21. ;---------------------------------------------------------------
  22. ; Task:         Insert function number in ah register for calling
  23. ;               BIOS & DOS functions.
  24. ; Input:        Function # in ah.
  25. ; Output:       none
  26. ; Registers:    ah changed.
  27. ;===============================================================
  28. MACRO   Function        n
  29.         mov     ah, n           ;; Inserts function number in ah register.
  30. ENDM
  31.  
  32. ;===============================================================
  33. ; Macro:        =*=SaveRegs=*=
  34. ;---------------------------------------------------------------
  35. ; Task:         Save registers on stack.
  36. ; Input:        Registers to save (enclosed in <and>).
  37. ; Output:       none
  38. ; Registers:    none
  39. ; Note:         Registers are saved in the order listed.
  40. ;===============================================================
  41. MACRO   SaveRegs        registers
  42.   IRP   reg, <registers>        ;; Uses IRP to save list of regs on stack.
  43.         push    reg             ;; Save register on stack.
  44.  ENDM
  45. ENDM    SaveRegs
  46.  
  47. ;===============================================================
  48. ; Macro:        =*=RestoreRegs=*=
  49. ;---------------------------------------------------------------
  50. ; Task:         Restore registers saved on stack.
  51. ; Input:        Registers to save.
  52. ; Output:       none
  53. ; Registers:    none
  54. ; Note:         Registers are restored in the order listed.
  55. ;               Registers must be restored in the opposite order
  56. ;               they are saved.
  57. ;===============================================================
  58. MACRO   RestoreRegs     registers
  59.   IRP   reg, <registers>        ;; Uses IRP directive to pop registers.
  60.         pop    reg
  61.   ENDM
  62. ENDM    RestoreRegs
  63.  
  64. ;===============================================================
  65. ; Macro:        =*=smove=*=
  66. ;---------------------------------------------------------------
  67. ; Task:         Move contents of one segment register to another
  68. ;               segment register.
  69. ; Input:        Destination register, source register.
  70. ; Output:       Source value in destination register.
  71. ; Registers:    Destination register changed.
  72. ;===============================================================
  73. MACRO   smove   segreg2, segreg1
  74.         push    segreg1
  75.         pop     segreg2
  76. ENDM    smove
  77.  
  78. ;===============================================================
  79. ; Macros:       =*=mmoveB/mmoveW=*=
  80. ;---------------------------------------------------------------
  81. ; Task:         Move byte/word from one memory location to another.
  82. ; Input:        dest=memB/memW, srce=memB/memW
  83. ; Output:       Source copied to destination.
  84. ; Registers:    none
  85. ;===============================================================
  86. MACRO   mmoveB  memdest, memsrce
  87.         push    ax
  88.         mov     al, memsrce
  89.         mov     memdest, al
  90.         pop     ax
  91. ENDM    mmoveB
  92.  
  93. MACRO   mmoveW  memdest, memsrce
  94.         push    ax
  95.         mov     ax, memsrce
  96.         mov     memdest, ax
  97.         pop     ax
  98. ENDM    mmoveW
  99.  
  100. ;===============================================================
  101. ; Macros:       =*=xshl/xshr=*=
  102. ;---------------------------------------------------------------
  103. ; Task:         Shift bits in register or memory to the left or
  104. ;               right by a specified number of places.
  105. ; Input:        memReg = word or byte in memory or register to shift.
  106. ;               count  = shift displacement (byte value only).
  107. ; Output:       Bits shifted.
  108. ; Registers:    none
  109. ;===============================================================
  110. MACRO   xshl    memReg, count
  111.  REPT   count
  112.         shl     memReg, 1
  113.  ENDM
  114. ENDM    xshl
  115.  
  116. MACRO   xshr    memReg, count
  117.  REPT   count
  118.         shr     memReg, 1
  119.  ENDM
  120. ENDM    xshr
  121.  
  122. ;===============================================================
  123. ; Macros:       =*=xinc/xdec=*=
  124. ;---------------------------------------------------------------
  125. ; Task:         Increment/decrement register/variable (byte or word).
  126. ; Input:        memReg = register or variable to increment.
  127. ;               count  = Number of times to increment/decrement.
  128. ; Output:       Register or variable incremented.
  129. ; Registers:    none
  130. ;===============================================================
  131. MACRO   xinc    memReg, count
  132.  REPT   count
  133.         inc     memReg
  134.  ENDM
  135. ENDM    xinc
  136.  
  137. MACRO   xdec    memReg, count
  138.  REPT   count
  139.         dec     memReg
  140.  ENDM
  141. ENDM    xdec
  142.