;	This is a demonstration program that surveys people who might
;	come to an exibition or a conference.
;	It is only a demonstration program for the iomacros and serves
;	no bigger purpose.

;	Written by Jim Wolfe		for COSC 300

		.model		small
		.386
		.stack		100h
	if1
	include		iomacros.inc		; Get the file with the macros
	endif
		.data
age		db			?			; Respondent's age
sex		db			?			; Respondent's sex (M or F)
pname	db			21 dup(?)	; Respondent's first name
sname	db			21 dup(?)	; Respondent's last name
miles	dw			?			; Number of miles respondent traveled
profit	dd			?			; Profit of respondent's company
		
		; Following are the survey prompts

p1		db			13,10,"What is your age? ", 0
p2		db			13,10,"What is your sex (M/F)? ", 0
p3		db			13,10,"What is your first name? ", 0
p31		db			13,10,"What is your last name? ",0
p4		db			13,10,"How many miles did you travel to get here? ", 0
p5		db			13,10,"What is your company net profit? ",0

last	db			" company.",13,10,0		; Ending string for display
		.code
		extern		writelong:proc, writestring:proc, writeint:proc
		extern		readlong:proc, readstring:proc, readint:proc 
		extern		writeint_signed:proc, waitchar:proc, readkey:proc
		extern		crlf:proc
main	proc
		mov			ax, @data
		mov			ds, ax
		mov			dx, 5			; Set loop limit
top:
		cout		s, p1			; Ask for age and read it
		nin			age
		cmp			age, 0			; If age is negative, terminate
		jle			finish
		cout		s, p2			; Ask for person's sex and read it
		cin			c, sex
		and			sex, 0DFh		; Force uppercase
again:
		cout		s, p3			; Ask for first name and read it
		cin			s, pname, 20
		cmp			pname, 0		; Try again, if accidental Enter
		je			again
		cout		s, p31			; Ask for last name and read it
		cin			s, sname, 20
		cout		s, p4			; Ask how far traveled and read it
		nin			miles
		cout		s, p5			; Ask for profit and read it
		nin			profit
		call		crlf			; Make blank lines
		call		crlf
results:
		cout		s, sname		; Display all info in sentence form
		cout		l, <!, >		; as:  LASTNAME, FIRSTNAME (SEX) is AGE
		cout		s, pname		;          traveled MILES miles, and is 
		cout		l, < !(>		;		    with a $PROFIT company.
		cout		c, sex
		cout		l, <!)  is >
		nout		age
		call		crlf
		cout		l, <     traveled >
		nout		miles
		cout		l, < miles!, and is with a $>
		nout		profit
		cout		s, last
		dec			dx
		je			finish			; Stop if counted down to 0
		jmp			top
finish:
		mov			ax, 4c00h
		int			21h
main	endp

end		main

