home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / sampler0 / comdebug.asm < prev    next >
Assembly Source File  |  1987-01-28  |  22KB  |  1,217 lines

  1.             title  COMDEBUG.ASM
  2.             page   55, 132    
  3.  
  4.  
  5. COMMENT!
  6.  
  7. Written by Peter Shier at TADIRAN Givat Shmuel January 1987
  8.  
  9. This program is a RAM resident serial communications status monitor. It is
  10. installed by typing
  11.  
  12.     COMDEBUG
  13.  
  14. at the dos prompt. To activate press ALT + Scroll Lock. The state of modem
  15. status, line status and modem control registers is displayed. The DTR line is 
  16. highlighted in reverse video and this is considered to be the "cursor"
  17. position. The following keys are now active:
  18.  
  19. 1/0                    Raise/lower the line highlighted by the cursor
  20.  
  21. D                    Display registers
  22.  
  23. Left/right arrows   Move cursor between DTR and RTS
  24.  
  25. C                   Change com port no.  
  26.  
  27. Esc                 Exit
  28.  
  29.  
  30. Com ports 1 to 10 are supported. COM1 and COM2 are at their usual addresses.
  31. (i.e. COM1 at 3F8H and COM2 at 2F8H). COM3 - COM10 start at BASE_ADDRESS and
  32. have a distance between them of PORT_DISPLACEMENT.
  33.  
  34. !
  35.  
  36.  
  37.  
  38.  
  39. push_all    macro
  40.             
  41.             push    ax
  42.             push    bx
  43.             push    cx
  44.             push    dx
  45.             push    di
  46.             push    si
  47.             push    bp
  48.             push    ds
  49.             push    es
  50.             pushf
  51.             endm
  52.  
  53. pop_all        macro
  54.  
  55.             popf
  56.             pop        es
  57.             pop        ds
  58.             pop        bp
  59.             pop        si
  60.             pop        di
  61.             pop        dx
  62.             pop        cx
  63.             pop        bx
  64.             pop        ax
  65.             endm
  66.             
  67.             
  68.  
  69.  
  70. TRUE  equ 1
  71. FALSE equ 0
  72.  
  73. ESC            equ    1
  74. D            equ    32
  75. C            equ    46
  76. ONE            equ    2
  77. NUM_ONE        equ    79
  78. ZERO        equ    11
  79. NUM_ZERO    equ    82
  80. LEFT        equ    75
  81. RIGHT        equ    77
  82.  
  83. ALT_SHIFT        equ 08h
  84. SCROLL_SHIFT    equ    10h
  85.  
  86. KB_DATA    equ 60h
  87. KB_CTL    equ    61h
  88.  
  89.  
  90. ON    equ    1
  91. OFF equ    0
  92.  
  93. REV_VIDEO    EQU    70H         ; video attributes for display routines
  94. NORM_VIDEO    EQU    07H
  95. BOLD        EQU 0FH
  96. BOLD_UNDERL EQU 09H
  97. BLINK        EQU 87H
  98.  
  99.  
  100.  
  101. ;-------------------------- for special adapter cards to add COM ports
  102.  
  103. BASE_ADDRESS        equ    280h    ; base address of card i.e. COM3
  104. PORT_DISPLACEMENT    equ 8       ; offset from COMn to COMn + 1 for card
  105. MCONT                equ 4
  106. LSTAT                equ 5
  107. MSTAT                equ 6
  108.  
  109.  
  110.  
  111.  
  112.  
  113. ;--------------------- modem status
  114.  
  115. D_CTS    equ    01h
  116. D_DSR    equ    02h
  117. TERI    equ    04h
  118. D_RLSD    equ    08h
  119. CTS        equ    10h
  120. DSR        equ    20h
  121. RI        equ    40h
  122. RLSD    equ    80h
  123.  
  124.  
  125.  
  126. ;-------------------- line status
  127.  
  128. DATA_READY    equ    01h
  129. OVERRUN        equ    02h
  130. PARITY        equ    04h
  131. FRAMING        equ    08h
  132. BREAK        equ    10h
  133. THRE        equ    20h
  134. TSRE        equ    40h
  135.  
  136.  
  137.  
  138. ;-------------------- modem control
  139.  
  140. DTR        equ    01h
  141. RTS        equ    02h
  142.  
  143.  
  144.  
  145. code     segment
  146.         assume cs:code, ds:code, es:code, ss:code
  147.             org        100h
  148.  
  149. first:
  150.             jmp     loader
  151.             ;jmp    tester
  152.  
  153. ASCII_signature        db "COMDEBUG by Peter Shier at TADIRAN Givat Shmuel 01/87"
  154.  
  155. busy                db    FALSE
  156. old_int9_off        dw    0
  157. old_int9_seg        dw    0
  158. graphics            db    FALSE
  159. video_ram             dw     0     ; video ram segment
  160. crt_status_port      dw     0
  161. crt_control_port     dw     0
  162. start_offset         dw     0      ; beginning offset in screen seg. for PRINTAT
  163. str_ptr                 dw     0      ; pointer to ASCIIZ string to print
  164. row                     db    0      ; row, col to print at
  165. col                     db    0
  166. attribute             db    0      ; desired attribute
  167. screen_storage       db     4000 dup(?) ;temp storage for screen contents
  168. modem_control        dw    03fch
  169. line_status            dw    03fdh
  170. modem_status        dw    03feh
  171. port                db    '01', 0
  172. cursor                db    DTR
  173. bit                    db    ?, 0
  174. saved_cursor_pos    dw    ?
  175.  
  176.  
  177. main_frame_msg    db " C O M D E B U G ", 0
  178. main_frame_1     db "╔════════════════════════════════════════════════════════════════════╗", 0
  179. main_frame_2     db "║                                                                    ║", 0
  180. main_frame_3     db "╚════════════════════════════════════════════════════════════════════╝", 0
  181.  
  182. mod_stat_msg_1   db " Modem Status ", 0
  183. mod_stat_msg_2   db "Delta CTS  Delta DSR  TERI  Delta RLSD  CTS  DSR  RI  RLSD", 0
  184. mod_stat_frame_1 db "┌──────────────────────────────────────────────────────────┐", 0
  185. mod_stat_frame_2 db "│                                                          │", 0
  186. mod_stat_frame_3 db "└──────────────────────────────────────────────────────────┘", 0
  187.  
  188. lin_stat_msg_1     db " Line  Status ", 0
  189. lin_stat_msg_2   db "Data Ready  Overrun  Parity  Framing  Break  THRE  TSRE", 0
  190. lin_stat_frame_1 db "┌────────────────────────────────────────────────────────┐", 0
  191. lin_stat_frame_2 db "│                                                        │", 0
  192. lin_stat_frame_3 db "└────────────────────────────────────────────────────────┘", 0
  193.  
  194. mod_ctrl_msg_1   db "Mod Ctrl", 0
  195. mod_Ctrl_msg_2   db "DTR  RTS", 0
  196. mod_ctrl_frame_1 db "┌────────┐", 0
  197. mod_ctrl_frame_2 db "│        │", 0
  198. mod_ctrl_frame_3 db "└────────┘", 0
  199.  
  200. instruct_msg_1 db "<- ->  Move cursor", 0
  201. instruct_msg_2 db "D  Display registers", 0
  202. instruct_msg_3 db "1/0  Raise/lower DTR/RTS", 0
  203. instruct_msg_4 db "C  Change com port", 0
  204. instruct_msg_5 db "Esc  Exit", 0
  205. instruct_msg_6 db "Com port = ", 0
  206.  
  207.  
  208.  
  209. tester        proc    near
  210.  
  211.             call    get_video_mode
  212.             call    display_screen
  213. t_10:
  214.             mov        ah, 0
  215.             int        16h
  216.             cmp        al, 1bh
  217.             jne        t_15
  218.             ret
  219. t_15:
  220.             xchg    al, ah
  221.             call    com_debug
  222.             jmp        t_10
  223.  
  224. tester        endp
  225.  
  226.  
  227. new_int9:
  228.             sti
  229.             push_all
  230.  
  231.             push    cs
  232.             pop        ds
  233.  
  234.             cmp        busy, TRUE
  235.             je        now_busy
  236.             pushf
  237.             call    dword ptr old_int9_off
  238.             mov        ax, 40h
  239.             mov        es, ax
  240.             test    byte ptr es:[17h], ALT_SHIFT
  241.             jz        done
  242.             test    byte ptr es:[18h], SCROLL_SHIFT
  243.             jz        done
  244.             mov        busy, TRUE
  245.             mov        al, ALT_SHIFT
  246.             not        al
  247.             and        byte ptr es:[17h], al
  248.             mov        al, SCROLL_SHIFT
  249.             not        al
  250.             and        byte ptr es:[18h], al
  251.             call    save_screen
  252.             call    save_cursor
  253. done:
  254.             pop_all
  255.             iret
  256.  
  257. now_busy:
  258.             call    get_scan_code     ; returns scan code in al
  259.             cmp        al, 80h
  260.             jae        eoi
  261.             cmp        al, ESC
  262.             jne        still_on
  263.             call    restore_screen
  264.             call    restore_cursor
  265.             mov        busy, FALSE
  266.             jmp        eoi
  267. still_on:
  268.             call    com_debug      ; recieves scan code in al
  269. eoi:
  270.             mov        al, 20h
  271.             out        20h, al
  272.             pop_all
  273.             iret
  274.  
  275.  
  276.  
  277.  
  278.  
  279. get_scan_code    proc    near
  280.     
  281.             in        al, KB_DATA
  282.             push    ax
  283.             in        al, KB_CTL
  284.             mov        ah, al
  285.             or        al, 80h
  286.             out        KB_CTL, al
  287.             xchg    ah, al
  288.             out        KB_CTL, al
  289.             pop        ax
  290.             ret
  291.             
  292. get_scan_code    endp
  293.  
  294.  
  295.  
  296.  
  297. save_cursor        proc    near
  298.  
  299.             mov        ah, 03h
  300.             mov        bh, 00h
  301.             int        10h
  302.             mov        saved_cursor_pos, dx
  303.  
  304.             mov        ah, 02h
  305.             mov        bh, 00h
  306.             mov        dh, 25
  307.             mov        dl, 0
  308.             int        10h
  309.             ret
  310.  
  311. save_cursor        endp
  312.  
  313.  
  314.  
  315. restore_cursor        proc    near
  316.  
  317.             mov        ah, 02h
  318.             mov        bh, 00h
  319.             mov        dx, saved_cursor_pos
  320.             int        10h
  321.             ret
  322.  
  323. restore_cursor        endp
  324.  
  325.  
  326. com_debug     proc    near
  327.  
  328. ; recieves scan code in al
  329.  
  330.             cmp        al, D
  331.             jne        cd_10
  332.             call    display_modem_status
  333.             call    display_line_status
  334.             call    display_modem_control
  335.             ret
  336. cd_10:
  337.             cmp        al, C
  338.             jne        cd_20
  339.             call    change_port
  340.             call    display_port
  341.             call    display_modem_status
  342.             call    display_line_status
  343.             call    display_modem_control
  344.             ret
  345. cd_20:
  346.             cmp        al, ONE
  347.             je        cd_30
  348.             cmp        al, NUM_ONE
  349.             jne        cd_40
  350. cd_30:
  351.             mov        ah, cursor
  352.             mov        bh, ON
  353.             call    set_modem_control
  354.             call    display_modem_control
  355.             ret
  356. cd_40:
  357.             cmp        al, ZERO
  358.             je        cd_50
  359.             cmp        al, NUM_ZERO
  360.             jne        cd_60
  361. cd_50:
  362.             mov        ah, cursor
  363.             mov        bh, OFF
  364.             call    set_modem_control
  365.             call    display_modem_control
  366.             ret
  367. cd_60:
  368.             cmp        al, LEFT
  369.             je        cd_70
  370.             cmp        al, RIGHT
  371.             jne        cd_100
  372. cd_70:
  373.             cmp        cursor, DTR
  374.             jne        cd_80
  375.             mov        cursor, RTS
  376.             jmp        cd_90
  377. cd_80:
  378.             mov        cursor, DTR
  379. cd_90:
  380.             call    display_modem_control
  381.             ret
  382. cd_100:
  383.             mov        ah, 0eh
  384.             mov        al, 07h
  385.             int        10h
  386.             ret
  387.  
  388. com_debug    endp
  389.  
  390.  
  391.  
  392.  
  393.  
  394. change_port        proc    near
  395.  
  396.  
  397. ; 'C' was pressed - must change all register addresses to those of next port
  398.  
  399.             cmp        port + 1, '1'             ; was port 1?
  400.             jne        cp_10                     ; no - check for 10
  401.             mov        modem_control, 02fch      ; yes - set addresses for COM2
  402.             mov        line_status,   02fdh      
  403.             mov        modem_status,  02feh
  404.             inc        port + 1                  ; set display digit
  405.             ret                               ; and done
  406. cp_10:
  407.             cmp        port, '1'                 ; was port 10?
  408.             jne        cp_20                     ; no - check for 2
  409.             mov        port + 1, '1'             ; yes - set up for COM1
  410.             mov        port, '0'
  411.             mov        modem_control, 03fch
  412.             mov        line_status,   03fdh
  413.             mov        modem_status,  03feh
  414.             ret
  415. cp_20:
  416.  
  417.             cmp        port + 1, '2'                       ; was port 2?
  418.             jne        cp_30                               ; no - must be 3 - 10
  419.             inc        port + 1                            ; yes - set up for COM3
  420.             mov        modem_control, BASE_ADDRESS + MCONT
  421.             mov        line_status,   BASE_ADDRESS + LSTAT
  422.             mov        modem_status,  BASE_ADDRESS + MSTAT
  423.             ret
  424. cp_30:
  425.             inc        port + 1                 ; port was 3 - 10          
  426.             cmp        port + 1, 3ah            ; is this 10?
  427.             jne        cp_40                    ; no - set addresses
  428.             mov        port, '1'                ; yes - fix up display
  429.             mov        port + 1, '0'
  430. cp_40:
  431.             add        modem_control, PORT_DISPLACEMENT  ; just increment present
  432.             add        line_status, PORT_DISPLACEMENT    ; values
  433.             add        modem_status, PORT_DISPLACEMENT
  434.             ret
  435.  
  436.  
  437. change_port        endp
  438.  
  439.  
  440.  
  441.  
  442.  
  443. display_screen     proc    near
  444.  
  445.  
  446.             mov        str_ptr, offset main_frame_1
  447.             mov        row, 2
  448.             mov        col, 5
  449.             mov        attribute, BOLD
  450.             call    printat
  451.             
  452.             mov        cx, 19
  453.             mov        row, 3
  454. main_loop:
  455.             push    cx
  456.             mov        str_ptr, offset main_frame_2
  457.             mov        col, 5
  458.             mov        attribute, BOLD
  459.             call    printat
  460.             pop        cx
  461.             inc        row
  462.             loop    main_loop
  463.  
  464.             mov        str_ptr, offset main_frame_3
  465.             mov        row, 21
  466.             mov        col, 5
  467.             mov        attribute, BOLD
  468.             call    printat
  469.  
  470.             mov        str_ptr, offset main_frame_msg
  471.             mov        row, 2
  472.             mov        col, 30
  473.             mov        attribute, REV_VIDEO
  474.             call    printat
  475.  
  476.             mov        str_ptr, offset mod_stat_frame_1
  477.             mov        row, 4
  478.             mov        col, 9
  479.             mov        attribute, BOLD
  480.             call    printat
  481.             
  482.             mov        cx, 3
  483.             mov        row, 5
  484.  
  485. mod_stat_loop:
  486.  
  487.             push    cx
  488.             mov        str_ptr, offset mod_stat_frame_2
  489.             mov        col, 9
  490.             mov        attribute, BOLD
  491.             call    printat
  492.             pop        cx
  493.             inc        row
  494.             loop    mod_stat_loop
  495.  
  496.             mov        str_ptr, offset mod_stat_frame_3
  497.             mov        row, 8
  498.             mov        col, 9
  499.             mov        attribute, BOLD
  500.             call    printat
  501.  
  502.             mov        row, 4
  503.             mov        col, 31
  504.             mov        str_ptr, offset mod_stat_msg_1
  505.             mov        attribute, REV_VIDEO
  506.             call    printat
  507.  
  508.             mov        row, 6
  509.             mov        col, 10
  510.             mov        str_ptr, offset mod_stat_msg_2
  511.             mov        attribute, BOLD
  512.             call    printat
  513.  
  514.  
  515.  
  516.             mov        str_ptr, offset lin_stat_frame_1
  517.             mov        row, 9
  518.             mov        col, 10
  519.             mov        attribute, BOLD
  520.             call    printat
  521.             
  522.             mov        cx, 3
  523.             mov        row, 10
  524.  
  525. lin_stat_loop:
  526.  
  527.             push    cx
  528.             mov        str_ptr, offset lin_stat_frame_2
  529.             mov        col, 10
  530.             mov        attribute, BOLD
  531.             call    printat
  532.             pop        cx
  533.             inc        row
  534.             loop    lin_stat_loop
  535.  
  536.             mov        str_ptr, offset lin_stat_frame_3
  537.             mov        row, 13
  538.             mov        col, 10
  539.             mov        attribute, BOLD
  540.             call    printat
  541.  
  542.             mov        row, 9
  543.             mov        col, 31
  544.             mov        str_ptr, offset lin_stat_msg_1
  545.             mov        attribute, REV_VIDEO
  546.             call    printat
  547.  
  548.             mov        row, 11
  549.             mov        col, 11
  550.             mov        str_ptr, offset lin_stat_msg_2
  551.             mov        attribute, BOLD
  552.             call    printat
  553.  
  554.  
  555.             mov        str_ptr, offset mod_ctrl_frame_1
  556.             mov        row, 15
  557.             mov        col, 10
  558.             mov        attribute, BOLD
  559.             call    printat
  560.             
  561.             mov        cx, 3
  562.             mov        row, 16
  563.  
  564. mod_ctrl_loop:
  565.  
  566.             push    cx
  567.             mov        str_ptr, offset mod_ctrl_frame_2
  568.             mov        col, 10
  569.             mov        attribute, BOLD
  570.             call    printat
  571.             pop        cx
  572.             inc        row
  573.             loop    mod_ctrl_loop
  574.  
  575.             mov        str_ptr, offset mod_ctrl_frame_3
  576.             mov        row, 19
  577.             mov        col, 10
  578.             mov        attribute, BOLD
  579.             call    printat
  580.  
  581.             mov        row, 15
  582.             mov        col, 11
  583.             mov        str_ptr, offset mod_ctrl_msg_1
  584.             mov        attribute, REV_VIDEO
  585.             call    printat
  586.  
  587.             mov        row, 17
  588.             mov        col, 11
  589.             mov        str_ptr, offset mod_ctrl_msg_2
  590.             mov        attribute, BOLD
  591.             call    printat
  592.  
  593.             mov        row, 16
  594.             mov        col, 28
  595.             mov        str_ptr, offset instruct_msg_1
  596.             mov        attribute, BOLD
  597.             call    printat
  598.             
  599.             mov        row, 17
  600.             mov        col, 32
  601.             mov        str_ptr, offset instruct_msg_2
  602.             mov        attribute, BOLD
  603.             call    printat
  604.  
  605.             mov        row, 18
  606.             mov        col, 30
  607.             mov        str_ptr, offset instruct_msg_3
  608.             mov        attribute, BOLD
  609.             call    printat
  610.  
  611.             mov        row, 19
  612.             mov        col, 32
  613.             mov        str_ptr, offset instruct_msg_4
  614.             mov        attribute, BOLD
  615.             call    printat
  616.  
  617.             mov        row, 20
  618.             mov        col, 30
  619.             mov        str_ptr, offset instruct_msg_5
  620.             mov        attribute, BOLD
  621.             call    printat
  622.  
  623.             mov        row, 16
  624.             mov        col, 59
  625.             mov        str_ptr, offset instruct_msg_6
  626.             mov        attribute, BOLD
  627.             call    printat
  628.  
  629.             call    display_port
  630.             call    display_modem_status
  631.             call    display_line_status
  632.             call    display_modem_control
  633.             
  634.  
  635.             ret
  636.  
  637. display_screen     endp
  638.  
  639.  
  640.  
  641.  
  642.  
  643. display_modem_status    proc    near
  644.  
  645.             mov        dx, modem_status
  646.             in        al, dx
  647.             
  648.             test    al, D_CTS
  649.             jz        dms_10
  650.             mov        bit, '1'
  651.             jmp        dms_20
  652. dms_10:
  653.             mov        bit, '0'
  654. dms_20:
  655.             mov        row, 7
  656.             mov        col, 14
  657.             mov        attribute, NORM_VIDEO
  658.             mov        str_ptr, offset bit
  659.             push    ax
  660.             call    printat
  661.             pop        ax
  662.             
  663.             test    al, D_DSR
  664.             jz        dms_30
  665.             mov        bit, '1'
  666.             jmp        dms_40
  667. dms_30:
  668.             mov        bit, '0'
  669. dms_40:
  670.             mov        row, 7
  671.             mov        col, 26
  672.             mov        attribute, NORM_VIDEO
  673.             mov        str_ptr, offset bit
  674.             push    ax
  675.             call    printat
  676.             pop        ax
  677.  
  678.             test    al, TERI 
  679.             jz        dms_50
  680.             mov        bit, '1'
  681.             jmp        dms_60
  682. dms_50:
  683.             mov        bit, '0'
  684. dms_60:
  685.             mov        row, 7
  686.             mov        col, 33
  687.             mov        attribute, NORM_VIDEO
  688.             mov        str_ptr, offset bit
  689.             push    ax
  690.             call    printat
  691.             pop        ax
  692.  
  693.             test    al, D_RLSD
  694.             jz        dms_70
  695.             mov        bit, '1'
  696.             jmp        dms_80
  697. dms_70:
  698.             mov        bit, '0'
  699. dms_80:
  700.             mov        row, 7
  701.             mov        col, 42
  702.             mov        attribute, NORM_VIDEO
  703.             mov        str_ptr, offset bit
  704.             push    ax
  705.             call    printat
  706.             pop        ax
  707.  
  708.             test    al, CTS
  709.             jz        dms_90
  710.             mov        bit, '1'
  711.             jmp        dms_100
  712. dms_90:
  713.             mov        bit, '0'
  714. dms_100:
  715.             mov        row, 7
  716.             mov        col, 51
  717.             mov        attribute, NORM_VIDEO
  718.             mov        str_ptr, offset bit
  719.             push    ax
  720.             call    printat
  721.             pop        ax
  722.  
  723.             test    al, DSR
  724.             jz        dms_110
  725.             mov        bit, '1'
  726.             jmp        dms_120
  727. dms_110:
  728.             mov        bit, '0'
  729. dms_120:
  730.             mov        row, 7
  731.             mov        col, 56
  732.             mov        attribute, NORM_VIDEO
  733.             mov        str_ptr, offset bit
  734.             push    ax
  735.             call    printat
  736.             pop        ax
  737.  
  738.             test    al, RI
  739.             jz        dms_130
  740.             mov        bit, '1'
  741.             jmp        dms_140
  742. dms_130:
  743.             mov        bit, '0'
  744. dms_140:
  745.             mov        row, 7
  746.             mov        col, 60
  747.             mov        attribute, NORM_VIDEO
  748.             mov        str_ptr, offset bit
  749.             push    ax
  750.             call    printat
  751.             pop        ax
  752.  
  753.             test    al, RLSD
  754.             jz        dms_150
  755.             mov        bit, '1'
  756.             jmp        dms_160
  757. dms_150:
  758.             mov        bit, '0'
  759. dms_160:
  760.             mov        row, 7
  761.             mov        col, 65
  762.             mov        attribute, NORM_VIDEO
  763.             mov        str_ptr, offset bit
  764.             call    printat
  765.  
  766.             ret
  767.  
  768. display_modem_status    endp
  769.  
  770.  
  771.  
  772. display_modem_control    proc    near
  773.  
  774.             mov        dx, modem_control
  775.             in        al, dx
  776.             
  777.             test    al, DTR
  778.             jz        dmc_10
  779.             mov        bit, '1'
  780.             jmp        dmc_20
  781. dmc_10:
  782.             mov        bit, '0'
  783. dmc_20:
  784.             cmp        cursor, DTR
  785.             jne        dmc_30
  786.             mov        attribute, REV_VIDEO
  787.             jmp        dmc_40
  788. dmc_30:
  789.             mov        attribute, NORM_VIDEO
  790. dmc_40:
  791.             mov        row, 18
  792.             mov        col, 12
  793.             mov        str_ptr, offset bit
  794.             push    ax
  795.             call    printat
  796.             pop        ax
  797.             
  798.             test    al, RTS
  799.             jz        dmc_50
  800.             mov        bit, '1'
  801.             jmp        dmc_60
  802. dmc_50:
  803.             mov        bit, '0'
  804. dmc_60:
  805.             cmp        cursor, RTS
  806.             jne        dmc_70
  807.             mov        attribute, REV_VIDEO
  808.             jmp        dmc_80
  809. dmc_70:
  810.             mov        attribute, NORM_VIDEO
  811. dmc_80:
  812.             mov        row, 18
  813.             mov        col, 17
  814.             mov        str_ptr, offset bit
  815.             call    printat
  816.  
  817.             ret
  818.  
  819. display_modem_control    endp
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826. set_modem_control    proc    near
  827.  
  828. ; recieves mask in ah, change flag in bh
  829.  
  830.             mov        dx, modem_control
  831.             in        al, dx
  832.  
  833.             cmp        bh, ON
  834.             jne        smc_10
  835.             or        al, ah
  836.             jmp        smc_20
  837. smc_10:
  838.             not        ah
  839.             and        al, ah
  840. smc_20:
  841.             out        dx, al
  842.             ret
  843.  
  844. set_modem_control    endp
  845.  
  846.  
  847.  
  848.  
  849.  
  850. display_line_status    proc    near
  851.  
  852.             mov        dx, line_status
  853.             in        al, dx
  854.             
  855.             test    al, DATA_READY
  856.             jz        dls_10
  857.             mov        bit, '1'
  858.             jmp        dls_20
  859. dls_10:
  860.             mov        bit, '0'
  861. dls_20:
  862.             mov        row, 12
  863.             mov        col, 15
  864.             mov        attribute, NORM_VIDEO
  865.             mov        str_ptr, offset bit
  866.             push    ax
  867.             call    printat
  868.             pop        ax
  869.             
  870.             test    al, OVERRUN
  871.             jz        dls_30
  872.             mov        bit, '1'
  873.             jmp        dls_40
  874. dls_30:
  875.             mov        bit, '0'
  876. dls_40:
  877.             mov        row, 12
  878.             mov        col, 26
  879.             mov        attribute, NORM_VIDEO
  880.             mov        str_ptr, offset bit
  881.             push    ax
  882.             call    printat
  883.             pop        ax
  884.  
  885.             test    al, PARITY 
  886.             jz        dls_50
  887.             mov        bit, '1'
  888.             jmp        dls_60
  889. dls_50:
  890.             mov        bit, '0'
  891. dls_60:
  892.             mov        row, 12
  893.             mov        col, 34
  894.             mov        attribute, NORM_VIDEO
  895.             mov        str_ptr, offset bit
  896.             push    ax
  897.             call    printat
  898.             pop        ax
  899.  
  900.             test    al, FRAMING
  901.             jz        dls_70
  902.             mov        bit, '1'
  903.             jmp        dls_80
  904. dls_70:
  905.             mov        bit, '0'
  906. dls_80:
  907.             mov        row, 12
  908.             mov        col, 43
  909.             mov        attribute, NORM_VIDEO
  910.             mov        str_ptr, offset bit
  911.             push    ax
  912.             call    printat
  913.             pop        ax
  914.  
  915.             test    al, BREAK
  916.             jz        dls_90
  917.             mov        bit, '1'
  918.             jmp        dls_100
  919. dls_90:
  920.             mov        bit, '0'
  921. dls_100:
  922.             mov        row, 12
  923.             mov        col, 51
  924.             mov        attribute, NORM_VIDEO
  925.             mov        str_ptr, offset bit
  926.             push    ax
  927.             call    printat
  928.             pop        ax
  929.  
  930.             test    al, THRE
  931.             jz        dls_110
  932.             mov        bit, '1'
  933.             jmp        dls_120
  934. dls_110:
  935.             mov        bit, '0'
  936. dls_120:
  937.             mov        row, 12
  938.             mov        col, 57
  939.             mov        attribute, NORM_VIDEO
  940.             mov        str_ptr, offset bit
  941.             push    ax
  942.             call    printat
  943.             pop        ax
  944.  
  945.             test    al, TSRE
  946.             jz        dls_130
  947.             mov        bit, '1'
  948.             jmp        dls_140
  949. dls_130:
  950.             mov        bit, '0'
  951. dls_140:
  952.             mov        row, 12
  953.             mov        col, 63
  954.             mov        attribute, NORM_VIDEO
  955.             mov        str_ptr, offset bit
  956.             call    printat
  957.  
  958.             ret
  959.  
  960. display_line_status    endp
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973. display_port    proc    near
  974.  
  975.             mov        row, 16
  976.             mov        col, 70
  977.             mov        str_ptr, offset port
  978.             mov        attribute, BOLD
  979.             call    printat
  980.             ret
  981.  
  982. display_port    endp
  983.  
  984.  
  985. save_screen proc near
  986.  
  987. ;----------------------------------------------------------------------------
  988. ; this procedure stores the entire contents of the video ram buffer to a safe
  989. ; place
  990. ;----------------------------------------------------------------------------
  991.     
  992.     mov        dx, crt_control_port
  993.  
  994.     cld
  995.     push ds
  996.     push ds
  997.     pop es
  998.     mov di, offset screen_storage
  999.     mov ax, video_ram
  1000.     mov ds, ax
  1001.     ;cmp ax, 0b800h
  1002.     ;jne save_10
  1003.     
  1004.     push    es
  1005.     mov        ax, 40h
  1006.     mov        es, ax
  1007.     mov        al, es:[65h]
  1008.     mov        bh, al
  1009.     and        al, 0f7h
  1010.     out        dx, al
  1011.     pop        es
  1012.  
  1013.  
  1014. save_10:
  1015.  
  1016.     mov si, 0
  1017.     mov cx, 2000
  1018.     rep movsw
  1019.     
  1020.     pop ds
  1021.     ;cmp        video_ram, 0b800h
  1022.     ;jne        save_20
  1023.     mov        al, bh
  1024.     push    ax
  1025.     push    dx
  1026.     call    display_screen
  1027.     pop        dx
  1028.     pop        ax
  1029.     out        dx, al
  1030.  
  1031. save_20:
  1032.  
  1033.     ret
  1034.  
  1035. save_screen endp
  1036.  
  1037.  
  1038.  
  1039.  
  1040. restore_screen proc near
  1041.     
  1042. ;----------------------------------------------------------------------------
  1043. ; procedure to restore original contents of video ram
  1044. ;----------------------------------------------------------------------------
  1045.  
  1046.     cld
  1047.     push ds
  1048.     pop es
  1049.     mov si, offset screen_storage
  1050.     mov ax, video_ram
  1051.     mov es, ax
  1052.     cmp ax, 0b800h
  1053.     jne res_10
  1054.  
  1055.     push    es
  1056.     mov        dx, crt_control_port
  1057.     mov        ax, 40h
  1058.     mov        es, ax
  1059.     mov        al, es:[65h]
  1060.     mov        bh, al
  1061.     and        al, 0f7h
  1062.     out        dx, al
  1063.     pop        es
  1064.  
  1065. res_10:
  1066.  
  1067.     mov di, 0
  1068.     mov cx, 2000
  1069.     rep movsw
  1070.     cmp    video_ram, 0b800h
  1071.     jne    res_20
  1072.     mov    al, bh
  1073.     out    dx, al
  1074.  
  1075. res_20:
  1076.  
  1077.     ret
  1078.  
  1079. restore_screen endp
  1080.  
  1081.  
  1082.  
  1083.  
  1084. printat proc near
  1085.  
  1086. ;----------------------------------------------------------------------------
  1087. ; procedure to write an asciiz string to video ram. printat gets its 
  1088. ; parameters from the following variables:
  1089. ;
  1090. ; str_ptr   dw  pointer to asciiz string to display
  1091. ; row       db  row to display at  (0 - 24)
  1092. ; col       db  column to display at  (0 - 79)
  1093. ; attribute db  attribute to display with
  1094. ;
  1095. ; The caller need only fill these variables and then call printat. A variable
  1096. ; video_ram dw ? must also be present and contain the segment of the video ram.
  1097. ;----------------------------------------------------------------------------
  1098.             
  1099.             xor        ax, ax
  1100.             mov        al, row                ; calculate relative
  1101.             mov     cl, 80              ; offset of starting position
  1102.             mul        cl                  ; from start of video ram 
  1103.             xor     bh, bh
  1104.             mov        bl, col
  1105.             add        ax, bx        
  1106.             shl        ax, 1                ; offset = ((row x 80) + col) * 2
  1107.             mov        di, ax              ; di will index video ram
  1108.  
  1109.             
  1110.             mov        bx, video_ram       ; initialize es to video ram
  1111.             mov        es, bx
  1112.             mov        ah, attribute         ; ah = attribute
  1113.             mov        bx, str_ptr          ; bx = pointer to string
  1114.             mov        si, 00               ; si will index string
  1115.             mov      dx, crt_status_port
  1116.  
  1117. printat_10:
  1118.             cmp        byte ptr ds:[bx + si], 0    ; is this null byte?
  1119.             je        printat_20                  ; yes - all done
  1120.             mov        cl, byte ptr ds:[bx + si]   ; no - enter byte
  1121. wait_1:
  1122.             in        al, dx
  1123.             test    al, 1
  1124.             jnz        wait_1
  1125.             cli
  1126. wait_2:
  1127.             in        al, dx
  1128.             test    al, 1
  1129.             jz        wait_2
  1130.             mov        es:[di], cl
  1131.             sti
  1132.             inc        di                            ; once for character byte
  1133. wait_3:
  1134.             in        al, dx
  1135.             test    al, 1
  1136.             jnz        wait_3
  1137.             cli
  1138. wait_4:
  1139.             in        al, dx
  1140.             test    al, 1
  1141.             jz        wait_4
  1142.             mov        es:[di], ah                    ; enter attribute byte
  1143.             sti
  1144.             inc        di                            ; once for attribute byte
  1145.             inc        si                          ; ++string
  1146.             jmp        printat_10                
  1147. printat_20:
  1148.             ret                                    ; all done
  1149.  
  1150. printat        endp
  1151.  
  1152.  
  1153.  
  1154. loader        proc    near
  1155.  
  1156.       
  1157.             call    get_video_mode
  1158.  
  1159.             mov        ah, 35h
  1160.             mov        al, 09h
  1161.             int        21h
  1162.             mov        old_int9_off, bx
  1163.             mov        old_int9_seg, es
  1164.  
  1165.             mov        ah, 25h
  1166.             mov        al, 09h
  1167.             mov        dx, offset new_int9
  1168.             int        21h
  1169.  
  1170.  
  1171.             mov        dx, offset sign_on_msg
  1172.             mov        ah, 09h
  1173.             int        21h
  1174.  
  1175.             mov        dx, offset loader
  1176.             int        27h
  1177.  
  1178.             ret            
  1179.  
  1180. loader        endp
  1181.  
  1182.  
  1183.  
  1184.  
  1185. get_video_mode proc near
  1186.  
  1187.     
  1188.     mov     ax, 40h
  1189.     mov     es, ax
  1190.     mov     ax, es:[63h]
  1191.     add     ax, 4
  1192.     mov     crt_control_port, ax
  1193.     add     ax, 2
  1194.     mov        crt_status_port, ax
  1195.     mov        video_ram, 0b000h
  1196.     mov        ah, 15                  ; check if graphics display
  1197.     int        10h
  1198.     test    al, 4
  1199.     jnz        got_mode
  1200.     mov        video_ram, 0b800h       ; if so then adjust video ram address
  1201.     mov        graphics, true
  1202.  
  1203. got_mode:
  1204.  
  1205.     ret
  1206.  
  1207. get_video_mode endp
  1208.  
  1209.  
  1210. sign_on_msg        db    0dh, 0ah
  1211.                 db    "COMDEBUG now resident - Alt + Scroll Lock to activate"
  1212.                 db    0dh, 0ah, '$'
  1213.  
  1214.  
  1215. code        ends
  1216.             end    first
  1217.