;SEARCH--G6_15
;**********************************************************
datarea segment			;define data segment
thirty	db	30		;value for mul instruction
;message table
msg0	db	'I like my IBM-PC--------------'	
msg1	db	'8088 programming is fun-------'
msg2	db	'Time to buy more diskettes----'
msg3	db	'This program works------------'
msg4	db	'Turn off that printer---------'
msg5	db	'I have more memory than you---'
msg6	db	'The PSP can be useful---------'
msg7	db	'BASIC was easier than this----'
msg8	db	'DOS is indispensable----------'
msg9	db	'Last massage of the day-------'
;error message
errmsg	db 	'error!!!  invalid parameter!! '
datarea ends
;**********************************************************
stack	segment
	db	256 dup(0)	;256 bytes of stack space
  tos	label	word
stack	ends
;**********************************************************
prognam segment			;defint code segment
;----------------------------------------------------------
main	proc	far		;main part of program

	assume cs:prognam,ds:datarea,ss:stack

start:				;starting execution address

;set SS register to current stack segment
	mov	ax,stack
	mov	ss,ax
	mov	sp,offset tos

;set up stack for return
	push	ds		;save old data segment
	sub	ax,ax		;put zero in AX	
	push	ax		;save it on stack

;set DS register to current data segment
	mov	ax,datarea	;datarea segment addr
	mov	ds,ax	  	;  into DS register

;MAIN PART OF PROGRAM GOES HERE

begin:	mov 	ah,1		;move a parameter from keybd
	int	21h		
	sub	al,'0'		;convert from ASCII to binary
	jc	error		;branch if not numeric( <'0')
	cmp	al,9		;check for valid numeric
	ja	error		;branch if not valid( >'9')

;select appropriate message from message table
	mov	bx,offset msg0	;point to first message
	mul	thirty		;(AX)=(AL)*30
	add	bx,ax		;point to desired message
	call	display		;display the message at [BX]
	jmp	begin
;display error message for invalid parameter
error:	mov	bx,offset errmsg
	call	display		;display error message
	ret			;return to DOS
;------------------------------------------------------------
;Subroutine to display a message on the screen
;Enter with BX-->message to be displayed
;Message is assumed to be 30 characters long

display proc 	near
	mov	cx,30		;number of char. to display
disp1:	mov	dl,[bx]		;get next char. to display
	call	dispchar	;display it
	inc	bx		;point to next char.
	loop	disp1		;do it 30 times
	mov	dl,0dh		;carriage return
	call	dispchar
	mov	dl,0ah		;linefeed
	call	dispchar
	ret			;return to caller of 
				;  'display'
display	endp
;-----------------------------------------------------------
;Subroutine to display a character on the screen
;Enter with (DL)= character to be displayed

dispchar proc	near
	mov	ah,2		;display out a character
	int	21h
	ret			;return to caller of
				;  'dispchar'
dispchar	endp
;----------------------------------------------------------
main	endp			;end of main part of program
;----------------------------------------------------------
prognam ends			;end of code segment
;**********************************************************

	end	start		;end assembly
