home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / ASSEMBLY / V20BOOT.ZIP / V20BDOS.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-04-30  |  28.4 KB  |  795 lines

  1.  
  2.         TITLE    'BDOS-BIOS EMULATOR for V20 on IBM PC'
  3.         PAGE 60
  4. ; this is bdos minus the disk calls, which are passed on to msdos
  5.  
  6. ; philosophy
  7.  
  8.         ; handle character calls in 8080 mode so that
  9.         ; can do submit and EX files
  10.         ; line editing and ^S , ^C handling are easier this way
  11.  
  12.         ; the character i/o calls are off to the BIOS
  13.         ; eventually anyway
  14.  
  15.         ; bdos disk calls passed off directly to 8086 MSDOS
  16.         ; add selected higher calls to support
  17.         ; time, date, make dir, change dir calls
  18.         ; can be done in Turbo bdos-handler
  19.  
  20. VER    equ 2
  21. REV    equ 2
  22.  
  23. BDOSHANDLE   equ  0c2h;   8086 interrupt numbers to get to 8086 mode
  24. BIOSHANDLE   equ  0c3h;   80,81h used by other end to get here
  25.  
  26. ; V20 macros ( used only once )
  27.  
  28. CALLN   macro     x  ; call 8088 routine at int x
  29.         db        11101101b,11101101b  ;
  30.         db        (x  and 0ffh)  ;
  31.         endm
  32.  
  33. RETEM   macro
  34.         db   0edh,0fdh
  35.         endm
  36.  
  37. BOOTV   equ  0000H; Vector to BIOS warm boot routine
  38. IOBYTE  equ  0003H; System I/O device assignment
  39. TBUFF   equ  0080H; Default DMA buffer location
  40.  
  41. FALSE   equ  0
  42. TRUE    equ  1
  43.  
  44. CR      equ     0DH
  45. LF      equ     0AH
  46. TAB     equ     09H             ; Tab
  47. BACKSP  equ     08H             ; Backspace
  48. CTRLC   equ     03H             ; Control-C
  49. CTRLE   EQU     05H             ; Control-E
  50. CTRLP   EQU     10H             ; Control-P
  51. CTRLR   EQU     12H             ; Control-R
  52. CTRLS   EQU     13H             ; Control-S
  53. CTRLU   EQU     15H             ; Control-U
  54. CTRLX   EQU     18H             ; Control-X
  55. DELDAT  EQU     0E5H            ; Deleted data byte
  56.  
  57.         ORG   0FA00H ;  CSEG    ; DOSLOC
  58.  
  59. SERIAL: DB      0,0,0           ; Room for serial number
  60.         DB      0,0,0
  61.  
  62. ENTRY:  JMP     BDOS            ; Entry to disk monitor ; serial + 6
  63.  
  64. ;****
  65. ;Put bdos dpb and allocation vector here so can be found easily.
  66. ; these are doctored up by the Turbo Bdos-handler
  67.  
  68. DATASTART EQU   $
  69. BDOSDPB:   ;serial + 9
  70.         DS      16     ;
  71. BDOSALLOC: ;serial + 25
  72.         DS      256
  73. CTEMP1: DB      0               ; temp used for console input buffer
  74. CTEMP2: DB      0               ; temp count holder for buffer
  75. COLUMN: DB      0               ; column pointer for buffer
  76. LSTCPY: DB      0               ; list copy toggle byte
  77. CHRRDY: DB      0               ; char waiting flag
  78. OLDSP:  DB      0,0             ; Caller's Stack ptr
  79.         DB      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  80.         DB      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  81.         DB      0,0,0,0,0,0,0,0 ; 48 bytes (room for stack)
  82. USRCOD: DB      0               ; user and disk code lives here
  83. CURDSK: DB      0               ; current disk holder
  84. FCB:    DW      0               ; Storage for caller's parms
  85. ODATA:  DW      0               ; return information storage
  86. IDATA:  DB      0
  87. OUT1:   DB      0
  88. OLDDSK: DB      0
  89. OUTDSK: DB      0
  90. DATAEND equ     $
  91.         ds      4  ; buffer area in case miscounted
  92.  
  93.  
  94. ;****
  95. ;bdos entry point. data enters as follows:
  96. ;               C  = command
  97. ;               DE = address or 16 bit data word
  98. ;               E  = 8 bit data word
  99.  
  100. ;      return from bdos data is as follows:
  101. ;               A  = status or value
  102. ;               HL = 16 bit value or address
  103.  
  104.  
  105. ;****
  106. ;bdos entry saves input data as follows:
  107.  
  108. ;    DE -> FCB          0  -> OLDDSK
  109. ;    E  -> IDATA        0  -> OUT1
  110. ;    0  -> ODATA        sets return to BEXIT on stack
  111. ;    SP -> OLDSP
  112.  
  113. ;    saves input data and jumps to command routine
  114.  
  115. ; DESTROYS A AND HL RIGHT AWAY
  116.  
  117. BDOS:   LDA     0FFFFH;  -1      ; test for exit
  118.         ORA     A
  119.         JNZ     BREAKOUT         ; in BIOS area  do a RETEM
  120.  
  121. BEGIN:
  122.         XCHG      ; mov de to fcb and bdde
  123.         SHLD    BDDE
  124.         SHLD    FCB
  125.         XCHG
  126.         LXI     H,BDBC
  127.         mov     m,c             ;
  128.         LXI     h,0             ; zero hl
  129.         SHLD    ODATA           ; save this for the return
  130.         DAD     SP              ; add in the user stack pointer
  131.         SHLD    OLDSP           ; save this for the return also
  132.         LXI     SP,USRCOD       ; point to BDOS stack  { use private stack }
  133.         MOV     A,E             ; move data byte into A
  134.         STA     IDATA           ; save it
  135.         XRA     A               ; zero out a
  136.         STA     OLDDSK          ; save this as the old disk
  137.         STA     OUT1            ; and at OUT1 for disk relog on exit
  138.         LXI     H,BEXIT ;Bexit  ; get the return point address
  139.         PUSH    H               ; and stuff it on the stack for exiting
  140.         MOV     A,C             ; move the command into A
  141.         STA     BDPSW           ; put it into registers at the end
  142.         CPI     13              ; Max Char cmds +1 - is it too big?
  143.         JNC     MSDOSHANDLER    ; return if so
  144.         MOV     C,E             ; get input data from E into C
  145.         LXI     H,CMMNDS        ; point to the dispatch table
  146.         MOV     E,A             ; move the command from A into E
  147.         MVI     D,0             ; zero out D
  148.         DAD     D               ; add in the dispatch table
  149.         DAD     D               ; once more - over two bytes
  150.         MOV     E,M             ; pull the jump address
  151.         INX     H               ; into
  152.         MOV     D,M             ; DE
  153.         LHLD    FCB             ; get the info word into HL
  154.         XCHG                    ; swap DE and HL
  155.         PCHL                    ; jump to the command routine
  156.  
  157. ;****
  158. ; command dispatch table
  159.  
  160. CMMNDS: DW      WBOOTF          ;  0: System reset
  161.         DW      REDCON          ;  1: Console input
  162.         DW      WRTCON          ;  2: Console output
  163.         DW      REDRDR          ;  3: Reader input
  164.         DW      PUNF            ;  4: Punch output
  165.         DW      LISTF           ;  5: List output
  166.         DW      DIRTIO          ;  6: Direct console I/O
  167.         DW      GETIOB          ;  7: Get I/O Byte
  168.         DW      PUTIOB          ;  8: Set I/O Byte
  169.         DW      PRNBUF          ;  9: Print string
  170.         DW      REDBUF          ; 10: Read console buffer
  171.         DW      GCSTAT          ; 11: Get console status
  172.         DW      GETVER          ; 12: Get version number ( 2.2 )
  173.  
  174. ;****
  175. ; Read next console character
  176.  
  177. CONIN:  LXI     H,CHRRDY        ; Point to the char ready flag
  178.         MOV     A,M             ; move the ready byte into A
  179.         MVI     M,0             ; and zero out the flag
  180.         ORA     A               ; was anyone home
  181.         RNZ                     ; return if not
  182.         JMP     CONIF           ; otherwise go get the thing
  183.  
  184. ;****
  185. ; Read console character, echo print if it is ok
  186.  
  187. CIECHO: CALL    CONIN           ; get a character
  188.         CALL    GRAFIC          ; check the control characters
  189.         RC                      ; return if the char is not printable
  190.         PUSH    PSW             ; otherwise save it
  191.         MOV     C,A             ; put a copy into C
  192.         CALL    WRTCON          ; and print it out
  193.         POP     PSW             ; restore it
  194.         RET                     ; and return to sender
  195.  
  196. ;****
  197. ;see if A is a good control char, ret with CY set if not
  198.  
  199. GRAFIC: CPI     CR              ; test for carriage return
  200.         RZ                      ; return if it was
  201.         CPI     LF              ; how about line feed
  202.         RZ                      ; that is ok
  203.         CPI     TAB             ; as is tab
  204.         RZ                      ; so back with it
  205.         CPI     BACKSP          ; Backspace in 2.0
  206.         RZ                      ; is known
  207.         CPI     ' '             ; test all other control characters
  208.         RET                     ; and go back with carry set for no echo
  209.  
  210. ;****
  211. ; Check for console break and abort
  212.  
  213. CONBRK: LDA     CHRRDY          ; get the character ready byte
  214.         ORA     A               ; and check for waiting char
  215.         JNZ     CB1             ; non zero says something is there
  216.         CALL    CONSF           ; check the console if none there
  217.         ANI     01H             ; and in the status bit
  218.         RZ                      ; return if it came up zero
  219.         CALL    CONIF           ; otherwise go get the waiting char
  220.         CPI     CTRLS           ; was it a control-s
  221.         JNZ     CB0             ; if not return with ready flag set
  222.         CALL    CONIF           ; if it was wait for the next char
  223.         CPI     CTRLC           ; is this one control c?
  224.         JZ      BOOTV           ; if so we reboot
  225.         XRA     A               ; or else zero a
  226.         RET                     ; and simply return
  227.  
  228. CB0:    STA     CHRRDY          ; Save input char
  229. CB1:    MVI     A,TRUE          ; and say true to the caller
  230.         RET                     ; and go back
  231.  
  232. ;****
  233. ; Output char in C to console, list also if LSTCPY = true
  234.  
  235. CONOUT: LDA     CTEMP1          ; get the first temp column counter
  236.         ORA     A               ; is it zero?
  237.         JNZ     CONOU1          ; if nonzero jump over
  238.         PUSH    B               ; otherwise save input character
  239.         CALL    CONBRK          ; Check for abort
  240.         POP     B               ; recover the char
  241.         PUSH    B               ; save it again
  242.         CALL    CONOF           ; and print the character on the console
  243.         POP     B               ; recover once more
  244.         PUSH    B               ; would you believe save it again
  245.         LDA     LSTCPY          ; get the list flag byte
  246.         ORA     A               ; to set flags
  247.         CNZ     LISTF           ;  and to list if LSTCPY=true
  248.         POP     B               ; restore char one last time
  249. CONOU1: MOV     A,C             ; put the byte into A
  250.         LXI     H,COLUMN        ; point to the buffer column counter
  251.         CPI     7FH             ; Rubout ?
  252.         RZ                      ; return if so
  253.         INR     M               ; Increment column
  254.         CPI     ' '             ; is the character a space?
  255.         RNC                     ; return if less - must be control
  256.         DCR     M               ; Decrement column
  257.         MOV     A,M             ; and get the character there
  258.         ORA     A               ; check for a null
  259.         RZ                      ; return if it is
  260.         MOV     A,C             ; move the char into C
  261.         CPI     BACKSP          ; was it a backspace?
  262.         JNZ     CONOU2          ; if not jump over
  263.         DCR     M               ; Decrement column
  264.         RET                     ; and return
  265.  
  266. CONOU2: CPI     LF              ; was it a linefeed?
  267.         RNZ                     ; return if not again
  268.         MVI     M,0             ; Set column to 0
  269.         RET                     ; and return
  270.  
  271. ;****
  272. ; Print char in C at console, convert Ctrl chars to ^[char]
  273.  
  274. CTLOUT: MOV     A,C             ; move the char into A
  275.         CALL    GRAFIC          ; see if it is printable
  276.         JNC     WRTCON          ; jump past cause it is ok
  277.         PUSH    PSW             ; otherwise save ctrl char on the stack
  278.         MVI     C,5EH           ; get the "^" char
  279.         CALL    CONOUT          ; and print it
  280.         POP     PSW             ; get the char back
  281.         ORI     40H             ; add in the bias to make it print
  282.         MOV     C,A             ; put it into C for the next
  283.  
  284. ;****
  285. ; BDOS function 2: write to the system console char in C
  286.  
  287. WRTCON: MOV     A,C             ; which puts it into A
  288.         CPI     TAB             ; check for tab
  289.         JNZ     CONOUT          ; if not jump and print
  290. TABOUT: MVI     C,' '           ; Space gets printed to expand tabs
  291.         CALL    CONOUT          ;  to
  292.         LDA     COLUMN          ;   next
  293.         ANI     07H             ;    tab
  294.         JNZ     TABOUT          ;     stop
  295.         RET                     ; Return
  296.  
  297. DELAST: CALL    BACKUP          ; back up one character
  298.         MVI     C,' '           ; then get a blank
  299.         CALL    CONOF           ; and print it out
  300. BACKUP: MVI     C,BACKSP        ; get a backspace
  301.         JMP     CONOF           ; and print it as well to move into spot
  302.  
  303. ;****
  304. ; Print pound sign, CRLF, and fix columns
  305.  
  306. LBCRLF: MVI     C,'#'           ; get a pound sign
  307.         CALL    CONOUT          ; and print it
  308.         CALL    CRLF            ; Turn up a new line
  309. LB1:    LDA     COLUMN          ; get the column counter
  310.         LXI     H,CTEMP2        ; point to the temp counter
  311.         CMP     M               ; are they equal?
  312.         RNC                     ; not there yet
  313.         MVI     C,' '           ; so get a space
  314.         CALL    CONOUT          ; and print it out
  315.         JMP     LB1             ; loop til the counts are the same
  316.  
  317. ;****
  318. ; Print CR/LF at console
  319.  
  320. CRLF:   MVI     C,CR            ;  get a cr
  321.         CALL    CONOUT          ; and print it out
  322.         MVI     C,LF            ; followed by a lf
  323.         JMP     CONOUT          ; which goes out too
  324.  
  325. ;****
  326. ; Print string at (BC) until '$' with TAB expansion
  327.  
  328. PRINT:  LDAX    B               ; get the byte at (BC)
  329.         CPI     '$'             ; is it the end mark?
  330.         RZ                      ; if so we are done
  331.         INX     B               ; otherwise bump the pointer
  332.         PUSH    B               ; and save it in the stack
  333.         MOV     C,A             ; get the character into C
  334.         CALL    WRTCON          ; write it out expanding tabs
  335.         POP     B               ; recover the pointer
  336.         JMP     PRINT           ; and loop til we hit the stop
  337.  
  338. ;****
  339. ; BDOS function 10: Read console buffer at
  340. ;     enter with BC -> console buffer address
  341.  
  342. REDBUF: LDA     COLUMN          ; get the column counter into A
  343.         STA     CTEMP2          ; save it at CTEMP2
  344.         LHLD    FCB             ; get the information into HL
  345.         MOV     C,M             ; get the buffer count byte
  346.         INX     H               ; and bump the pointer to the next spot
  347.         PUSH    H               ; save it for later
  348.         MVI     B,0             ; zero B
  349. RB0:    PUSH    B               ; save BC for later
  350.         PUSH    H               ; and HL as well
  351. RB1:    CALL    CONIN           ; go get a char from the console
  352.         ANI     7FH             ; strip the parity bit
  353.         POP     H               ; recover HL
  354.         POP     B               ; and BC
  355.         CPI     CR              ; is this character a CR?
  356.         JZ      RBEXIT          ; if so jump over
  357.         CPI     LF              ; how about a LF
  358.         JZ      RBEXIT          ; jump with that as well
  359.         CPI     BACKSP          ; do we have a backspace?
  360.         JNZ     CHKRUB          ; if not over we go
  361.         MOV     A,B             ; put B into A
  362.         ORA     A               ; is it still zero?
  363.         JZ      RB0             ; if so go get another character
  364.         DCR     B               ; if not decrement the count in B
  365.         LDA     COLUMN          ; get the column counter
  366.         STA     CTEMP1          ; save it at CTEMP1 for later
  367.         JMP     RB65            ; jump over
  368.  
  369. ; Check for Rubout (remove & echo last char.)
  370.  
  371. CHKRUB: CPI     7FH             ; do we have a rubout?
  372.         JNZ     CHKEOL          ; if not jump over
  373.         MOV     A,B             ; if so move b into A
  374.         ORA     A               ; set the flags
  375.         JZ      RB0             ; if b was zero go get another
  376.         MOV     A,M             ; get the char at (ODATA)
  377.         DCR     B               ; decrement the count in B
  378.         DCX     H               ; point back to FCB
  379.         JMP     RB10            ; jump to echo the char
  380.  
  381. ; Check for Control-E (physical end-of-line)
  382.  
  383. CHKEOL: CPI     CTRLE           ;  is it end of line?
  384.         JNZ     CKPTOG          ; jump over if not
  385.         PUSH    B               ; if so save BC
  386.         PUSH    H               ; and FCB address
  387.         CALL    CRLF            ; Turn up a new line
  388.         XRA     A               ; zero A
  389.         STA     CTEMP2          ; set it into CTEMP2
  390.         JMP     RB1             ; and go get more
  391.  
  392. ; Check for Control-P
  393.  
  394. CKPTOG: CPI     CTRLP           ; is it the print toggle
  395.         JNZ     CKBOL           ; if not jump past
  396.         PUSH    H               ; if so save FCB address
  397.         LXI     H,LSTCPY        ; get the pointer to print toggle byte
  398.         MVI     A,01H           ; put a 1 into A
  399.         SUB     M               ; subtract it from the toggle
  400.         MOV     M,A             ; and put it back
  401.         POP     H               ; recover FCB
  402.         JMP     RB0             ; and go get more
  403.  
  404. ; Check for Control-X (bacK space to beg. current line)
  405.  
  406. CKBOL:  CPI     CTRLX           ; do we back up?
  407.         JNZ     CKREML          ; if not on to the next choice
  408.         POP     H               ; if so restore the stack pointer
  409. BLOOP:  LDA     CTEMP2          ; get the byte at CTEMP2
  410.         LXI     H,COLUMN        ; and point to the column counter
  411.         CMP     M               ; are they the same?
  412.         JNC     REDBUF          ; if so go try again for input
  413.         DCR     M               ; if not decrement the CTEMP2 count
  414.         CALL    DELAST          ; delete the character there
  415.         JMP     BLOOP           ; and loop until we are done
  416.  
  417. ; check for control-U
  418.  
  419. CKREML: CPI     CTRLU           ; do we remove the line after newline?
  420.         JNZ     CKRETL          ; if not try again
  421.         CALL    LBCRLF          ; if so print a "#" and CR
  422.         POP     H               ; restore the stack
  423.         JMP     REDBUF          ; and try for input again
  424.  
  425. ; Check for Control-R (retype current line after new line)
  426.  
  427. CKRETL: CPI     CTRLR           ; want to retype?
  428.         JNZ     ECHOCC          ; if not onward for next
  429. RB65:   PUSH    B               ; if so save the count in B
  430.         CALL    LBCRLF          ; print a "#" and CRLF
  431.         POP     B               ; recover ODATA
  432.         POP     H               ; and FCB
  433.         PUSH    H               ; saving FCB again
  434.         PUSH    B               ; and ODATA
  435. RB7:    MOV     A,B             ; move the count into
  436.         ORA     A               ; see if it is zero
  437.         JZ      FIXCOL          ; if so jump over
  438.         INX     H               ; if not point to ODATA
  439.         MOV     C,M             ; pull the byte there into C
  440.         DCR     B               ; decrement the count
  441.         PUSH    B               ; save it on the stack
  442.         PUSH    H               ; and the ODATA pointer
  443.         CALL    CTLOUT          ; print it out expanding control chars
  444.         POP     H               ; recover the ODATA pointer
  445.         POP     B               ; and the count in B
  446.         JMP     RB7             ; loop until the line is out
  447.  
  448. ;fix up the column counters
  449.  
  450. FIXCOL: PUSH    H               ; save the pointer
  451.         LDA     CTEMP1          ; get CTEMP1
  452.         ORA     A               ; set the flags
  453.         JZ      RB1             ; if zero go get the next character
  454.         LXI     H,COLUMN        ; point to the column counter
  455.         SUB     M               ; subtract it from the value of CTEMP1
  456.         STA     CTEMP1          ; and save this back in CTEMP1
  457. FXLOOP: CALL    DELAST          ; delete the last character
  458.         LXI     H,CTEMP1        ; point to CTEMP1
  459.         DCR     M               ; decrement it by one
  460.         JNZ     FXLOOP          ; loop to delete all of them
  461.         JMP     RB1             ; go get the next character
  462.  
  463. ;echo the control character
  464.  
  465. ECHOCC: INX     H               ; must be some other control character
  466.         MOV     M,A             ; put the character into ODATA+1
  467.         INR     B               ; bump the count by one
  468. RB10:   PUSH    B               ; save it on the stack
  469.         PUSH    H               ; and the pointer as well
  470.         MOV     C,A             ; put the character into C
  471.         CALL    CTLOUT          ; print it out with grafic control chars
  472.         POP     H               ; recover the pointer
  473.         POP     B               ; and the count
  474.         MOV     A,M             ; put the byte at (HL) into A
  475.         CPI     CTRLC           ; is it an abort?
  476.         MOV     A,B             ; put the count into A
  477.         JNZ     RB11            ; if no abort jump over
  478.         CPI     01H             ; is the count 1?
  479.         JZ      BOOTV           ; if so boot
  480. RB11:   CMP     C               ; if not does it equal C
  481.         JC      RB0             ; if less go get another char
  482. RBEXIT: POP     H               ; recover the pointer
  483.         MOV     M,B             ; put the count in b there
  484.         MVI     C,CR            ; get a CR
  485.         JMP     CONOUT          ; and print it out
  486.  
  487. ;****
  488. ;BDOS function 1: Read console - return with byte in A
  489.  
  490. REDCON: CALL    CIECHO          ; get a char echo if printable
  491.         JMP     GOBAK           ; and go back with it
  492.  
  493. ;****
  494. ; BDOS function 3: Read reader - return with byte in A
  495.  
  496. REDRDR: CALL    READF           ; get byte from reader
  497.         JMP     GOBAK           ; and return with it
  498.  
  499. ;****
  500. ; BDOS function 6: Direct I/O
  501. ;       on entry, C=FF for input, C=char for output
  502. ;       (Book says E reg vice C)
  503. ;        appears can enter with FE or FF --- ????
  504.  
  505. ;       return with char or status in A
  506.  
  507. DIRTIO: MOV     A,C             ; Get request
  508.         INR     A               ; Test for FF=input request
  509.         JZ      INREQ           ; Skip down if input request
  510.         INR     A               ; if FF adding one will set zero flag
  511.         JZ      CONSF           ; if it was go get console status
  512.         JMP     CONOF           ; otherwise go send it out
  513.  
  514. INREQ:  CALL    CONSF           ; get console status
  515.         ORA     A               ; set flags
  516.         JZ      REXIT           ; return if none - restore first
  517.         CALL    CONIF           ; if someone is there go get it
  518.         JMP     GOBAK           ; and return with it
  519.  
  520. ;****
  521. ; BDOS function 7: get IO byte into A
  522.  
  523. GETIOB: LDA     IOBYTE          ; get the iobyte
  524.         JMP     GOBAK           ; and go back with it
  525.  
  526. ;****
  527. ; BDOS function 8: set IO byte from C into place
  528.  
  529. PUTIOB: LXI     H,IOBYTE        ; point to the iobyte
  530.         MOV     M,C             ; put the new value in from C
  531.         RET                     ; and return
  532.  
  533. ;****
  534. ; BDOS function 9: Print console buffer until '$'
  535. ;       entry string address in DE
  536.  
  537. PRNBUF: XCHG                    ; swap DE and HL - HL points to buffer
  538.         MOV     C,L             ; and get a copy
  539.         MOV     B,H             ;   of HL into BC
  540.         JMP     PRINT           ; go to the print routine
  541.  
  542. ;****
  543. ; BDOS function 11: check console status - return in A
  544.  
  545. GCSTAT: CALL    CONBRK          ; Check for abort
  546. GOBAK:  STA     ODATA           ; save result in return info byte
  547. JR:     RET                     ; and go back to caller
  548.  
  549. JR1:    MVI     A,01H           ; get a 1 for return
  550.         JMP     GOBAK           ; set it in to rinfo and return
  551.  
  552. ;****
  553. ; BDOS function 12: return version number
  554.  
  555. GETVER:
  556.         MVI     A,22H
  557.         JMP     GOBAK
  558.  
  559. ;****
  560. ; bdos exit routine
  561.  
  562. BEXIT:  LDA     OUT1            ; get the out flag for drive reset
  563.         ORA     A               ; set the flags
  564.         JZ      REXIT           ; if zero we may exit as is
  565.         LHLD    FCB             ; otherwise get the FCB address
  566.         MVI     M,0             ; put a zero into drive select byte
  567.         LDA     OLDDSK          ; get the old disk out
  568.         ORA     A               ; was it zero
  569.         JZ      REXIT           ; if so exit
  570.         MOV     M,A             ; otherwise set in the old disk byte
  571.         LDA     OUTDSK          ; get the disk to relog
  572.         STA     IDATA           ; save it for the login
  573.         CALL    LOGIN           ; go log in the old disk
  574.  
  575. REXIT:  LHLD    OLDSP           ; get the old stack pointer out
  576.         SPHL                    ; put it back in place
  577.         LHLD    ODATA           ; get the output data into place
  578.         MOV     A,L             ; put L into A
  579.         MOV     B,H             ; and H into B
  580.         RET                     ; then return from BDOS happy
  581. ;****
  582. ; hand off all higher calls to 8086 handler
  583. ;
  584. MSDOSHANDLER:
  585.         lhld    fcb         ; recover de
  586.         mov     d,h
  587.         mov     e,l
  588.         mov     c,a         ; put call back
  589.         calln   bdoshandle  ; special v20 call
  590. BDOSCALL   EQU  $-1
  591.         lhld    bdhl        ; get return
  592.         shld    odata       ; should return in hl and a
  593.         jmp     Bexit
  594. LOGIN:
  595.         lxi     h,bdbc
  596.         mvi     m,0eh  ; select the disk in a
  597.         lxi     h,bdpsw
  598.         mov     m,a
  599.         CALLN   BDOSHANDLE
  600. LOGCALL EQU     $-1
  601.         ret
  602.  
  603. ; put data at the rear
  604. ;****
  605. ; console input buffer data storage area
  606.  
  607.  
  608. ; move part of bios here
  609.  
  610. COLDBOOT:   ; should load addresses in lower memory
  611. jmp0:
  612.       ; MOVE INTERRUPT LOCATIONS INTO PLACE
  613.       ; FOR BDOS AND BIOS
  614.         LDA    BIOSHAN
  615.         STA    CMMNCALL  ; COMMON BIOS CALL HANDLER
  616.         STA    WMNCALL   ; WARMBOOT CALL HANDLER
  617.         LDA    BDOSHAN
  618.         STA    LOGCALL
  619.         STA    BDOSCALL  ; AND DO WARM BOOT
  620.  
  621. jmp1: ; warm boot
  622.      ; zero out data areas in bdos also
  623.      lxi    h,datastart
  624.      lxi    b,dataend-datastart
  625. luuu:
  626.     mov    a,b
  627.     ora    c
  628.     jz     doneit
  629.     xra    a
  630.     mov    m,a
  631.     inx    h
  632.     dcx    b
  633.     jmp    luuu
  634. doneit:
  635.      mvi    a,1
  636.      jmp    warmer
  637.  
  638. jmp2:
  639.      mvi    a,2
  640.      jmp    commonbios
  641.  
  642. jmp3:
  643.      mvi    a,3
  644.      jmp    commonbios
  645.  
  646. jmp4:
  647.      mvi    a,4
  648.      jmp    commonbios
  649.  
  650. jmp5:
  651.      mvi    a,5
  652.      jmp    commonbios
  653.  
  654. jmp6:
  655.      mvi    a,6
  656.      jmp    commonbios
  657.  
  658. jmp7:
  659.      mvi    a,7
  660.      jmp    commonbios
  661.  
  662. jmp8:
  663.      mvi    a,8
  664.      jmp    commonbios
  665.  
  666. jmp9:
  667.      mvi    a,9
  668.      jmp    commonbios
  669.  
  670. jmp10:
  671.      mvi    a,10
  672.      jmp    commonbios
  673.  
  674. jmp11:
  675.      mvi    a,11
  676.      jmp    commonbios
  677.  
  678. jmp12:
  679.      mvi    a,12
  680.      jmp    commonbios
  681.  
  682. jmp13:
  683.      mvi    a,13
  684.      jmp    commonbios
  685.  
  686. jmp14:
  687.      mvi    a,14
  688.      jmp    commonbios
  689.  
  690. jmp15:
  691.      mvi    a,15
  692.      jmp    commonbios
  693.  
  694. jmp16:
  695.      mvi    a,16
  696.      jmp    commonbios
  697.  
  698. FILLEND EQU     $
  699.  
  700.           ORG   SERIAL + 500H;
  701. BIOS:
  702. COLD:     jmp     coldboot
  703. WBOOTF:   jmp     jmp1   ; do dos call to load the ccp again
  704.                          ; under CP/M-86, could reinitialize BDOS
  705. CONSF:    jmp     jmp2   ; CONSOLE STATUS
  706. CONIF:    jmp     jmp3   ; conin
  707. CONOF:    jmp     jmp4   ; Conout
  708. LISTF:    jmp     jmp5   ; list
  709. PUNF:     jmp     jmp6   ; punch
  710. READF:    jmp     jmp7   ; reader
  711.  
  712. ;the following (except for listst) are not implemented
  713. ;and will warm boot the CP/M-80 system
  714.  
  715. HOMF:  jmp     jmp8    ; notimpl; home
  716. SELF:  jmp     jmp9    ; notimpl; seldsk
  717. TRKF:  jmp     jmp10   ; notimpl; settrk
  718. SECF:  jmp     jmp11   ; notimpl; setdsk
  719. DMAF:  jmp     jmp12   ; setdma
  720. DRDF:  jmp     jmp13   ; notimpl; read
  721. DWRF:  jmp     jmp14   ; notimpl; write
  722. LISTS: jmp     jmp15   ; listst ;
  723. SECTRN:jmp     jmp16   ; sectran
  724.  
  725. ; pass all bios calls onto the turbo handler
  726. ; wipes out a,bc,hl
  727.  
  728. breakout:    ; return permanently to 8086 mode where we left with BRKEM
  729.      RETEM   ; to whence it came
  730.  
  731. commonbios: ; call 8088 code
  732.      sta    bpsw           ; show call
  733.      lda    abortflag      ; TEST FOR ABORT
  734.      ora    a
  735.      jnz    breakout
  736. ; most cp/m bios routines only use bc
  737. ; disk routines may use more, but not implemented here
  738.      mov    h,b
  739.      mov    l,c
  740.      shld   bbc
  741.      CALLN  BIOSHANDLE     ; go to turbo handler and do it
  742. cmmncall EQU  $-1
  743.      lhld   bhl            ; bios returns in a and hl
  744.      lda    bpsw
  745.      ret                   ; this one not used usually
  746.  
  747. warmer:
  748.      sta    bpsw           ; show call
  749.      lda    abortflag      ; TEST FOR ABORT
  750.      ora    a
  751.      jnz    breakout
  752.      CALLN   BIOSHANDLE
  753. WMNCALL      EQU   $-1
  754.      LXI     SP,CPMSTACK
  755.      LHLD    BHL           ; get the address
  756.      PCHL                  ; and jump
  757.  
  758. codeend equ  $
  759.      org     0ff80h;
  760.  
  761. cpmstack:   dw   0
  762.  
  763.      ORG     0FFB0H
  764.  
  765. COLDHAN:     DB    80H
  766. CCPHAN:      DB    81H
  767. BDOSHAN:     DB    82H
  768. BIOSHAN:     DB    83H
  769.  
  770.      org     0ffc0h;
  771. ccpreg:
  772. ccppsw:   dw    0       ;ax
  773. ccphl:    dw    0       ;bx
  774. ccpbc:    dw    0       ;cx
  775. ccpde:    dw    0       ;dx
  776.  
  777.           org   0ffd0h
  778. bpsw:     dw    0   ;ax
  779. bhl:      dw    0   ;bx
  780. bbc:      dw    0   ;cx
  781. bde:      dw    0   ;dx
  782.  
  783.          org   0ffe0h
  784. BDOSreg:
  785. bdpsw:   dw    0   ;ax
  786. bdhl:    dw    0   ;bx
  787. bdbc:    dw    0   ;cx
  788. bdde:    dw    0   ;dx
  789.  
  790.          org   0ffffh;
  791. abortflag:  db   0;  non-zero aborts
  792. biosend EQU $
  793.  
  794.      end    ; stub bdos-bios
  795.