	; CALLVERS program

bdos	equ	5			; entry point for BDOS
prtstr	equ	9			; print string function
vers	equ	12			; get version function
cr	equ	0dh			; carriage return
lf	equ	0ah			; line feed

	org	100h

	mvi 	c,vers 
	call 	bdos			; try to get version #
					; CALLVERS will intercept
	mov 	a,l 
	lxi	h,curvers
	call	binhex

;	mvi 	d,5			; Perform 5 times
;loop:	push	d			; save counter
	mvi 	c,prtstr 
	lxi 	d,call$msg		; print call message
	call 	bdos
;	pop 	d
;	dcr 	d			; decrement counter
;	jnz 	loop
	mvi 	c,0
	jmp 	bdos

binhex:	push	psw
	rrc ! rrc ! rrc ! rrc
	call	binhex1
	pop	psw
binhex1:
	ani	0fh
	adi	30h
	cpi	3ah
	jc	binhex2
	adi	7
binhex2:
	mov m,a ! inx h ! inx h
	ret

call$msg:
	db	cr,lf,'**** CP/M-VERSION  '
curvers	db	'0.0'
	db	'  ****$',cr,lf

	end
