home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB118 / setaux.asm < prev    next >
Assembly Source File  |  1995-05-28  |  17KB  |  471 lines

  1. TITLE    SET-DISPLAY-RESET COMM. PORT ON RAINBOW 100
  2. subttl    STACK SEGMENT
  3. STACK    SEGMENT PARA STACK 'STACK'
  4. ;
  5.     dw    100 dup(?)
  6. ;
  7. TSTACK    LABEL    WORD
  8. STACK    ENDS
  9. ;
  10. ;DEFINE PROGRAM SEGMENT PREFIX
  11. ;
  12. PREFIX    SEGMENT AT 0
  13.     ORG    80H
  14. CMDCNT    DB    ?            ;COMMAND LINE COUNT
  15. CMDSTR    DB    80 DUP (?)        ;COMMAND LINE BUFFER
  16. PREFIX    ENDS
  17. ;
  18. subttl    DATA SEGMENT
  19. ;
  20. DSEG    SEGMENT PARA PUBLIC 'DATA'
  21. ;
  22. APREFIX    DW    0
  23. CLS    DB    1BH,'[2J','$'        ;ESCAPE SEQ. TO CLEAR SCREEN
  24. INTRO   DB      '        '
  25.         DB      1BH,'[7m'
  26.         DB      'SETAUX.EXE  V2.0   by David N. Mitchell  Copyright (C)'
  27.         DB      ' 8/86',13,10
  28.         DB      1BH,'[0m'
  29.         DB      13,10
  30.         DB      '     The "SETAUX" program now supports two new functions : '
  31.         DB      '"SETAUX D" will',13,10
  32.         DB      'display the current settings of the port and "SETAUX R" will '
  33.         DB      'reset the',13,10
  34.         DB      'port to the NVM settings and clear the port.  The display '
  35.         DB      'and set functions',13,10
  36.         DB      'only support the options listed below.  Once changed by the '
  37.         DB      'program, these',13,10
  38.         DB      'settings will NOT be reflected in the modem set-up screen '
  39.         DB      'accessed through',13,10
  40.         DB      'the Rainbow SET-UP key.  The following is a list of '
  41.         DB      'supported settings to be',13,10
  42.         DB      'passed in the order listed along with the actual parameters '
  43.         DB      'in parentheses.',13,10
  44.         DB      'NO intervening spaces are allowed between parameters !',13,10
  45.         DB      13,10
  46.         DB      'STOP BITS :    1 (1)   1.5 (2)      2 (3)',13,10
  47.         DB      'DATA BITS :    5 (1)     6 (2)      7 (3)     8 (4)    7S (5)'
  48.         DB      '     7M (6)',13,10
  49.         DB      'PARITY    : EVEN (1)   ODD (2)   NONE (3)',13,10
  50.         DB      'RCV BAUD  :  300 (1)  1200 (2)   2400 (3)  4800 (4)  9600 (5)'
  51.         DB      13,10
  52.         DB      'XMT BAUD  :  300 (1)  1200 (2)   2400 (3)  4800 (4)  9600 (5)'
  53.         DB      13,10
  54.         DB      13,10
  55.         DB      'Example call for 1 stop bit, 8 data bits, no parity, RCV = '
  56.         DB      '1200, XMT = 1200 :',13,10
  57.         DB      13,10
  58.         DB      'SETAUX 14322',13,10,'$'
  59. ;
  60. ;       IO CONTROL PACKET
  61. ;
  62. IOCTL   LABEL   BYTE
  63. FNUM    DB      ?
  64. FRETC   DB      ?
  65. CHAR    DB      ?
  66. CSTAT   DB      ?
  67. DEVNUM  DB      0
  68. MDMCNTL DB      0
  69. STOPBIT DB      0
  70. DATABIT DB      0
  71. PARITY  DB      0
  72. RXBAUD  DB      0
  73. TXBAUD  DB      0
  74. XONCHR  DB      0
  75. XOFFCHR DB      0
  76. RXONOFF DB      0
  77. TXONOFF DB      0
  78. ALTBUF  DB      6 DUP(0)
  79. ;
  80. BLANK16 DB      '                $'
  81. HEADER0 DB      '   *** Rainbow Current Comm. Port Set-Up ***',13,10,'$'
  82. HEADER1 DB      '      (Copyright (C) 8/86 David Mitchell)',13,10,'$'
  83. HEADER2 DB      'DATA BITS/PARITY   RCV-BAUD  TX-BAUD  STOP-BITS',13,10,'$'
  84. HEADER3 DB      '----------------   --------  -------  ---------',13,10,'$'
  85. CRLF    DB      13,10,'$'
  86. BLANK   DB      20H
  87. FIVE    DB      '5'
  88. SIX     DB      '6'
  89. SEVEN   DB      '7'
  90. EIGHT   DB      '8'
  91. S       DB      'S'
  92. M       DB      'M'
  93. SLASH   DB      '/'
  94. ODD     DB      'O'
  95. EVEN0   DB      'E'
  96. NONE    DB      'N'
  97. ONE     DB      '1',13,10,'$'
  98. ONE5    DB      '1.5',13,10,'$'
  99. TWO     DB      '2',13,10,'$'
  100. B300    DB      '  300$'
  101. B1200   DB      ' 1200$'
  102. B2400   DB      ' 2400$'
  103. B4800   DB      ' 4800$'
  104. B9600   DB      ' 9600$'
  105. OTHER   DB      'OTHER$'
  106. PARERR  DB      'ERROR : 7S and 7M data bit specifications require parity = '
  107.         DB      'NONE$'
  108. ERROR   DB      'ERROR : Invalid Parameter Specification$'
  109. PARAM   DB      'ERROR : Too Many Parameters$'
  110. NOSET   DB      'Function Unsuccessful',13,10,'$'
  111. ;
  112. DSEG    ENDS
  113. ;
  114. subttl    MACROS
  115.     INCLUDE    CALLS.MAC
  116. ;
  117. ;
  118. subttl    CODE SEGMENT
  119. ;
  120. CSEG    SEGMENT PARA PUBLIC 'CODE'
  121. START    PROC    FAR
  122.     ASSUME    CS:CSEG,SS:STACK,ES:PREFIX
  123.     mov    ax,dseg
  124.     mov    ds,ax
  125.     ASSUME    DS:DSEG
  126.         mov     aprefix,es
  127.     mov    ax,stack
  128.     mov    ss,ax
  129.     mov    sp,offset tstack
  130. ENTRY:    MOV    DI,OFFSET CMDSTR    ;LOCATION OF PARAMETER STRING
  131.     MOV    CH,0
  132.     MOV    CL,CMDCNT        ;LENGTH OF PARAMETER STRING
  133.     CMP    CX,0            ;ANY PARAMETERS
  134.     JNZ    SCAN0            ;YES - PROCESS THEM
  135.     JMP    SCANX
  136. SCAN0:    MOV    AL,ES:[DI]        ;GET FIRST PARAMETER CHAR.
  137.         CMP     AL,20H
  138.         JZ      NOSAV                   ;DITCH THE LEADING SPACE
  139. SCAN1:  MOV     AL,ES:[DI]
  140.     CMP    AL,96
  141.     JLE    NEXT            ;IF CHAR. < "A" DON'T CONVERT
  142.     CMP    AL,123
  143.     JGE    NEXT            ;IF CHAR. > "Z" DON'T CONVERT
  144.     SUB    AL,20H            ;CONVERT TO UPPER CASE
  145. NEXT:    MOV    ES:[DI],AL        ;PUT CHAR. BACK IN BUFFER
  146. NOSAV:    INC    DI            ;POINT TO NEXT CHARACTER
  147.     LOOP    SCAN1            ;GET NEXT CHARACTER
  148.     MOV    AL,'$'
  149.     MOV    ES:[DI],AL
  150. SCANX:    NOP                ;ALL PARAMETERS HANDLED
  151. ;-------------------------------------------------------------------------------
  152. ;START OF MAIN PROGRAM
  153. ;-------------------------------------------------------------------------------
  154.         cmp     cmdcnt,0
  155.         jnz     chk                             ;if no paramters,
  156.         display intro                           ;display help message
  157.         jmp     done
  158. CHK:    mov     di,offset cmdstr                ;check param. for "D" or "R"
  159.         inc     di
  160.         mov     cl,es:[di]
  161.         cmp     cl,44H                          ;D = display current settings,
  162.         jnz     chk4r
  163.         call    showset
  164.         jmp     done
  165. CHK4R:  cmp     cl,52H                          ;R = reset to NVM & clear
  166.         jnz     chkparm
  167.         call    reset
  168.         jmp     done
  169. CHKPARM:call    check
  170.         call    setparm
  171.         jmp     done
  172. ;-------------------------------------------------------------------------------
  173. ;RETURN TO DOS
  174. ;-------------------------------------------------------------------------------
  175. DONE:    display crlf
  176.         exit
  177.     RET
  178. START    ENDP
  179. ;-------------------------------------------------------------------------------
  180. ;SUBROUTINES
  181. ;-------------------------------------------------------------------------------
  182. RESET   PROC
  183.         mov     cl,1
  184.         mov     di,offset fnum                  ;function code
  185.         mov     [di],cl
  186.         mov     di,offset devnum                ;device number
  187.         mov     al,1
  188.         mov     [di],al                         ;device = comm.
  189.         mov     ah,44H                          ;IOCTL devices function code
  190.         mov     al,2                            ;func. code - 2 works (not 3)
  191.         mov     bx,3                            ;handle - 3=AUX 4=PRN
  192.         mov     dx,offset ioctl                 ;packet address
  193.         int     21H                             ;reset to NVM & clear port
  194.         ret
  195. RESET   ENDP
  196. SHOWSET PROC
  197.         mov     al,3
  198.         mov     di,offset fnum                  ;function code
  199.         mov     [di],al
  200.         mov     di,offset devnum                ;device number
  201.         mov     al,1
  202.         mov     [di],al                         ;device = comm.
  203.         mov     ah,44H                          ;IOCTL devices function code
  204.         mov     al,2                            ;func. code
  205.         mov     bx,3                            ;handle - 3=AUX 4=PRN
  206.         mov     dx,offset fnum                  ;packet address
  207.         int     21H
  208.         mov     di,offset fretc
  209.         mov     al,[di]                         ;ret. code
  210.         cmp     al,0FFH                         ;FFH = success , 0 = fail
  211.         jz      dispset                         ;display settings
  212. nomsg:  display noset
  213.         jmp     done
  214. dispset:display crlf
  215.         display blank16
  216.         display header0
  217.         display blank16
  218.         display header1
  219.         display crlf
  220.         display blank16
  221.         display header2
  222.         display blank16
  223.         display header3
  224.         display blank16
  225.         mov     cx,8
  226. loop1:  dsp_chr blank
  227.         loop    loop1
  228.         mov     di,offset databit
  229.         mov     al,[di]
  230.         cmp     al,1
  231.         jnz     chk2
  232.         dsp_chr five
  233.         jmp     party
  234. chk2:   cmp     al,2
  235.         jnz     chk3
  236.         dsp_chr six
  237.         jmp     party
  238. chk3:   cmp     al,3
  239.         jnz     chk4
  240.         dsp_chr seven
  241.         jmp     party
  242. chk4:   cmp     al,4
  243.         jnz     chk5
  244.         dsp_chr eight
  245.         jmp     party
  246. chk5:   cmp     al,5
  247.         jnz     chk6
  248.         dsp_chr seven
  249.         dsp_chr slash
  250.         dsp_chr s
  251.         jmp     nopar
  252. chk6:   dsp_chr seven
  253.         dsp_chr slash
  254.         dsp_chr m
  255.         jmp     nopar
  256. party:  dsp_chr slash
  257.         mov     di,offset parity
  258.         mov     al,[di]
  259.         cmp     al,1
  260.         jnz     chkp2
  261.         dsp_chr even0
  262.         jmp     nopar
  263. chkp2:  cmp     al,2
  264.         jnz     chkp3
  265.         dsp_chr odd
  266.         jmp     nopar
  267. chkp3:  dsp_chr none
  268. nopar:  mov     cx,9
  269. loop2:  dsp_chr blank
  270.         loop    loop2
  271.         mov     di,offset rxbaud
  272.         mov     al,[di]
  273.         cmp     al,7
  274.         jnz     chkr2
  275.         display b300
  276.         jmp     trsmt
  277. chkr2:  cmp     al,9
  278.         jnz     chkr3
  279.         display b1200
  280.         jmp     trsmt
  281. chkr3:  cmp     al,0CH
  282.         jnz     chkr4
  283.         display b2400
  284.         jmp     trsmt
  285. chkr4:  cmp     al,0EH
  286.         jnz     chkr5
  287.         display b4800
  288.         jmp     trsmt
  289. chkr5:  cmp     al,10H
  290.         jnz     chkr6
  291.         display b9600
  292.         jmp     trsmt
  293. chkr6:  display other
  294. trsmt:  mov     cx,5
  295. loop3:  dsp_chr blank
  296.         loop    loop3
  297.         mov     di,offset txbaud
  298.         mov     al,[di]
  299.         cmp     al,7
  300.         jnz     chkt2
  301.         display b300
  302.         jmp     stbit
  303. chkt2:  cmp     al,9
  304.         jnz     chkt3
  305.         display b1200
  306.         jmp     stbit
  307. chkt3:  cmp     al,0CH
  308.         jnz     chkt4
  309.         display b2400
  310.         jmp     stbit
  311. chkt4:  cmp     al,0EH
  312.         jnz     chkt5
  313.         display b4800
  314.         jmp     stbit
  315. chkt5:  cmp     al,10H
  316.         jnz     chkt6
  317.         display b9600
  318.         jmp     stbit
  319. chkt6:  display other
  320. stbit:  mov     cx,7
  321. loop4:  dsp_chr blank
  322.         loop    loop4
  323.         mov     di,offset stopbit
  324.         mov     al,[di]
  325.         cmp     al,1
  326.         jnz     chks2
  327.         dsp_chr one
  328.         jmp     done
  329. chks2:  cmp     al,2
  330.         jnz     chks3
  331.         display one5
  332.         jmp     done
  333. chks3:  display two
  334. SHOWSET ENDP
  335. CHECK   PROC
  336.         mov     dl,0                            ;parity flag, see below
  337.         mov     ch,0                            ;zero high byte
  338.         mov     cl,5                            ;must have 5 parameters
  339.         mov     bx,1                            ;parm counter
  340.         mov     di,offset cmdstr                ;location of cmd. line (parms)
  341. CONT:   inc     di                              ;skip blank - mov to next parm.
  342.         mov     al,es:[di]                      ;get 1st parm into al
  343.         cmp     al,20H                          ;check for blanks
  344.         jz      err                             ;go print error msg
  345.         cmp     bx,1                            ;1st parm ?
  346.         jnz     too                             ;no, goto two
  347.         cmp     al,34H                          ;1st parm >= 4 ?
  348.         jge     err                             ;yes, goto err
  349.         jmp     zero                            ;go chk. if parm <= 0
  350. TOO:    cmp     bl,2                            ;2nd parm ?
  351.         jnz     three                           ;no, goto three
  352.         cmp     al,37H                          ;2nd parm >= 7 ?
  353.         jge     err                             ;yes, goto err
  354.         cmp     al,34H                          ;2nd parm <= 4 ?
  355.         jle     ok                              ;yes, don't worry about parity
  356.         mov     dl,1                            ;no, set flag - parity must = N
  357. OK:     jmp     zero                            ;go chk. if parm <= 0
  358. THREE:  cmp     bl,3                            ;3rd parm ?
  359.         jnz     four                            ;no, goto four
  360.         cmp     al,34H                          ;3rd parm >= 4 ?
  361.         jge     err                             ;yes, goto err
  362.         cmp     dl,1                            ;flag set ? 
  363.         jnz     zero                            ;no, goto zero
  364.         cmp     al,33H                          ;yes, parity must = N
  365.         jnz     perr                            ;parity <> N, print parity err.
  366.         jmp     zero                            ;parity = N, goto zero
  367. FOUR:   cmp     al,36H                          ;this is used for 4th and 5th
  368.         jge     err                             ;since both must be < 6
  369. ZERO:   cmp     al,30H                          ;used to check all parms > 0
  370.         jle     err                             ;no, goto err
  371.         inc     bx                              ;add 1 to count
  372.         loop    cont                            ;sub. 1 from cx, goto cont
  373.         inc     di                              ;add 1 to pointer
  374.         mov     al,es:[di]                      ;get what should be '$'
  375.         cmp     al,24H                          ;char = '$' ?
  376.         jnz     toomany                         ;no, print toomany msg
  377.         ret                                     ;
  378. ERR:    mov     dx,offset error                 ;prints standard error msg
  379. WRITE:  mov     ah,09H                          ;
  380.         int     21H                             ;
  381.         jmp     quit                            ;
  382. PERR:   mov     dx,offset parerr                ;print parity error msg
  383.         jmp     write                           ;
  384. TOOMANY:mov     dx,offset param                 ;print too many parms error msg
  385.         jmp     write                           ;
  386. QUIT:   exit
  387.     ret
  388. CHECK   ENDP
  389. SETPARM PROC
  390.         mov     cl,0
  391.         mov     si,offset fnum                  ;function code
  392.         mov     [si],cl
  393.         mov     si,offset devnum                ;device number
  394.         mov     al,1
  395.         mov     [si],al                         ;device = comm.
  396.         mov     di,offset cmdstr                ;parm. string address
  397.         inc     di                              ;skip blank
  398.         mov     al,es:[di]                      ;get 1st parm. - stop bits
  399.         sub     al,30H                          ;convert from ascii to numeric
  400.         inc     di
  401.         mov     si,offset stopbit
  402.         mov     [si],al                         ;set stop bits
  403.         mov     al,es:[di]                      ;get 2nd parm. - data bits
  404.         sub     al,30H                          ;convert from ascii to numeric
  405.         inc     di
  406.         mov     si,offset databit
  407.         mov     [si],al                         ;set data bits
  408.         mov     al,es:[di]                      ;get 3rd parm. - parity
  409.         sub     al,30H                          ;convert from ascii to numeric
  410.         inc     di
  411.         mov     si,offset parity
  412.         mov     [si],al                         ;set parity
  413.         mov     al,es:[di]                      ;get 4th parm. - rcv baud
  414.         sub     al,30H                          ;convert from ascii to numeric
  415.         cmp     al,1                            ;check for 300 baud
  416.         jnz     rchk1                           ;no, goto rchk1
  417.         mov     al,7                            ;yes, code for 300 baud
  418.         jmp     setrcv                          ;goto set rcv baud
  419. RCHK1:  cmp     al,2                            ;check for 1200 baud
  420.         jnz     rchk2                           ;no, goto rchk2
  421.         mov     al,9                            ;yes, code for 1200 baud
  422.         jmp     setrcv
  423. RCHK2:  cmp     al,3                            ;check for 2400 baud
  424.         jnz     rchk3
  425.         mov     al,0CH                          ;yes, code for 2400
  426.         jmp     setrcv
  427. RCHK3:  cmp     al,4
  428.         jnz     rchk4
  429.         mov     al,0EH                          ;yes, code for 4800
  430.         jmp     setrcv
  431. RCHK4:  mov     al,10H                          ;9600 baud is only one left
  432. SETRCV: inc     di
  433.         mov     si,offset rxbaud
  434.         mov     [si],al                         ;set RCV baud
  435.         mov     al,es:[di]                      ;get 5th parm. - xmt baud
  436.         sub     al,30H                          ;convert from ascii to numeric
  437.         cmp     al,1                            ;check for 300 baud
  438.         jnz     chek1                           ;no, goto chek1
  439.         mov     al,7                            ;yes, code for 300 baud
  440.         jmp     setx                            ;goto set tx baud
  441. CHEK1:  cmp     al,2                            ;check for 1200 baud
  442.         jnz     chek2                           ;no, goto chek2
  443.         mov     al,9                            ;yes, code for 1200 baud
  444.         jmp     setx
  445. CHEK2:  cmp     al,3                            ;check for 2400 baud
  446.         jnz     chek3
  447.         mov     al,0CH                          ;yes, code for 2400
  448.         jmp     setx
  449. CHEK3:  cmp     al,4
  450.         jnz     chek4
  451.         mov     al,0EH                          ;yes, code for 4800
  452.         jmp     setx
  453. CHEK4:  mov     al,10H                          ;9600 baud is only one left
  454. SETX:   inc     di
  455.         mov     si,offset txbaud
  456.         mov     [si],al                          ;set XMT baud
  457.         mov     ah,44H                          ;IOCTL devices function code
  458.         mov     al,2                            ;func. code - 2 works (not 3)
  459.         mov     bx,3                            ;handle - 3=AUX 4=PRN
  460.         mov     dx,offset ioctl                 ;packet address
  461.         int     21H
  462.         mov     si,offset fretc
  463.         mov     al,[si]
  464.         cmp     al,0FFH
  465.         jz      retu
  466.         display noset
  467. RETU:   ret
  468. SETPARM ENDP
  469. CSEG    ENDS
  470.     END    START
  471.