	NAME	DATE
	ENTRY	DATE

VBYTES	EQU	05	# OF BYTES ON THE STACK
STR_MSB	EQU	12
DAY_MSB EQU	10
CLKBAS	EQU	50H        = CLOCK PORT BASE ADDRESS
CLKCMD	EQU	CLKBAS+10  =   "   COMMAND PORT ADDRESS
CLKDTA	EQU	CLKBAS+11  =   "   DATA     "      "
NO_OP	EQU	00H
RDFREE	EQU	10H
HOLD	EQU	40H
DAYS01	EQU	07H
DAYS10	EQU	08H
MTHS01	EQU	09H
MTHS10	EQU	0AH
YRS01	EQU	0BH
YRS10	EQU	0CH
LEAPYR	EQU	08H
WKDAY	EQU	06H

DATE:
	ENTR	D,2,0
	MOV	B,STR_MSB(IX)	FIRST POINT BC TO
	MOV	C,STR_MSB-1(IX)	TOP OF DATESTRING,THEN
	DCX	B		POINT TO 1ST CHAR IN STRING.
	MVI	A,HOLD		STOP THE CLOCK!
	OUT	CLKCMD
	MVI	A,MTHS10	MONTHS-(TENS)-DIGIT-READ COMMAND
*				INTO A.
	CALL	GETDIGIT	GET DIGIT FROM CLOCK & PASS
*				TO PASCAL/Z LAND.
	DCX	B
	MVI	A,MTHS01	SAME FOR MONTHS (ONES) DIGIT
	CALL	GETDIGIT
	DCX	B		SKIP '/'
	DCX	B
	MVI	A,DAYS10	ETC.
	CALL	GETDIGIT
	DCX	B
	MVI	A,DAYS01
	CALL	GETDIGIT
	DCX	B		SKIP '/',
	DCX	B		| & SKIP
	DCX	B		| CENTURY DIGITS.
	DCX	B
	MVI	A,YRS10
	CALL	GETDIGIT
	DCX	B
	MVI	A,YRS01
	CALL	GETDIGIT
	MOV	B,DAY_MSB(IX)	NOW TO GET THE
	MOV	C,DAY_MSB-1(IX) DAY OF THE WEEK!
	MVI	A,0
	STAX	B		MSB = 0
	DCX	B
	MVI	A,WKDAY
	ADI	RDFREE
	OUT	CLKCMD
	IN	CLKDTA		GET LSB
	STAX	B
	MVI	A,NO_OP		RESTART THE CLOCK!
	OUT	CLKCMD
	EXIT	D,VBYTES


* GETDIGIT READS A DIGIT FROM THE CLOCK AND STORES IT IN THE
* APPROPRIATE CHARACTER OF THE PASCAL/Z DATESTRING.
*	:ON CALL THE DIGIT COMMAND MUST BE IN A &
*	:AND THE ADDRESS OF THE CHAR IN BC		
GETDIGIT:
	ADI	RDFREE		ADD 'READ' TO COMMAND.
	OUT	CLKCMD
	IN	CLKDTA		GET DIGIT
	ADI	30H		CONVERT TO ASCII &
	STAX	B		PLACE IN STRING.
	RET

