.TITLE DATEI Version 2.3 (Find) .ENABL LC ; .CALL DATEI DAT IDATE ; DAT is a 10 character array ; which contains the date or 10 spaces on return. ; IDATE is an optional parameter ; if specified it is assumed to be the date ; to be converted rather than the system date. ; If IDATE is omitted the system is returned. ; The calling sequence is the standard RT-11 Fortran sequence. ; D. N. Tanner ; Livermore, Ca 94550 ; MACRO .CALL ; SETS UP STANDARD SUBROUTINE CALL USING ; THE FORTRAN CALL CONVENTION (JSR PC,SUB) .nlist .MACRO .CALL .NAME .A1,.A2,.A3,.A4,.A5,.A6,.A7,.A8,.A9,.A10,?A .NARG .NUM ;Get number of arguments .NUM = .NUM-1 ;Don't count .NAME .IIF GT .NUM-10. .NUM=10. ;Limit is 10 arguments MOV #A,%5 ;Point R5 to argument list JSR %7,.NAME ;Call subroutine BR .+4+<.NUM*2> ;Branch past argument list A: .BYTE .NUM,0 ;Number of arguments .IIF GT .NUM .WORD .A1 ;Include only arguments needed .IIF GT .NUM-1 .WORD .A2 .IIF GT .NUM-2 .WORD .A3 .IIF GT .NUM-3 .WORD .A4 .IIF GT .NUM-4 .WORD .A5 .IIF GT .NUM-5 .WORD .A6 .IIF GT .NUM-6 .WORD .A7 .IIF GT .NUM-7 .WORD .A8 .IIF GT .NUM-8. .WORD .A9 .IIF GT .NUM-9. .WORD .A10 ; Branch to here, the next instruction in the program .ENDM .list .GLOBL DATEI,IOASC,SAVER,RESTOR .MCALL .DATE DATEI: JSR PC,SAVER ;save Registers CLR MODE CMP (R5)+,#2 ;Test for IDATE Argument BLT 1$ ;No INC MODE ;MODE=1 indicates IDATE argument 1$: MOV (R5),R4 ;Get location of DATE MOV #10.,R1 10$: MOVB SPACE,(R4)+ ;Set output to 10 spaces SOB R1,10$ TST MODE ;Do we have a user date? BEQ 2$ ;No, use system date MOV @2(R5),R0 ;Yes, Get the date for IDATE BR 3$ 2$: .DATE ;System date 3$: MOV R0,R2 ;copy the date, BNE DAT0 ;do we have one? JSR PC,RESTOR ;No, just return with the blanks DAT0: BIC #177740,R0 ;Extract the year from the date ADD #72.,R0 ;offset is 72, can't be earlier than 72 MOV R0,-(SP) ;Save it for later MOV R2,R0 ;Get a new copy of the date ASL R0 ASL R0 ASL R0 SWAB R0 SWAB R2 ASR R2 ASR R2 BIC #177760,R2 ;Extract the month MOV R2,-(SP) ;Save it for later BIC #177740,R0 ;Extract the day MOV R0,I ;Save it for conversion to ASCII MOV (R5),-(SP) ;Save DAT location, Output string .CALL IOASC I,N2,CHR ;Convert day to ASCII MOV (SP)+,R0 ;Restore DAT pointer MOVB CHR,(R0)+ ;Deposit the ASCII day MOVB CHR+1,(R0)+ MOVB #'-,(R0)+ ;Add the dash MOV (SP),R1 ;Get the month and multiply by 3 ; for a table pointer ASL R1 ADD (SP)+,R1 ADD #MOS-3,R1 ;Add in the table start location MOVB (R1)+,(R0)+ ;Deposit the 3 letter month name MOVB (R1)+,(R0)+ MOVB (R1),(R0)+ MOVB #'-,(R0)+ ;Another dash MOV (SP)+,I ;Now get the year MOV R0,-(SP) ;Save the output pointer .CALL IOASC I,N2,CHR ;Convert the year to ASCII MOV (SP)+,R0 ;Restore the DAT pointer MOVB CHR,(R0)+ ;Copy the year MOVB CHR+1,(R0)+ JSR PC,RESTOR ;Restore registers and return MOS: .ASCII /JanFebMarApr/ ;Month name table .ASCII /MayJunJulAug/ .ASCII /SepOctNovDec/ .EVEN I: .WORD 0 N2: .WORD 2 SPACE: .BYTE 40,40 CHR: .WORD 0 MODE: .WORD 0 .END