TITLE M0NTH (EXE)
;Convert the numeric month to alphabetic abbreviation
DATASG	SEGMENT PARA 'DATA'
 THREE	 DB  3
 MONIN	 DB  3,4 DUP(?)
 ALFMON	 DB  '???','$'
 MONTAB	 DB  'JAN','FEB','MAR','APR','MAY','JUN'
	 DB  'JUL','AUG','SEP','OCT','NOV','DEC'
DATASG	ENDS
;
CODESG	SEGMENT PARA 'CODE'
	ASSUME  CS:CODESG, DS:DATASG, ES:DATASG
;----------------------------------------------------
MAIN	PROC	FAR
	PUSH	DS	     ;set up for return
	SUB	AX,AX
	PUSH	AX
	MOV	AX,DATASG    ;point to data seg.
	MOV	DS,AX
	MOV	ES,AX
	CALL	INPUT	     ;input and convert
	CALL	LOCATE	     ;locate month
	CALL	DISPLAY	     ;display alpha month
	RET
MAIN	ENDP
;-----------------------------------------------------
;Input and convert ASCII to binary:
INPUT	PROC	NEAR
	PUSH	DX
	MOV	AH,0AH	     ;input	from keyboard
	LEA	DX,MONIN     ;address of buffer
	INT	21H
	MOV	AH,MONIN+2   ;fetch numeric month
	MOV	AL,MONIN+3
	XOR	AX,3030H     ;clear ASCII 3's
	CMP	AH,00	     ;month 01-09 ?
	JZ	RETURN	     ;yes,bypass
	SUB	AH,AH	     ;no,clear AH
	ADD	AL,10	     ;correct for binary
RETURN:	POP	DX
	RET
INPUT	ENDP
;----------------------------------------------------
; Locate month in table
LOCATE	PROC	NEAR
	PUSH	SI	     ;save the registers
	PUSH	DI
	PUSH	CX
	LEA	SI,MONTAB
	DEC	AL	     ;correct for table
	MUL	THREE	     ;3 chars for each month
	ADD	SI,AX
	MOV	CX,03	     ;init'ze 3 chars move
	CLD
	LEA	DI,ALFMON
	REP	MOVSB	     ;mov 3 chars
	POP	CX	     ;restore registers
	POP	DI
	POP	SI
	RET
LOCATE	ENDP
;----------------------------------------------------
;Display alpha month
DISPLAY	PROC	NEAR
	PUSH	DX
	LEA	DX,ALFMON    ;address of output buffer
	MOV	AH,09	     ;display function
	INT	21H	     ;DOS call
	POP	DX
	RET
DISPLAY	ENDP
;----------------------------------------------------
CODESG	ENDS
	END	MAIN
