home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / asm / 3dvect25 / macros.inc < prev    next >
Encoding:
Text File  |  1993-06-25  |  2.8 KB  |  109 lines

  1. ; macros used throughout
  2.  
  3. pushw      macro ww  ; push word, used for pushing constants
  4.            mov ax,ww
  5.            push ax
  6.            endm
  7.  
  8. line       macro xx1,yy1,xx2,yy2,col
  9.            pushw xx1
  10.            pushw yy1
  11.            pushw xx2
  12.            pushw yy2
  13.            pushw col
  14.            call draw_line
  15.            endm
  16.  
  17. block      macro xx1,yy1,xx2,yy2,col
  18.            push xx1 yy1 xx2 yy2 col
  19.            call fill_block
  20.            endm
  21.  
  22. char       macro chr,xx,yy,fc ; plot character
  23.  
  24.            push ax bx cx dx
  25.            mov ax,chr
  26.            push ax
  27.            mov ax,xx
  28.            push ax
  29.            mov ax,yy
  30.            push ax
  31.            mov ax,0
  32.            push ax
  33.            call tgprintc
  34.  
  35.            pop dx cx bx ax
  36.            mov ax,chr
  37.            push ax
  38.            mov ax,xx
  39.            add ax,1
  40.            push ax
  41.            mov ax,yy
  42.            sub ax,1
  43.            push ax
  44.            mov ax,fc
  45.            push ax
  46.            call tgprintc
  47.            endm
  48.  
  49. ; macro to out a 16 bit value to an i/o port
  50.  
  51. out_16     macro register, value
  52.            ifdifi <register>, <dx> ; if dx not setup
  53.            mov dx, register        ; then select register
  54.            endif
  55.            ifdifi <value>, <ax>    ; if ax not setup
  56.            mov ax, value           ; then get data value
  57.            endif
  58.            out dx, ax              ; set i/o register(s)
  59. endm
  60.  
  61. ; macro to out a 8 bit value to an i/o port
  62.  
  63. out_8      macro register, value
  64.            ifdifi <register>, <dx> ; if dx not setup
  65.            mov dx, register        ; then select register
  66.            endif
  67.            ifdifi <value>, <al>    ; if al not setup
  68.            mov al, value           ; then get data value
  69.            endif
  70.            out dx, al              ; set i/o register
  71. endm
  72.  
  73. ; macros to push and pop multiple registers
  74.  
  75. pushx      macro r1, r2, r3, r4, r5, r6, r7, r8
  76.            ifnb <r1>
  77.            push r1                 ; save r1
  78.            pushx r2, r3, r4, r5, r6, r7, r8
  79.            endif
  80. endm
  81.  
  82. popx       macro r1, r2, r3, r4, r5, r6, r7, r8
  83.            ifnb <r1>
  84.            pop r1                  ; restore r1
  85.            popx r2, r3, r4, r5, r6, r7, r8
  86.            endif
  87. endm
  88.  
  89. ; macro to clear registers to 0
  90.  
  91. clr        macro register, r2, r3, r4, r5, r6
  92.            ifnb <register>
  93.            xor register, register  ; set register = 0
  94.            clr r2, r3, r4, r5, r6
  95.            endif
  96. endm
  97.  
  98. ; macros to decrement counter & jump on condition
  99.  
  100. loopx      macro register, destination
  101.            dec register            ; counter--
  102.            jnz destination         ; jump if not 0
  103. endm
  104.  
  105. loopjz     macro register, destination
  106.            dec register            ; counter--
  107.            jz destination          ; jump if 0
  108. endm
  109.