home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / OSBORNE / CLOCK.LBR / OCLOCKRV.AZM / OCLOCKRV.ASM
Assembly Source File  |  2000-06-30  |  6KB  |  190 lines

  1. ; OCLOCK.ASM - disassembled from OCLOCK.COM by Mike Rubenstein
  2. ;
  3. ; When LASMed and MLOADed, produces code identical to the
  4. ; Mike Rubenstein original, which was freely distributed with 
  5. ; his copyright (q.v., below) and the associated OCLOCK.DOC.
  6. ; As noted in the document, this program is intended for use as
  7. ; a profiler, when testing applications written in Software Toolworks
  8. ; C-80.  It also provides valuable insights into the OCC1 ROM BIOS
  9. ; clock. 
  10. ;
  11. ; Initial disassembley, using REVAS and DSD, by Walt Wheeler, Y.O.U., 
  12. ; with major cleanup and clarification by Barry Siegfried, K2MF. 12/87
  13. ;
  14. BDOS    EQU    5
  15. TICNTR    EQU    0BH        ;two bytes at 0BH & 0CH for TICNTR
  16. TSTACK    EQU    13H        ;temp stack for use while back in RAM
  17. FCB    EQU    5CH        ;default FCB
  18. INTJVC    EQU     0EFF8H        ;int jump vector addr stored here
  19. ;
  20.     ORG     100H
  21. ;
  22.     JMP    START
  23. ;
  24. NAME:    DB    'OCLOCK Version 1.0',0DH,0AH
  25. ;
  26. CPYWR:    DB    'Copyright 1982  '
  27.     DB    'Michael M Rubenstein',0DH,0AH
  28.     DB    '$'
  29. ;
  30. START:    LXI    H,0        ;zero HL so that...
  31.     DAD    SP        ;...CCP stack pointer now in HL
  32.     LXI    SP,STACK    ;top of new stack
  33.     PUSH    H        ;save CCP stack pointer
  34. ;
  35.     LXI    H,FCB+1        ;look at command arg
  36.     LXI    D,OFFSW        ;point to 'OFF ' arg
  37.     LXI    B,4        ;arg count of 4
  38.     CALL    ARGTST        ;test for 'OFF ' arg
  39.     JZ    DEINST        ;turn off ticker
  40. ;
  41. ;This routine installs the ticker
  42. ;
  43. INST:    LHLD    INTJVC        ;int jump vector addr in HL
  44.     MOV    A,H        ;get int jump vector addr (high byte)
  45.     CPI    40H        ;does INTJVC point into ROM ( < 4000H )?
  46.     JRNC    ZERO        ;no, already installed
  47. ;
  48.     SHLD    NINT        ;yes, store orig int jump vector addr...
  49.                 ;...at new int jump vector
  50.     LHLD    BDOS+1        ;orig BDOS entry addr in HL
  51.     SHLD     NBDOS        ;store orig BDOS entry addr...
  52.                 ;...at new BDOS jump vector
  53. ;
  54. ;Calculate the dest addr of relocated code - BDOS minus 900H
  55. ;
  56.     MOV    A,H        ;get BDOS entry addr high byte
  57.     SUI    9        ;calculate - 900H (CCP is approx 800H ) 
  58.     MOV    H,A        ;put BDOS - 900H back in HL
  59.     MVI    L,0        ;zero L so that HL = dest addr
  60.     PUSH    H        ;save new BDOS jump vector
  61.                 ; this allows room for the relocated part of
  62.                 ; this code beneath the CCP, and protects both
  63.     XCHG            ;dest addr in DE
  64.     LXI    H,TICKER    ;source addr in HL
  65.     LXI    B,PROGLEN    ;program length in BC
  66.     LDIR            ;move ticker code to BDOS - 900H
  67.     POP    H        ;get back new BDOS jump vector
  68.     LXI    D,3        ;3 in DE so that...
  69.     SHLD    BDOS+1        ;store new BDOS jump vector at BDOS JMP
  70.     DAD    D        ;...HL = ticker code
  71.     SHLD    INTJVC        ;ticker code addr = new int jump vector
  72. ;
  73. ZERO:    LXI    H,0        ;zero HL to...
  74.     SHLD    TICNTR        ;...reset tick counter
  75. ;
  76. EXIT:    POP H            ;restore CCP stack pointer
  77.     SPHL            ;top of CCP stack
  78.     RET            ;return to CCP, ticker installed
  79. ;
  80. ;This routine de-installs the ticker
  81. ;
  82. DEINST:    LHLD    INTJVC        ;int jump vector addr in HL
  83.     MOV    A,H        ;get int jump vector addr high byte
  84.     CPI    40H        ;does INTJVC point to addr in ROM ( < 4000H )
  85.     JRC    EXIT        ;yes, already not-installed
  86. ;
  87.     MVI    L,NINTOFF    ;no, new int jump vector in HL
  88.     MOV    E,M        ;orig int jump...
  89.     INX    H        ;...vector addr...
  90.     MOV    D,M        ;...in DE
  91.     SDED    INTJVC        ;restore orig int jump vector addr
  92.     MVI    L,1        ;new BDOS jump vector in HL
  93.     MOV    E,M        ;orig BDOS...
  94.     INX    H        ;...entry addr...
  95.     MOV    D,M        ;...in DE
  96.     SDED    BDOS+1        ;restore orig BDOS entry addr
  97. ;
  98.     POP H            ;restore CCP stack pointer
  99.     SPHL            ;top of CCP stack
  100.     RET            ;return to CCP, ticker de-installed
  101. ;
  102. ARGTST:    LDAX    D        ;get 'OFF ' arg byte
  103.     CCI            ;A-[HL], HL=HL+1, BC=BC-1
  104.     RNZ            ;no match, ZF not set
  105.     RPO            ;BC=0, done with arg test, ZF set
  106.     INX    D        ;bump pointer
  107.     JR    ARGTST        ;loop until done
  108. ;
  109. ;---------------------------------------------------------------------
  110. ;This is the beginning of code to be moved up to BDOS - 900H
  111. ;---------------------------------------------------------------------
  112. ;
  113. TICKER    EQU    $
  114. ;
  115. NBDOS    EQU    $+1        ;addr for the following new BDOS...
  116.                 ;...jump filled in at runtime
  117. ;
  118.     JMP    0        ;jump to orig BDOS entry addr
  119. ;
  120. ;Actual ticker code starts here - this routine gets executed any
  121. ;    time the interrupt jump vector, which points to an address that
  122. ;    is buried in the ROM, would normally get executed
  123. ;
  124. ;---------------------------------------------------------------------
  125. ;This is the beginning of code which must be ported to any other
  126. ;    code that performs real-time functions
  127. ;
  128.     DI            ;disable interrupts
  129.     OUT    1        ;switch in RAM bank
  130.     SSPD    TSTACK        ;save ROM stack pointer...
  131.     LXI    SP,TSTACK    ;...at top of temp stack in RAM
  132.     PUSH    H        ;save regs
  133.     PUSH    D        ;
  134.     PUSH    PSW        ;
  135. ;
  136. ;---------------------------------------------------------------------
  137. ;The following code is meant to check that the new BDOS jump is
  138. ;    still installed - if it isn't it fixes it
  139. ;
  140. ;It will not be necessary to port this part of the code
  141. ;
  142.     LDED    INTJVC        ;new int jump vector in DE
  143.     MVI    E,0        ;new BDOS jump in DE
  144.     LHLD    BDOS+1        ;new BDOS jump vector in HL...
  145.                 ;...so that HL = DE if all OK
  146.     STC            ;set CF
  147.     DSBB    D        ;subtract DE from HL
  148.     JRC    TICKUP        ;HL = DE, CF still set
  149.     SDED    BDOS+1        ;CF cleared, HL > DE, refresh BDOS jump
  150. ;
  151. ;2 bytes beginning at 000BH for TICNTR
  152. ;
  153. ;The following code is equivalent to your real time code to which
  154. ;    the appropriate code above and below must be ported
  155. ;
  156. TICKUP:    LHLD    TICNTR        ;get the tick counter...
  157.     INX    H        ;...increment it and...
  158.     SHLD    TICNTR        ;...store it back
  159. ;
  160. ;---------------------------------------------------------------------
  161. ;This is the end of code which must be ported to any other
  162. ;    code that performs real-time functions
  163. ;
  164.     POP    PSW        ;restore regs
  165.     POP    D        ;
  166.     POP    H        ;
  167.     LSPD    TSTACK        ;restore ROM stack pointer
  168.     OUT    0        ;switch ROM bank back in
  169. ;
  170. NINT    EQU    $+1        ;addr for the following new int...
  171.                 ;...jump vector filled in at runtime
  172. ;
  173.     JMP    0        ;jump to orig int jump vector addr
  174. ;
  175. ;---------------------------------------------------------------------
  176. ;
  177. NINTOFF    EQU    NINT-TICKER    ;offset of orig int jump vector...
  178.                 ;...addr in relocated code
  179. ;
  180. PROGLEN    EQU    $-TICKER
  181. ;
  182. OFFSW:    DB    'OFF '        ;'OFF ' arg
  183. ;
  184.     DS    20        ;stack area
  185. ;
  186. STACK:                ;top of new stack
  187. ;
  188.     END
  189.