; WHEN.ASM ; ; This program READS (to the console) the BCD date/time MAINTAINED in basepage ; RAM (at 0010H - 0014H) by CLOCK.COM, q.v., or the compatible BCD ; date/time which is merely STORED at the same locations by DATTIM.COM. ; ; This code is somewhat machine specific: You need a Z80 (non-8080 instructions ; are present) in a system which does NOT implement RST 2 (INTERRUPT 2 -- whose ; vector normally occupies addresses 10H thru 17H). Those requirements are ; satisfied by many if not most Z80 computers, but this code was written for ; and has been tested only on an Osborne 1, with a 1.44 ROM. ; ; MODIFICATION HISTORY (insert most recent notes at top) ; vers 1.01, 12/29/87 ww - added line feed routines around output to make easier to read ; vers 1.0, 12/28/87 by Walt Wheeler for Yankee Osborne Users, Hartford/New Haven, CT ; BDOS EQU 5H ;BDOS Call & Vector MDY EQU 10H ;Month,Day,Year,Hrs,Min begins at 10H ; ---> specific to CLOCK & DATTIM ; ORG 100H ; BEGIN: JMP START NAME: DB 'WHEN ver 1.02 ' DATE: DB '01/01/88' ; START: MVI A,0DH ; get in CALL CONOUT ; and spit it out (for ease of reading DATE & TIME) MVI A,0AH ; to CALL CONOUT ; and spit out the LXI H,MDY ; point to the 5 BCD bytes (Month DayYrHrMin MVI B,5 ; count of BCD chars to display ; MAIN: CALL BCD2AS ;call BCD to ASCII routine (which calls CONOUT) ; INX H ; point to next BCD byte... DCR B ; ...and decrement after each BCD byte ; has been converted to ASCII and output MOV A,B ; get decremented BCD bytes count ; ...oh, for a CASE function... CPI 4 ; have we output only the MM+"/" ??? JRZ MAIN ; if so, no need to chg separator so loop to MAIN: ORA A ;( 1 byte shorter than but otherwise same as "CPI 0") ; otherwise, maybe we're done? JRZ QUIT ; do the finish-up if count NOT EQUAL 4,3,2 or 1 CPI 1 ; have we output HH+separator, next output is MM? CZ SEPCHG ; if so, change separator (after MM) to a CPI 2 ; have we output YY, next output is HH+Separator CZ SEPCH1 ; if so, change separator (after HH) to a ":" CPI 3 ; have we output the MM/DD with next output to be YY CZ SEPCHG ; if so, change separator (between YY & MM) to JR MAIN ; and regardless, with all possible cases covered, ; loop back to MAIN with all cases covered ; QUIT: MVI A,0DH ; to CALL CONOUT ; spit out MVI A,0AH ; to CALL CONOUT ; and spit ; RET ; and RETurn to CCP -- no warm boot ; BCD2AS: MOV A,M ; get the next BCD byte ANI 0F0H ; mask low nibble (& clears Carry Bit) RAR ; & rotate right, 4 times RAR ; to move the high RAR ; nibble to the RAR ; low nibble_postion ADI 30H ; make printable (ASCII) number in CALL CONOUT ; print the first decimal digit MOV A,M ; get original BCD byte back ANI 0FH ; mask high nibble ADI 30H ; make printable (ASCII) CALL CONOUT ; and print second decimal digit SEP EQU $+1 ; "MVI" below assembles at "$" and the separator_char ; at "$+1" (= SEP ) -- calculation is done ; so SEPCHG & SEPCH1 (q.v.) can modify it. MVI A,'/' ; get a separator char in CALL CONOUT ; and print the separator RET ; to main routine ; CONOUT: MVI C,2 ; BDOS funct for CONSOLE OUTPUT of one byte MOV E,A ; move the ASCII digit to PUSH B PUSH H CALL BDOS POP H POP B RET ;generally, to BCD2AS (also called by START and QUIT) ; SEPCHG: MVI A,' ' ; new val for byte at (SEP+1) --- a "/" to a STA SEP ; and store it there.... RET ; to MAIN ; SEPCH1: MVI A,':' ; new val for byte at (SEP+1) -- a ":" sted a STA SEP RET ; to MAIN ; ENDMKR: DB '<- END WHEN.COM' ; end marker ; END