time setting

ZXNet echo conference «code.zx»

From Aleksandr Majorov To All 5 July 1997

Hayushki, All! Here is a program that displays/outputs time from CMOS clock. I’ll say right away: the program was written for myself and for testing, that's why it's a little "clumsy" ╔══════════════ let’s start from here ══════════╗ ORG 25000 ;if you don’t have to set the clock, then don’t ;call!!!! CALL SETTING LD A,2 ;remember BASIC CALL #1601 LOOP WAIT LD C,11;waiting for the chip CALL IN_C ;will be ready RLCA JR C,WAIT LD A.22 ;AT 0.0 RST 16 XOR A RST 16 XOR A RST 16 LD C,7 ;output CALL PRINT ;day LD A,"-" RST 16 LD C,8 ;\n CALL PRINT ;-- month LD A,"-" RST 16 LD C,9 ;\n CALL PRINT ;--- year LD A," " RST 16 LD C,6 ;\n CALL PRINT ;--- day of week LD A,13 RST 16 LD C,4 CALL PRINT ;clock LD A,":" RST 16 LD C,2 CALL PRINT ;min. LD A,":" RST 16 LD C,0 CALL PRINT ;sec. LD A,#7F ;by space exit IN A,(#FE) RRCA JR C,LOOP RET ;read the number from port number [C] and ;output it ;by the way: numbers in binary ten. form) PRINT CALL IN_C PUSH AF RRCA RRCA RRCA RRCA AND 15ADD A,"0" RST 16 POP AF AND 15 ADD A,"0" RST 16 RET SET_REG LD A,C LD BC,#FFF9 JR OUT_D OUT_C PUSH AF CALL SET_REG POP AF LD BC,#FF79 OUT_D LD HL,#2A53 PUSH HL JP #3D2F IN_C CALL SET_REG LD BC,#FF79 ;READING FROM TR-DOS PORT ;!!! IF YOU DO NOT HAVE A SCORP, THEN INSTEAD ;GIVEN P/P USE THE ONE THAT IS GIVEN ;In ZN'35!!! ;this is also true for EVERYONE else ;programs!!!!!!!!!!!! IN_D LD HL,#3FF3 PUSH HL JP #3D2F ;here we set the time and date, so: ;time 03:06:50 ;date 05-07-97 day of week 7 (Saturday) SEK DB #50 MIN DB #06 HOU DB #03 NED DB #07 DAY DB #05 MOU DB #07 YEAR DB #97 SETTIM ;set registers for work, ;for more details see ZN'35 LD C,10 LD A,%00100000 CALL OUT_C LD C,11 LD A,#82 CALL OUT_C LD C,13 CALL IN_C LD C,12 CALL IN_C ;set the time LD IX,SEK LD C,0 LD A,(IX+0) CALL OUT_C LD C,2 LD A,(IX+1) CALL OUT_C LD C,4 LD A,(IX+2) CALL OUT_C LD C,6 LD A,(IX+3) CALL OUT_C LD C,7 LD A,(IX+4) CALL OUT_C LD C,8 LD A,(IX+5) CALL OUT_C LD C,9 LD A,(IX+6)CALL OUT_C ;start the clock LD C,#0B LD A,#02 JP OUT_C ╚═════════════ enough for today ═════════╝ Well, that's all... Best regards, Aleksandr (*MAS*)