	NAME	TIME
	ENTRY	TIME

STR_MSB	EQU	09H
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
SECS01	EQU	00H
SECS10	EQU	01H
MINS01	EQU	02H
MINS10	EQU	03H
HRS01	EQU	04H
HRS10	EQU	05H
AM_PM	EQU	05H

TIME:
	ENTR	D,2,0
	MOV	B,STR_MSB(IX)	FIRST POINT BC TO
	MOV	C,STR_MSB-1(IX)	TOP OF TIMESTRING,THEN
	DCX	B		POINT TO 1ST CHAR IN STRING.
	MVI	A,HOLD		STOP THE CLOCK!
	OUT	CLKCMD
	MVI	A,HRS10		HOURS (TENS) DIGIT READ COMMAND
*				INTO A.
	CALL	GETDIGIT	GET DIGIT FROM CLOCK & PASS
*				TO PASCAL/Z LAND.
	DCX	B
	MVI	A,HRS01		SAME FOR HOURS (ONES) DIGIT
	CALL	GETDIGIT
	DCX	B
	DCX	B
	MVI	A,MINS10	ETC.
	CALL	GETDIGIT
	DCX	B
	MVI	A,MINS01
	CALL	GETDIGIT
	DCX	B
	DCX	B
	MVI	A,SECS10
	CALL	GETDIGIT
	DCX	B
	MVI	A,SECS01
	CALL	GETDIGIT
	MVI	A,NO_OP		RESTART THE CLOCK!
	OUT	CLKCMD
	EXIT	D,2


* GETDIGIT READS A DIGIT FROM THE CLOCK AND STORES IT IN THE
* APPROPRIATE CHARACTER OF THE PASCAL/Z TIMESTRING.
*	:THE LEAPYEAR AND 24hr MODE BITS ARE MASKED.
*	: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
	CPI	RDFREE+HRS10	WAS IT HRS10 ?
*				i.e.WILL IT CONTAIN 24hr BIT?
	IN	CLKDTA		GET DIGIT
	JNZ	NOT_HRS10
	SUI	8		IF IT WAS HRS10 THEN KILL 24hr BIT
NOT_HRS10:
	ADI	30H		CONVERT TO ASCII &
	STAX	B		PLACE IN STRING.
	RET

