;
;  PROGRAM:  SYSTEST3
;  AUTHOR:  Richard Conn
;  PURPOSE:  This program demonstrates the EVAL routines and the Math routines
;		within SYSLIB
;

;
;  Externals
;
	EXT	ADDHD	; HL = HL + DE
	EXT	SUBHD	; HL = HL - DE
	EXT	NEGH	; HL = NEGATE OF HL
	EXT	MULHD	; HL = HL * DE
	EXT	DIVHD	; HL = HL / DE
	EXT	ANDHD	; HL = HL AND DE
	EXT	ORHD	; HL = HL OR DE
	EXT	XORHD	; HL = HL XOR DE
	EXT	SHFTRH	; HL = HL shifted right one bit position
	EXT	SHFTLH	; HL = HL shifted left one bit position
	EXT	ROTRH	; HL = HL rotated right one bit position
	EXT	ROTLH	; HL = HL rotated left one bit position

	EXT	PRINT	; Print String
	EXT	BBLINE	; Input Line Editor
	EXT	EVAL	; Number Evaluator
	EXT	PHLDC	; Print HL as up to 5 decimal chars
	EXT	PHL4HC	; Print HL as 4 Hex chars

;
;  ASCII Char defns
;
cr	equ	0dh
lf	equ	0ah

;
;  Print Banner
;
	call	print
	db	'SYSTEST3 -- Math Routines and Evaluation Demo',0

;
;  This is the main loop and a prompt to the user.
;
loop:
	call	print
	db	cr,lf,'Input Two Numbers, Separated by a Comma (<CR> to Stop)'
	db	' -- ',0
	call	bbline	; get user input
	ora	a	; no input if A=0
	rz		; return to Operating System
	call	eval	; evaluate the first number (which is pted to by HL)
	xchg		; place number in HL
	shld	num1	; save it away as 1st number
	xchg		; restore pointer to comma after number in HL
	inx	h	; skip comma
	call	eval	; evaluate the 2nd number (returned in DE)

;
;  Through the rest of this loop, DE contains the 2nd number.  Note that none
;  of the routines affect it.
;
	call	print
	db	cr,lf,'First Number is ',0
	lhld	num1	; get and print first number
	call	phldc	; print in decimal
	call	print
	db	' in Decimal or ',0
	call	phl4hc	; print in hex
	call	print
	db	' in Hex',cr,lf,0
	call	print
	db	'The Second Number is ',0
	xchg		; get 2nd number into HL
	call	phldc	; print in decimal
	call	print
	db	' in Decimal or ',0
	call	phl4hc	; print in hex
	call	print
	db	' in Hex',cr,lf,0
	xchg		; save 2nd number in DE for rest of loop
	call	print
	db	cr,lf,'Sum = ',0
	lhld	num1	; get first number again
	call	addhd	; HL = HL + DE
	call	phldc	; print sum
	call	print
	db	'  Difference = ',0
	lhld	num1	; get first number (since destroyed by ADDHD)
	call	subhd	; ... and so on ...
	call	phldc	; print difference
	call	print
	db	'  Product = ',0
	lhld	num1
	call	mulhd
	call	phldc	; print product
	call	print
	db	'  Quotient = ',0
	lhld	num1
	call	divhd
	call	phldc	; print quotient
	call	print
	db	cr,lf,'  Negative of First Argument = ',0
	lhld	num1
	call	negh
	call	phldc	; print negative
	call	print
	db	cr,lf,'AND = ',0
	lhld	num1	; get first number
	call	andhd
	call	phl4hc
	call	print
	db	'  OR = ',0
	lhld	num1
	call	orhd
	call	phl4hc
	call	print
	db	'  XOR = ',0
	lhld	num1
	call	xorhd
	call	phl4hc
	call	print
	db	cr,lf,'First Argument:  SHIFT L = ',0
	lhld	num1
	call	shftlh
	call	phl4hc
	call	print
	db	'  SHIFT R = ',0
	lhld	num1
	call	shftrh
	call	phl4hc
	call	print
	db	'  ROT L = ',0
	lhld	num1
	call	rotlh
	call	phl4hc
	call	print
	db	'  ROT R = ',0
	lhld	num1
	call	rotrh
	call	phl4hc
	jmp	loop

num1:	ds	2	; first number

	db	0

	end
