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 / CPM / BDOS / EXTENDED.BDS < prev    next >
Text File  |  2000-06-30  |  3KB  |  115 lines

  1. ; From Dr. Dobb's Journal, Number 73, November 1982, pp. 6
  2.  
  3. ; A letter from Oscar Goldman, extracted from
  4. ; CP/M EXCHANGE by Gene Head 
  5.  
  6. ; Dear Gene,
  7. ;    This scheme is based on intercepting calls to the BDOS.  The
  8. ; only visible entry point into the BDOS is the jump instruction
  9. ; at the absolute memory address of 5.  WHile it might seem a
  10. ; simple matter to change the address at 6 and 7 in order to
  11. ; effect the interception, many applications programs (e.g., DDT)
  12. ; determine memory size from the information contained there.
  13. ; Therefore, it would seem prudent to leave the content of 6 and
  14. ; 7 alone.  Fortunately, for our purpose, the instruction jumped
  15. ; to from 5 is also a jump instruction.  This observation is the
  16. ; key to the interception process.
  17. ;    Here is an outline of the modifications to be made in the
  18. ; BIOS.  (If necessary, change the identifiers to avoid
  19. ; duplication.)
  20. ;    Add the following two equates:
  21.  
  22. ; MAXFUN    EQU    49    ; Last of the standard BDOS function numbers
  23. ; EXTRA    EQU    ?    ; Replace the "?" with the actual number
  24.             ; of new BDOS calls.  The new function
  25.             ; numbers will start from 50.
  26.  
  27. ; Toward the end of the warm boot, there is a routine called
  28. ; "gocpm".  (This name is used by Digital Research in the listing
  29. ; of the skeletal CBIOS.)  Somewhere in there will be found the
  30. ; two lines:
  31.  
  32. ;    LXI    H,BDOS
  33. ;    SHLD    6
  34.  
  35. ; Immediately after these, insert the following 4 lines:
  36.  
  37. ;     LHLD    BDOS+1
  38. ;    SHLD    NORMAL+1
  39. ;    LXI    H,DIVERT
  40. ;    SHLD    BDOS+1
  41.  
  42. ; and finish with the rest of "gocpm".
  43. ;     At a convenient point in the BIOS, add the following:
  44.  
  45. NORMAL:    EQU    JMP    0    ; The 0 will be replaced during
  46.                 ; the warm boot.
  47. DIVERT:
  48.     ; This point is reached with the function number in C
  49.     ; and the BDOS call information in DE.
  50.     MVI    A,MAXFUN
  51.     CMP    C        ; Is it an old or new call?
  52.     JNC    NORMAL        ; Old ones are diverted to NORMAL.
  53.     ADI    EXTRA
  54.     CMP    C        ; Are we exceeding the number of
  55.                 ; allowed calls?
  56.     JNC    OKAY        ; Continue if not.
  57.     LXI    H,0        ; Protocol requires these registers
  58.                 ; to be zeroed for out-of-range calls.
  59.     RET
  60. ;
  61. OKAY:
  62.     ; Here we handle the new functions
  63.     LXI    H,0        ; HL is lost.
  64.     DAD    SP
  65.     SHLD    SAVSTK        ; Save the stack pointer for later return,
  66.     LXI    SP,SAVSTK    ; and set up a local stack.
  67.     XCHG
  68.     SHLD    NTRPAR        ; Save the entry parameters.
  69.     LXI    D,FIN
  70.     PUSH    D        ; A place to return to when done.
  71.     MOV    A,c
  72.     SBI    MAXFUN+1    ; Start counting from 0.
  73.     ADD    A        ; Double it
  74.     MOV    E,A
  75.     MVI    D,0
  76.     LXI    D,TABLE
  77.     DAD    D        ; HL points to the revelent table entry.
  78.     MOV    E,M        ; Get the address
  79.     INX    H        ; contained there,
  80.     MOV    D,M        ; and move it
  81.     XCHG            ; into HL.
  82.     PCHL            ; Go do it.
  83. ;
  84. FIN:
  85.     ; Return to here when done.
  86.     LHLD    SAVSTK
  87.     SPHL            ; Restore old stack pointer.
  88.     LHLD    XITPAR        ; Get the result of the routine.
  89.     MOV    A,L
  90.     MOV    B,H        ; As per CP/M protocol.
  91.     RET            ; All done.
  92. ;
  93. TABLE:
  94.     ; Jump table for the various new BDOS calls.
  95.     ; There should be one entry for each of "EXTRA" items.
  96. NEW0:    DW    DONEW0
  97. NEW1:    DW    DONEW1
  98.     ...
  99.     ...
  100. ;
  101. NITPAR:    DS    2        ; Save the entry value of DE.
  102. XITPAR:    DS    2        ; Save the result of the BDOS call.
  103.     DS    40        ; Ample local stack -
  104.                 ; change this if necessary.
  105. SAVSTK:    DS    2        ; Save the stack pointer on entry.
  106. ;
  107. ; Each of the following routines must end with a RET instruction.
  108. ; If the routine returns a value, then it should be stored in XITPAR.
  109. ;
  110. DONEW0:                ; Actual routine #0.
  111.  
  112. DONEW1:                ; Actual routine #1.
  113.  
  114.     etc.
  115.