


;BINIHEX&--Binary to hexadecimal converter
;Converts internal binary to hex on screen
;For use with BASIC programs

display	equ	2h		;video output function
doscall	equ	21h		;DOS interrupt number
;**********************************************************
binihex segment			;defint code segment
;----------------------------------------------------------
main	proc	far		;main part of program

	assume cs:binihex

;check that argment is really integer
	cmp	al,2		; 2 is code for integer
	jne	exit		;wrong argument
;get integer from Floating Point Accumulator
	mov	ax,[bx]		;integer into AX
	mov	bx,ax		;  into BX for binihex
;print out binary number in BX on screen
	mov	ch,4		;number of digits
rotate:	mov	cl,4		;set count to 4 bits
	rol	bx,cl		;left digit to right
	mov	al,bl		;move to AL
	and	al,0fh		;mask off left digit
	add	al,30h		;convert hex to ASCII
	cmp	al,3ah		;is it>9?
	jl	printit		;no,so 0 to 9 digit
	add	al,7h		;yes,so A to F digit
printit:
	mov	dl,al		;put ASCII char in DL
	mov	ah,display	;display output funct
	int	doscall		;call DOS
	dec	ch		;done 4 digits?
	jnz	rotate		;not yet
exit:   
	ret			;return to DOS

main	endp			;end of main part of program
;----------------------------------------------------------
binihex ends			;end of code segment
;**********************************************************

	end	main		;end assembly

;			(2)
