nam Clock Module ttl Module Header * opt -c ************************************************************ * * * Clock Module * * * * Copyright 1982 by Microware Systems Corporation * * Reproduced Under License * * * * This source code is the proprietary confidential prop- * * erty of Microware Systems Corporation, and is provided * * to the licensee solely for documentation and educational * * purposes. Reproduction, publication, or distribution in * * any form to any party other than the licensee is * * is strictly prohibited !!! * * * ************************************************************ ifeq (CPUType-CMS9639) * Initialise PIA for VSYNC or TIMER interrupts, endc * and take control of IRQ vector * CPORT set A.Clock hardware clock control use defsfile ************************************************************* * * MODULE HEADER * Type set Systm+Objct Revs set ReEnt+1 mod ClkEnd,ClkNam,Type,Revs,ClkEnt,CPORT ClkNam fcs /Clock/ fcb 3 Edition number * * CLOCK DATA DEFINITIONS * TIMSVC fcb F$Time fdb TIME-*-2 fcb $80 CLKPRT equ M$Mem Memory has Clock port address (CPORT) * * DAYS IN MONTHS TABLE * MONTHS fcb 0 Uninitialized month fcb 31 January fcb 28 February fcb 31 March fcb 30 April fcb 31 May fcb 30 June fcb 31 July fcb 31 August fcb 30 September fcb 31 October fcb 30 November fcb 31 December ************************************************************* * * Non-Clock Interrupt Service * NOTCLK ldd D.Poll get polling routine ptr lbra TICK50 ************************************************************* * * Clock Interrupt Service routine * * NOTE: the stack pointer is invalid when this routine is * entered. It must not be used, but it must not be * lost. * CLKSRV ldx CLKPRT,PCR GET CLOCK ADDRESS lda 1,x get CRA of 6821 bpl NOTCLK it is not the clock that raised IRQ? lda ,x clear the interrupt Tick equ * * * UPDATE CURRENT TIME * dec D.Tick COUNT TICK bne Tick40 BRANCH IF NOT END OF SECOND ldd D.Min GET MINUTE & SECOND incb COUNT SECOND cmpb #60 END OF MINUTE? bcs TICK35 BRANCH IF NOT inca COUNT MINUTE cmpa #60 END OF HOUR? bcs TICK30 Branch if not ldd D.Day Get day & hour incb COUNT Hour cmpb #24 End of day? bcs TICK25 Branch if not inca COUNT Day leax MONTHS,PCR Get days/month table ldb D.Month Get month cmpb #2 Is it february? bne TICK10 Branch if not ldb D.Year Get year beq TICK10 Branch if even hundred andb #3 Is it leap year? bne TICK10 Branch if not deca ADD Feb 29 TICK10 ldb D.Month Get month cmpa B,X End of month? bls TICK20 Branch if not ldd D.Year Get year & month incb COUNT Month cmpb #13 End of year? bcs TICK15 Branch if not inca COUNT Year ldb #1 New month TICK15 std D.Year Update year & month lda #1 New day TICK20 clrb NEW Hour TICK25 std D.Day Update day & hour clra NEW Minute TICK30 clrb NEW Second TICK35 std D.Min Update minute & second lda #TickSec Get ticks presecond sta D.Tick Tick40 equ * ldd D.Clock get clock routine ptr TICK50 std D.SvcIRQ set IRQ service routine jmp [D.XIRQ] enter system ***** * * CLOCK INITIALIZATION ENTRY * ClkEnt pshs cc lda #TickSec get ticks per second sta D.Tick lda #TickSec/10 set ticks/time slice sta D.TSlice sta D.Slice leax CLKSRV,pcr GET SERVICE ROUTINE stx D.IRQ SET INTERRUPT VECTOR * PIA initialisation goes here ldx CLKPRT,pcr get PIA address orcc #IntMasks set interrupt masks clra sta 1,x clr control register lda #%00000001 PIA port A bit0 output, rest input sta ,x set data direction register lda #5 select pheripheral register & CRA1 interrupt enable, high to low sta 1,x set control register clra sta 0,x clear bit 0 which enables 100Hz clock lda ,x clear any current interrupts puls cc restore interrupt masks leay TIMSVC,PCR OS9 F$SSvc SET TIME SERVICE ROUTINE ClkEnt3 rts ************************************************************* * * Subroutine Time * * Time of Day service routine * TIME lda D.SysTsk get system task number ldx D.Proc get process ptr ldb P$Task,x get process task number ldx #D.Time get source ptr ldy #6 get byte count ldu R$X,u get specified location os9 F$Move move time to user rts emod ClkEnd equ * end