home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB139 / option.lzh / MACROS.ASM < prev    next >
Assembly Source File  |  1986-10-09  |  6KB  |  193 lines

  1.         PAGE    +
  2.         SUBTTL  MACROs
  3. ;
  4. ;
  5. ; MSDOS functions macros
  6. ;
  7. SVC             macro
  8.                 int     21h
  9.                 endm
  10. ;
  11. ax2hex          macro                   ;display ax as hex number
  12.                 LOCAL   mor_dig
  13.                 mov     cx,0404h        ;4 char to print in cl
  14.                                         ;rotate count in ch
  15.                 mov     bx,ax           ;bx tem loc'n
  16. mor_dig:        rol     bx,cl           ;left dig to right
  17.                 mov     al,bl           ;mov to al
  18.                 and     al,0fh          ;right dig only
  19.                 add     al,90h          ;sneaky conv
  20.                 daa                     ; to ASCII hex
  21.                 adc     al,40h
  22.                 daa
  23.                 dis_chr al
  24.                 dec     ch              ;count -1
  25.                 jnz     mor_dig
  26.                 endm
  27. ;
  28. open_handle     macro   access_code,name
  29.                 lds     dx, name
  30.                 mov     al, access_code 
  31.                 mov     ah, 3dh
  32.                 SVC
  33.                 endm
  34. ;
  35. close_handle    macro   handle
  36.                 mov     bx, handle
  37.                 mov     ah, 3eh
  38.                 SVC
  39.                 endm
  40. ;
  41. read_handle     macro   handle,no_of_bytes,buf
  42.                 lds     dx,buf
  43.                 mov     bx, handle
  44.                 mov     cx, no_of_bytes
  45.                 mov     ah, 3fh
  46.                 SVC
  47.                 endm
  48. ;
  49. dis_chr         macro   char
  50.                 mov     dl,&char
  51.                 mov     ah,02h
  52.                 SVC
  53.                 endm
  54. ;
  55. dis_str_com     macro   string          ;remember "quotes" around string
  56.                 LOCAL   a,b
  57.                 jmp     short b
  58. a               db      &string&,'$'
  59. b:                dis_str a
  60.                 endm
  61. ;
  62. dis_str_exe     macro   strseg,string
  63.                 LOCAL   a
  64. &strseg         segment
  65. a               db      &string&,'$'
  66. &strseg         ends
  67.                 dis_str a
  68.                 endm
  69. ;
  70. dis_str         macro   string
  71.                 mov     dx, offset string
  72.                 mov     ah, 09h
  73.                 SVC
  74.                 endm
  75. ;
  76. disk_reset      macro
  77.                 mov     ah, 0dh
  78.                 SVC
  79.                 endm
  80. ;
  81. current_disk    macro
  82.                 mov     ah, 19h
  83.                 SVC
  84.                 endm
  85. ;
  86. GetSwitchChar   macro
  87.                 mov     ah, 37h
  88.                 mov     al, 0
  89.                 SVC
  90.                 endm
  91. ;
  92. GetDevAvail     macro
  93.                 mov     ah, 37h
  94.                 mov     al, 2
  95.                 SVC
  96.                 endm
  97. ;
  98. version         macro
  99.                 LOCAL   continue_1,address_1
  100.                 mov     ah,30h
  101.                 SVC
  102. address_1:      cmp     al,2
  103.                 jle     continue_1
  104.                 mov     dx, offset address_1
  105.                 push    dx
  106.                 jmp     error
  107. continue_1:     
  108.                 endm
  109. ;
  110. skip_chain      macro   key,dest
  111.                 LOCAL   cont
  112.                 cmp     al,"&key&"      ;is it a __?
  113.                 jne     cont            ;no
  114.                 jmp     &dest           ;yes
  115. cont:
  116.                 endm
  117. ;
  118. SetDevAvail     macro
  119.                 mov     ah, 37h
  120.                 mov     al, 3
  121.                 SVC
  122.                 endm
  123. ;
  124. get_time        macro
  125.                 mov     ah,2ch
  126.                 SVC
  127.                 endm
  128. ;
  129. convert         macro   value,base,destination
  130.                 local   table,begin_convert
  131.                 jmp     begin_convert
  132. table   db      "0123456789ABCDEF"
  133. begin_convert:  mov     al,value
  134.                 xor     ah,ah
  135.                 xor     bx,bx
  136.                 div     base
  137.                 mov     bl,al
  138.                 mov     al,cs:table[bx]
  139.                 mov     destination,al
  140.                 mov     bl,ah
  141.                 mov     al,cs:table[bx]
  142.                 mov     destination[1],al
  143.                 endm
  144. ;
  145. conv_dec_word   macro   value,qty,dest
  146.                 local   divsor,begin,cont,cont1,not_0,done
  147.                 jmp     begin
  148. divsor  dw      10000,1000,100,10,1
  149. begin:
  150.                 mov     ax,value                ;load
  151.                 xor     si,si                   ;clr pointer
  152.                 xor     bx,bx                   ;clr pointer
  153.                 mov     cx,5                    ;qty of digits to conv
  154. cont:
  155.                 xor     dx,dx                   ;clr remainder
  156.                 push    ax                      ;save
  157.                 div     cs:divsor[bx+si]        ;divide by factor of 10
  158.                 add     ax,"0"                  ;convert to ascii
  159.                 cmp     cx,qty                  ;store?
  160.                 jnbe    cont1                   ;no don't store
  161.                 mov     dest[bx],al             ;store character
  162. cont1:
  163.                 inc     bx                      ;bump pointer
  164.                 inc     si                      ;bump pointer
  165.                 cmp     ax,"0"
  166.                 jnz     not_0
  167.                 pop     ax                      ;restore number
  168.                 loop    cont
  169.                 jmp     done
  170. not_0:
  171.                 pop     ax                      ;clean stack
  172.                 mov     ax,dx                   ;set up next digit
  173.                 loop    cont
  174. done:
  175.                 endm
  176. ;
  177. all_done        macro
  178.                 mov     ah,4ch
  179.                 SVC
  180.                 endm
  181. ;
  182. ;
  183. check_kbd_status macro
  184.                 mov     ah,0bH
  185.                 SVC
  186.                 endm
  187. ;
  188. read_key        macro
  189.                 mov     ah,08h
  190.                 SVC
  191.                 ENDM
  192. ;
  193.