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 >
Wrap
Assembly Source File
|
1986-10-09
|
6KB
|
193 lines
PAGE +
SUBTTL MACROs
;
;
; MSDOS functions macros
;
SVC macro
int 21h
endm
;
ax2hex macro ;display ax as hex number
LOCAL mor_dig
mov cx,0404h ;4 char to print in cl
;rotate count in ch
mov bx,ax ;bx tem loc'n
mor_dig: rol bx,cl ;left dig to right
mov al,bl ;mov to al
and al,0fh ;right dig only
add al,90h ;sneaky conv
daa ; to ASCII hex
adc al,40h
daa
dis_chr al
dec ch ;count -1
jnz mor_dig
endm
;
open_handle macro access_code,name
lds dx, name
mov al, access_code
mov ah, 3dh
SVC
endm
;
close_handle macro handle
mov bx, handle
mov ah, 3eh
SVC
endm
;
read_handle macro handle,no_of_bytes,buf
lds dx,buf
mov bx, handle
mov cx, no_of_bytes
mov ah, 3fh
SVC
endm
;
dis_chr macro char
mov dl,&char
mov ah,02h
SVC
endm
;
dis_str_com macro string ;remember "quotes" around string
LOCAL a,b
jmp short b
a db &string&,'$'
b: dis_str a
endm
;
dis_str_exe macro strseg,string
LOCAL a
&strseg segment
a db &string&,'$'
&strseg ends
dis_str a
endm
;
dis_str macro string
mov dx, offset string
mov ah, 09h
SVC
endm
;
disk_reset macro
mov ah, 0dh
SVC
endm
;
current_disk macro
mov ah, 19h
SVC
endm
;
GetSwitchChar macro
mov ah, 37h
mov al, 0
SVC
endm
;
GetDevAvail macro
mov ah, 37h
mov al, 2
SVC
endm
;
version macro
LOCAL continue_1,address_1
mov ah,30h
SVC
address_1: cmp al,2
jle continue_1
mov dx, offset address_1
push dx
jmp error
continue_1:
endm
;
skip_chain macro key,dest
LOCAL cont
cmp al,"&key&" ;is it a __?
jne cont ;no
jmp &dest ;yes
cont:
endm
;
SetDevAvail macro
mov ah, 37h
mov al, 3
SVC
endm
;
get_time macro
mov ah,2ch
SVC
endm
;
convert macro value,base,destination
local table,begin_convert
jmp begin_convert
table db "0123456789ABCDEF"
begin_convert: mov al,value
xor ah,ah
xor bx,bx
div base
mov bl,al
mov al,cs:table[bx]
mov destination,al
mov bl,ah
mov al,cs:table[bx]
mov destination[1],al
endm
;
conv_dec_word macro value,qty,dest
local divsor,begin,cont,cont1,not_0,done
jmp begin
divsor dw 10000,1000,100,10,1
begin:
mov ax,value ;load
xor si,si ;clr pointer
xor bx,bx ;clr pointer
mov cx,5 ;qty of digits to conv
cont:
xor dx,dx ;clr remainder
push ax ;save
div cs:divsor[bx+si] ;divide by factor of 10
add ax,"0" ;convert to ascii
cmp cx,qty ;store?
jnbe cont1 ;no don't store
mov dest[bx],al ;store character
cont1:
inc bx ;bump pointer
inc si ;bump pointer
cmp ax,"0"
jnz not_0
pop ax ;restore number
loop cont
jmp done
not_0:
pop ax ;clean stack
mov ax,dx ;set up next digit
loop cont
done:
endm
;
all_done macro
mov ah,4ch
SVC
endm
;
;
check_kbd_status macro
mov ah,0bH
SVC
endm
;
read_key macro
mov ah,08h
SVC
ENDM
;