home *** CD-ROM | disk | FTP | other *** search
- ;
- ; Convert bin (ax) to ascii (bx => buffer)
- ;
- bin_ascii proc near
- pusha
- push ax
- mov cx,6
- fill_buff: mov byte ptr [bx],' '
- inc bx
- loop fill_buff
- mov si,10
- or ax,ax
- jns clr_dvd
- neg ax
- clr_dvd: sub dx,dx
- div si
- add dx,'0'
- dec bx
- mov [bx],dl
- inc cx
- or ax,ax
- jnz clr_dvd
- pop ax
- or ax,ax
- jns no_more
- dec bx
- mov byte ptr [bx],'-'
- no_more: popa
- ret
- bin_ascii endp
-
- ;
- ; Convert Hex (dx) to Ascii (bx => buffer)
- ;
- hex2asc4 proc near
- push cx
- push ax
- mov cx,4 ;Do Four Digits
- h241: rol dx,1
- rol dx,1
- rol dx,1
- rol dx,1
- mov al,dl ;Get the Current Digit
- and al,0Fh
- cmp al,0Ah ;Is It Hex?
- jge h242
- add al,30h ;Normal Digit
- jmp h243
- h242: add al,37h ;Hex Digit
- h243: mov [bx],al ;Insert in Buffer
- inc bx
- loop h241
- pop ax
- pop cx
- ret
- hex2asc4 endp
-
- ;
- ; Convert Hex (dl) to Ascii (bx => buffer)
- ;
- hex2asc2 proc near
- push cx
- push ax
- mov cx,2 ;Do Two Digits
- h221: rol dl,1
- rol dl,1
- rol dl,1
- rol dl,1
- mov al,dl ;Get the Current Digit
- and al,0Fh
- cmp al,0Ah ;Is It Hex?
- jge h222
- add al,30h ;Normal Digit
- jmp h223
- h222: add al,37h ;Hex Digit
- h223: mov [bx],al ;Insert in Buffer
- inc bx
- loop h221
- pop ax
- pop cx
- ret
- hex2asc2 endp
-
- ;
- ; Print a string
- ;
- ; ds:dx => string
- ;
- puts proc near
- pusha
- mov ah,9 ;DOS print string
- int 21h
- popa
- ret
- puts endp
-