home *** CD-ROM | disk | FTP | other *** search
- ;****************************************************************************
- ; M A C R O . I N C
- ;============================================================================
- ; Commonly used macros to be included in assembly language routines.
- ;****************************************************************************
-
- ;===============================================================
- ; Macro: =*=DOS_21H=*=
- ;---------------------------------------------------------------
- ; Task: Call dos interrupt 21h.
- ; Input: none
- ; Output: none
- ; Registers: none
- ;================================================================
- MACRO DOS_21H
- int 21h ;; Call dos interrupt 21h.
- ENDM
-
- ;===============================================================
- ; Macro: =*=Function=*=
- ;---------------------------------------------------------------
- ; Task: Insert function number in ah register for calling
- ; BIOS & DOS functions.
- ; Input: Function # in ah.
- ; Output: none
- ; Registers: ah changed.
- ;===============================================================
- MACRO Function n
- mov ah, n ;; Inserts function number in ah register.
- ENDM
-
- ;===============================================================
- ; Macro: =*=SaveRegs=*=
- ;---------------------------------------------------------------
- ; Task: Save registers on stack.
- ; Input: Registers to save (enclosed in <and>).
- ; Output: none
- ; Registers: none
- ; Note: Registers are saved in the order listed.
- ;===============================================================
- MACRO SaveRegs registers
- IRP reg, <registers> ;; Uses IRP to save list of regs on stack.
- push reg ;; Save register on stack.
- ENDM
- ENDM SaveRegs
-
- ;===============================================================
- ; Macro: =*=RestoreRegs=*=
- ;---------------------------------------------------------------
- ; Task: Restore registers saved on stack.
- ; Input: Registers to save.
- ; Output: none
- ; Registers: none
- ; Note: Registers are restored in the order listed.
- ; Registers must be restored in the opposite order
- ; they are saved.
- ;===============================================================
- MACRO RestoreRegs registers
- IRP reg, <registers> ;; Uses IRP directive to pop registers.
- pop reg
- ENDM
- ENDM RestoreRegs
-
- ;===============================================================
- ; Macro: =*=smove=*=
- ;---------------------------------------------------------------
- ; Task: Move contents of one segment register to another
- ; segment register.
- ; Input: Destination register, source register.
- ; Output: Source value in destination register.
- ; Registers: Destination register changed.
- ;===============================================================
- MACRO smove segreg2, segreg1
- push segreg1
- pop segreg2
- ENDM smove
-
- ;===============================================================
- ; Macros: =*=mmoveB/mmoveW=*=
- ;---------------------------------------------------------------
- ; Task: Move byte/word from one memory location to another.
- ; Input: dest=memB/memW, srce=memB/memW
- ; Output: Source copied to destination.
- ; Registers: none
- ;===============================================================
- MACRO mmoveB memdest, memsrce
- push ax
- mov al, memsrce
- mov memdest, al
- pop ax
- ENDM mmoveB
-
- MACRO mmoveW memdest, memsrce
- push ax
- mov ax, memsrce
- mov memdest, ax
- pop ax
- ENDM mmoveW
-
- ;===============================================================
- ; Macros: =*=xshl/xshr=*=
- ;---------------------------------------------------------------
- ; Task: Shift bits in register or memory to the left or
- ; right by a specified number of places.
- ; Input: memReg = word or byte in memory or register to shift.
- ; count = shift displacement (byte value only).
- ; Output: Bits shifted.
- ; Registers: none
- ;===============================================================
- MACRO xshl memReg, count
- REPT count
- shl memReg, 1
- ENDM
- ENDM xshl
-
- MACRO xshr memReg, count
- REPT count
- shr memReg, 1
- ENDM
- ENDM xshr
-
- ;===============================================================
- ; Macros: =*=xinc/xdec=*=
- ;---------------------------------------------------------------
- ; Task: Increment/decrement register/variable (byte or word).
- ; Input: memReg = register or variable to increment.
- ; count = Number of times to increment/decrement.
- ; Output: Register or variable incremented.
- ; Registers: none
- ;===============================================================
- MACRO xinc memReg, count
- REPT count
- inc memReg
- ENDM
- ENDM xinc
-
- MACRO xdec memReg, count
- REPT count
- dec memReg
- ENDM
- ENDM xdec
-