home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / batdoor.zip / ECHO_R2.ZIP / ECHO_R.ASM next >
Assembly Source File  |  1986-12-19  |  7KB  |  147 lines

  1. ; ==================================================== ;
  2. ;                                                      ;
  3. ; ECHO_R: A remote ECHO for DOORS users.               ;
  4. ;                                                      ;
  5. ; Courtesy of: The BBS of Excellence (312)398-2872     ;
  6. ;                                                      ;
  7. ;                    Version 2.0                       ;
  8. ; ==================================================== ;
  9. cseg    segment  byte public 'CODE'
  10.         assume   cs:cseg,ds:cseg,es:cseg
  11.         org      100h
  12. ECHO_R  proc     near
  13.         jmp      MainCode   ; Skip over constant
  14. ;
  15. ComInd   db      0          ; Indicator for COM2 request
  16. DataReg  dw      ?          ; Output COM port
  17. LineReg  dw      ?          ; Input COM port
  18. OffSet   dw      0          ; Offset from 0000:0040 for the com port addr
  19. ;
  20. ErrMsg   db      7,13,'COM'
  21. PortNum  db      ?          ; Part of the message
  22.          db      ': serial port not installed!',13,10,'$'
  23. ;
  24. MainCode:
  25.            Call    CheckForCom2    ; Put value in OFFSET
  26.            Mov     BX,Offset       ; COM1=0, COM2=2
  27.            Mov     AX,40h          ; Set up segment location
  28.            Mov     DS,AX           ; Port addresses are at segment 40h
  29.            Mov     AX,DS:[BX]      ; Get COM port address
  30.            Push    CS              ; Point to data area for .COM program
  31.            Pop     DS              ; Restore Data register
  32.            Add     BX,48           ; Turn into ASCII
  33.            Mov     PortNum,BL      ; Get the byte for error message
  34.            Or      AX,AX           ; Is the serial port installed?
  35.            Jz      NoPort          ; No...Abort
  36.            Mov     DataReg,AX      ; Save the output port address
  37.            Add     AX,5            ; Increment to the next port
  38.            Mov     LineReg,AX      ; Save the input port address
  39.            Mov     SI,80h          ; point to the command buffer
  40.            Xor     CX,CX           ; Init the loop counter
  41.            Mov     CL,[SI]         ; Get the input length
  42.            Or      CL,CL           ; Was there no input ?
  43.            JZ      ExitWrite       ; True...then exit
  44.            Mov     DL,13           ; Start with a carriage return
  45.            Mov     [SI],DL         ; For local AND remote
  46.            Call    Writeit         ; And display it
  47.            Inc     SI              ; Point past the length
  48. WriteLoop:
  49.            Inc     SI              ; Point to next character
  50.            Mov     DL,[SI]         ; Get the character
  51.            Cmp     DL,'/'          ; Is this a slash ?
  52.            Jnz     CheckEsc        ; No..bypass COM check
  53.            Mov     DH,ComInd       ; Get the indicator
  54.            Or      DH,DH           ; Have we passed this point ?
  55.            Jnz     CheckEsc        ; Yes..skip it
  56.            Mov     DH,[SI+2]       ; Check the format
  57.            Cmp     DH,' '          ; is it blank ?
  58.            Jz      SetCom          ; Yes..go check
  59.            Cmp     DH,13           ; Null entry ?
  60.            Jnz     CheckEsc        ; No..skip it
  61. SetCom:
  62.            Mov     DH,[SI+1]       ; Get port number
  63.            Cmp     DH,'1'          ; Is it the default ?
  64.            Jz      SetDefault      ; yes..bypass it
  65.            Cmp     DH,'2'          ; For COM2?
  66.            Jnz     CheckEsc        ; No, skip it
  67. SetDefault:
  68.            Add     SI,2            ; Skip to next entry
  69.            Sub     CX,2            ; Skip this stuff
  70.            Jmp     NextEntry       ; NextEntry
  71. CheckEsc:
  72.            Cmp     DL,'@'          ; Is this an Esc character ?
  73.            Jne     WriteScreen     ; No...continue
  74.            Mov     DH,[SI+1]       ; Check the next character
  75.            Cmp     DH,'['          ; Is it for ANSI?
  76.            Jnz     WriteScreen     ; No...don't change it
  77.            Mov     DL,27           ; Change to a REAL Esc character
  78.            Mov     [SI],DL         ; And save it for later
  79. WriteScreen:
  80.            Call    Writeit         ; Display the character
  81. NextEntry:
  82.            Loop    WriteLoop       ; Get another
  83. ExitWrite:
  84.            Mov     DL,13           ; Get a carriage return
  85.            Mov     [SI],DL         ; For local and comx
  86.            Call    Writeit         ; Display it
  87.            Mov     DL,10           ; Get a line feed
  88.            Mov     [SI],DL         ; For local and comx
  89.            Call    Writeit         ; And display it
  90.            Int     20h             ; Terminate program
  91. NoPort:
  92.            Mov     AH,9            ; Prepare to write
  93.            Lea     DX,ErrMsg       ; Point to error message
  94.            Int     21h             ; Display it
  95.            Int     20h             ; Terminate program
  96. Echo_r     Endp
  97.  
  98. CheckForCom2 Proc Near
  99.            Mov     SI,80h          ; Point to command line
  100.            Xor     CH,CH           ; Init work register
  101.            Mov     CL,[SI]         ; Get size
  102.            Or      CL,CL           ; Is it zero ?
  103.            Jz      CommandExit     ; Yes..skip it
  104.            Inc     SI              ; Go past the length
  105. Com2Loop:  Mov     AL,[SI]         ; Get the preceding blank
  106.            Cmp     AL,' '          ; Is it REALLY blank ?
  107.            Jnz     NotIt           ; Nah...keep on looking
  108.            Mov     AL,[SI+1]       ; Get a character
  109.            Cmp     AL,'/'          ; Is it part of the indicator ?
  110.            Jnz     NotIt           ; No..skip it
  111.            Mov     AL,[SI+2]       ; Is the second byte there ?
  112.            Cmp     AL,'2'          ; Check it out
  113.            Jnz     NotIt           ; If not...skip it
  114.            Mov     AL,[SI+3]       ; A space must delimit
  115.            Cmp     AL,' '          ; Does it?
  116.            Jz      ThatsIt         ; Yes..go play
  117.            Cmp     AL,13           ; Or is it a carriage return ?
  118.            Jnz     NotIt           ; If not..skip it
  119. ThatsIt:   Mov     AX,2            ; Get the offset
  120.            Mov     Offset,AX       ; And save it
  121.            Jmp     CommandExit     ; Then exit the routine
  122. NotIt:     Inc     SI              ; Point to the next byte
  123.            Loop    Com2Loop        ; Keep checking
  124. CommandExit:
  125.            Ret
  126. CheckForCom2 Endp
  127.  
  128. Writeit    Proc    Near
  129.            Mov     AH,2            ; Code for screen write
  130.            Int     21h             ; Write character to the screen
  131. WaitLineLoop:
  132.            Mov     DX,LineReg      ; Get the Line Register address xFDh
  133.            In      AL,DX           ; Get the Line status
  134.            And     AL,20h          ; Is the Xmit buffer empty ?
  135.            Cmp     AL,20h          ; Is it?
  136.            Jne     WaitLineLoop    ; No...Exit to caller
  137.            Mov     DX,DataReg      ; Point to output port
  138.            Mov     AL,[SI]         ; Get the character
  139.            Out     DX,AL           ; Output the character
  140.            Ret                     ; Return to main routine
  141. WriteIt    Endp
  142.  
  143. CSEG       Ends
  144.            End     ECHO_R
  145.  
  146.  
  147.