; OCLOCK.ASM - disassembled from OCLOCK.COM by Mike Rubenstein ; ; When LASMed and MLOADed, produces code identical to the ; Mike Rubenstein original, which was freely distributed with ; his copyright (q.v., below) and the associated OCLOCK.DOC. ; ; As noted in the document, this program is intended for use as ; a profiler, when testing applications written in Software Toolworks ; C-80. It also provides valuable insights into the OCC1 ROM BIOS ; clock. ; ; Initial disassembley, using REVAS and DSD, by Walt Wheeler, Y.O.U., ; with major cleanup and clarification by Barry Siegfried, K2MF. 12/87 ; BDOS EQU 5 TICNTR EQU 0BH ;two bytes at 0BH & 0CH for TICNTR TSTACK EQU 13H ;temp stack for use while back in RAM FCB EQU 5CH ;default FCB INTJVC EQU 0EFF8H ;int jump vector addr stored here ; ORG 100H ; JMP START ; NAME: DB 'OCLOCK Version 1.0',0DH,0AH ; CPYWR: DB 'Copyright 1982 ' DB 'Michael M Rubenstein',0DH,0AH DB '$' ; START: LXI H,0 ;zero HL so that... DAD SP ;...CCP stack pointer now in HL LXI SP,STACK ;top of new stack PUSH H ;save CCP stack pointer ; LXI H,FCB+1 ;look at command arg LXI D,OFFSW ;point to 'OFF ' arg LXI B,4 ;arg count of 4 CALL ARGTST ;test for 'OFF ' arg JZ DEINST ;turn off ticker ; ;This routine installs the ticker ; INST: LHLD INTJVC ;int jump vector addr in HL MOV A,H ;get int jump vector addr (high byte) CPI 40H ;does INTJVC point into ROM ( < 4000H )? JRNC ZERO ;no, already installed ; SHLD NINT ;yes, store orig int jump vector addr... ;...at new int jump vector LHLD BDOS+1 ;orig BDOS entry addr in HL SHLD NBDOS ;store orig BDOS entry addr... ;...at new BDOS jump vector ; ;Calculate the dest addr of relocated code - BDOS minus 900H ; MOV A,H ;get BDOS entry addr high byte SUI 9 ;calculate - 900H (CCP is approx 800H ) MOV H,A ;put BDOS - 900H back in HL MVI L,0 ;zero L so that HL = dest addr PUSH H ;save new BDOS jump vector ; this allows room for the relocated part of ; this code beneath the CCP, and protects both XCHG ;dest addr in DE LXI H,TICKER ;source addr in HL LXI B,PROGLEN ;program length in BC LDIR ;move ticker code to BDOS - 900H POP H ;get back new BDOS jump vector LXI D,3 ;3 in DE so that... SHLD BDOS+1 ;store new BDOS jump vector at BDOS JMP DAD D ;...HL = ticker code SHLD INTJVC ;ticker code addr = new int jump vector ; ZERO: LXI H,0 ;zero HL to... SHLD TICNTR ;...reset tick counter ; EXIT: POP H ;restore CCP stack pointer SPHL ;top of CCP stack RET ;return to CCP, ticker installed ; ;This routine de-installs the ticker ; DEINST: LHLD INTJVC ;int jump vector addr in HL MOV A,H ;get int jump vector addr high byte CPI 40H ;does INTJVC point to addr in ROM ( < 4000H ) JRC EXIT ;yes, already not-installed ; MVI L,NINTOFF ;no, new int jump vector in HL MOV E,M ;orig int jump... INX H ;...vector addr... MOV D,M ;...in DE SDED INTJVC ;restore orig int jump vector addr MVI L,1 ;new BDOS jump vector in HL MOV E,M ;orig BDOS... INX H ;...entry addr... MOV D,M ;...in DE SDED BDOS+1 ;restore orig BDOS entry addr ; POP H ;restore CCP stack pointer SPHL ;top of CCP stack RET ;return to CCP, ticker de-installed ; ARGTST: LDAX D ;get 'OFF ' arg byte CCI ;A-[HL], HL=HL+1, BC=BC-1 RNZ ;no match, ZF not set RPO ;BC=0, done with arg test, ZF set INX D ;bump pointer JR ARGTST ;loop until done ; ;--------------------------------------------------------------------- ;This is the beginning of code to be moved up to BDOS - 900H ;--------------------------------------------------------------------- ; TICKER EQU $ ; NBDOS EQU $+1 ;addr for the following new BDOS... ;...jump filled in at runtime ; JMP 0 ;jump to orig BDOS entry addr ; ;Actual ticker code starts here - this routine gets executed any ; time the interrupt jump vector, which points to an address that ; is buried in the ROM, would normally get executed ; ;--------------------------------------------------------------------- ;This is the beginning of code which must be ported to any other ; code that performs real-time functions ; DI ;disable interrupts OUT 1 ;switch in RAM bank SSPD TSTACK ;save ROM stack pointer... LXI SP,TSTACK ;...at top of temp stack in RAM PUSH H ;save regs PUSH D ; PUSH PSW ; ; ;--------------------------------------------------------------------- ;The following code is meant to check that the new BDOS jump is ; still installed - if it isn't it fixes it ; ;It will not be necessary to port this part of the code ; LDED INTJVC ;new int jump vector in DE MVI E,0 ;new BDOS jump in DE LHLD BDOS+1 ;new BDOS jump vector in HL... ;...so that HL = DE if all OK STC ;set CF DSBB D ;subtract DE from HL JRC TICKUP ;HL = DE, CF still set SDED BDOS+1 ;CF cleared, HL > DE, refresh BDOS jump ; ;2 bytes beginning at 000BH for TICNTR ; ;The following code is equivalent to your real time code to which ; the appropriate code above and below must be ported ; TICKUP: LHLD TICNTR ;get the tick counter... INX H ;...increment it and... SHLD TICNTR ;...store it back ; ;--------------------------------------------------------------------- ;This is the end of code which must be ported to any other ; code that performs real-time functions ; POP PSW ;restore regs POP D ; POP H ; LSPD TSTACK ;restore ROM stack pointer OUT 0 ;switch ROM bank back in ; NINT EQU $+1 ;addr for the following new int... ;...jump vector filled in at runtime ; JMP 0 ;jump to orig int jump vector addr ; ;--------------------------------------------------------------------- ; NINTOFF EQU NINT-TICKER ;offset of orig int jump vector... ;...addr in relocated code ; PROGLEN EQU $-TICKER ; OFFSW: DB 'OFF ' ;'OFF ' arg ; DS 20 ;stack area ; STACK: ;top of new stack ; END