Title Time stamp VERS:- 00.02 DATE:- 08/01/82 TIME:- 01:35:45 ;************************************************************ ;* ;* File Tracking Program ;* by Eric Forbes ;* c/o Mississauga, Ont. Canada RCP/M System ;* (416) 826-5394 ;* ;************************************************************ ;Copyright (c) 1982, E. Forbes; permission granted to use, ;copy and distribute for non-commercial purposes. ;QUICK VIEW: Increment version and insert date and time each ; time a file is assembled / edited. See top line ;To use the 'DATE:- ' and 'TIME:- ' functions, this program ;expects to find three consecutive bytes at MONTH and HOUR, ;in BCD format. E.G. to print the date 07/31/82, the bytes ;07H 31H 82H should be available at HOUR, HOUR+1 and HOUR+2 ;If you do not have a clock ignore the 'month' and 'hour' ;equates. They are both read only and will only be read if ;'DATE:- ' or 'TIME:- ' is found in the 1st record of the file ;See TIMESTMP.DOC for further deatails false equ 0 true equ not false stdaln equ true ;True means this will stand alone. ;False means the program will be ;patched to the end of an assembler or editor. Then, after ;updating the version, date and time, the assembler or ;editor will act upon the updated file. month equ 0feadh ;month byte in bios hour equ month+3 ;hour byte in bios base equ 0 ;standard CP/M recsiz equ 128 ;record length cr equ 0dh lf equ 0ah bell equ 7 bdos equ base+5 tail equ base+80h ;command line if not stdaln ;if not stand alone endasm equ 4580h ;address to jump to at the end of ;assembler, also org of this program oldjmp equ 3EFDh ;used to restore the jump at the ;start of the assembler jmpadd equ 0103h ;address of the JP (C3h) used to get ;to this program assemb equ 0100h ;address to return to when finished ;updating the file endif ;if not stand alone if stdaln ;if stand alone endasm equ base+100h ;org if stand alone fcb equ base+5ch ;use default fcb endif ;if stand alone .z80 aseg org endasm ;end of assembler ;BC = Count of characters in command line tail. ;DE = File control block. ;Hl = Command line tail. start: ld de,crlf ld c,9 ;new line call bdos if not stdaln ;if not stand alone ;All these contortions are needed to keep the input command ;line exactly as the assembler expects to find it ld hl,tail ;move & format source file ld b,0 ;name to fcb ld c,(hl) ;count of characters inc hl ;HL --> 1st character in tail ld a,'=' ;look for the '=' in front cpir ;of the source file cmder: ld de,cmderr ;no '=' is a command error jp po,error ld de,fcb ;DE --> 1st position of FCB inc hl ;HL --> 2nd char after '=' ld a,':' ;see if 'd:' given cp (hl) ;Z set if found dec hl ;HL --> 1st char after '=' jr nz,start1 ;jump - no drive given ld a,(hl) ;get drive A, B, C, D, etc and 0fh ;convert A to 01 etc ld (de),a ;put in fcb cpi ;inc hl dec bc jp po,cmder ;command line too short cpi ;HL --> past drive & ':' jp po,cmder ;command line too short start1: inc de ;DE --> file name st1a: ld a,(hl) cp ' ' ;transfer file name til ' ' jr z,start2 cp '.' ;ignore '.' if ext given jr z,stext ;don't put '.' in fcb ldi ;ld in fcb inc hl & de dec bc jp po,start3 ;jump if end of tail jr st1a stext: ld de,ext ;DE --> file extention cpi ;inc hl dec bc jp po,start3 ;jump if end of tail jr st1a start2: ld a,' ' ;look for the space cpir ;before option jp po,start3 ;no ' '= no option ld a,(hl) ld (major),a ;save the option ld hl,tail ;dec the char count if dec (hl) ;option used, in case the dec (hl) ;assembler needs it. endif ;if not stand alone if stdaln ;if stand alone ld a,(base+6dh) ;get option ' ' or 'M' ld (major),a ;save it ld bc,3 ld de,fcb+9 ;set up to ld hl,ext ;make default ext 'MAC' ld a,(de) cp ' ' ;jump if ext not ' ' jr nz,start3 ldir ;ext = 'MAC' endif ;if stand alone start3: ld de,fcb ;open input file ld c,15 call bdos ld de,nofile ;report if can't open and inc a ;exit to CP/M jp z,error ld de,buff ld c,26 ;setdma call bdos ld de,fcb ld c,20 ;read record 1 call bdos ld de,verstx call find ;update version ld de,novers call nz,print call z,versn ld de,datetx call find ;update date ld de,nodate call nz,print call z,date ld de,timetx call find ;update time ld de,notime call nz,print call z,time ;write record back into file and exit to assembler or CP/M ;The file is not closed, 'cos that would reduce it to a ;single record. xor a ld (fcb+32),a ;zero the record count ld de,fcb ld c,21 call bdos ld de,donmsg error: call print ;print error message and exit. ;also normal exit if not stdaln ;if not stand alone ;Restore the assembler to original condition and jump to it ld hl,oldjmp ;restore value in hl ld (jmpadd+1),hl ;restore old jump address jp assemb ;jump to the assembler endif ;if not stand alone if stdaln ;if stand alone ret ;back to CP/M endif ;if stand alone print: push af ld c,9 call bdos ld hl,fcb+1 ld de,prtnam ld bc,11 ldir ld de,prtfil ld c,9 call bdos ;print file name pop af ret ;Increment the version number versn: inc hl ;hl --> units of major change ld a,(major) ;is a major change requested cp 'M' call z,twoinc ;inc major change number jr z,zeromn ;zero minor change number cp 'N' ;do not change version if ret z ;'n' option given inc hl inc hl inc hl ;hl --> units of vers no. twoinc: push af ;increment a 2 digit field push hl ld b,2 ld a,'9'+1 ;hl --> units position two1: inc (hl) cp (hl) jr nz,twox ;exit if not > 9 ascii ld (hl),'0' ;else zero the units dec hl ;and inc the tens djnz two1 twox: pop hl pop af ret zeromn: inc hl ;zero minor version inc hl ld (hl),'0' ;used when major changes inc hl ld (hl),'0' ret date: ld de,month ;insert m/d/y ld b,2 date1: call unpack ld (hl),'/' inc hl djnz date1 call unpack ret time: ld de,hour ld b,2 time1: call unpack ;insert h:m:s ld (hl),':' inc hl djnz time1 call unpack ret ;find the first character of string in de (V, D or T) find: ld hl,buff ;de = compare string ld bc,recsiz ;limit search to 1 rec trynxt: ld a,(de) ;get 1st char to find cpir ret po ;ret nz set = not found ;see if the rest of the string compares equal. Retry til we ;get to the end of the buffer push bc push de ld b,6 ;compare next 6 chars find2: inc de ld a,(de) cp (hl) jr nz,tryagn ;try for another string inc hl djnz find2 ;keep comparing til b = 0 pop de pop bc ret ;ret with z set tryagn: pop de ;Found the 1st character, but pop bc ;there was a bad compare in jr trynxt ;the next 6 characters. unpack: ld a,(de) ;unpack the BCD time & date inc de ;and put the ASCII characters push af ;in the buffer. rrca rrca rrca ;move high nibble to low rrca call unpak1 pop af ;do the low nibble unpak1: and 0fh add a,'0' ;make it an ASCII number ld (hl),a inc hl ret if not stdaln ;if not stand alone cmderr: db bell,'++ Command error ++',cr,lf,lf db 'e.g. datstamp d:obj.ext,d:lst.ext=d:xxx.mac m',cr,lf,lf db '"datstamp =xxx" is mandatory, the rest are optional',cr,lf,lf db 'M increments the major and zeros the minor version numbers',cr,lf,lf db 'N leaves the version numbers unchanged',cr,lf,lf db 'File was$' endif ;if not stand alone donmsg: db '++ Date stamped$' nofile: db '++ No source$' novers: db '++ No ' verstx: db 'VERS:- ' db 'in$' nodate: db '++ No ' datetx: db 'DATE:- ' db 'in$' notime: db '++ No ' timetx: db 'TIME:- ' db 'in$' crlf: db cr,lf,'$' major: db 0 if not stdaln ;if not stand alone fcb: db 0,' ' ;file cotrol block endif ;if not stand alone ext: db 'MAC' if not stdaln ;if not stand alone db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 endif ;if not stand alone buff: ds recsiz prtfil: db ' File:- ' prtnam: db ' ',cr,lf,lf,'$' end