home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / rs232ts2 / RS232TST.ZZ0 / RS232TST.Z80
Encoding:
Text File  |  1993-06-07  |  3.6 KB  |  156 lines

  1. ; RS232 TEST - Version 2.0  (First Beta Release)
  2. ;
  3. ; RS232TST looks at the SIO status register (RR0).  The entire status byte
  4. ; is placed in register 8.  The value of the individual bits in the status 
  5. ; register re placed in ZCPR3 user registers 0 through 7 respectively.
  6. ;
  7. ; The program aborts with an error code 6 if the Z3 wheel byte is not set,
  8. ; and aborts with an error message if no Z3 message buffer exists.
  9. ;
  10. ;                    Lindsay Haisley
  11. ;                    Znode 77
  12. ;                    (512) 259-1261
  13.  
  14. cr        equ    0dh
  15. lf        equ    0ah
  16.  
  17.         ext    putreg, z3init, getwhl, eprint, getmsg
  18.         .request syslib, z3lib
  19.  
  20. begin:        jp    start
  21.         defb    'Z3ENV'
  22.         defb    1
  23. env:        defw    00        ; ENV buffer
  24.         defb    'PORT'
  25. port:        defb    06h        ; Modem or RS232 control port number
  26.         defb    'RESET'
  27. resflg:        defb    0ffh        ; SIO Interrup/Status reset flag
  28.         defb    'WHEEL'
  29. whlflg:        defb    0ffh        ; Wheel protect flag
  30.  
  31.  
  32. start:        ld    hl,(env)    ; Get env address
  33.         call    z3init        ; Initialize z3lib
  34.         ld    a,(whlflg)    ; Are we checking for wheels?
  35.         or    a
  36.         jr    z,nocheck    ; If not, bypass
  37.         call    getwhl
  38.         or    a
  39.         jp    z,notwheel    ; If user not wheel, dissapear
  40. nocheck:    call    getmsg        ; Check for msg buffer
  41.         or    a
  42.         jp    z,msgerr    ; No message buffer, so error
  43.         ld    a,0ffh
  44.         ld    hl,82h        ; Point to tbuff
  45.         ld    a,(hl)        ; Check for document request
  46.         cp    '/'        ; ZCPR document request
  47.         jp    z,tell
  48.         
  49. ; Here the work is done
  50.         ld    a,(port)    ; get the port number
  51.         ld    (iport1),a    ; Stick it in the code
  52.         ld    (iport2),a
  53.         ld    a,(resflg)    ; Are we to do a reset?
  54.         or    a
  55.         jr    z,notreset    ; If not, skip it
  56.         ld    a,10h        ; Reset status/interruts
  57. iport1        equ    $+1
  58.         out    (0),a        ; Replacd by correct port
  59. iport2        equ    $+1
  60. notreset:    in    a,(0)        ; Get status
  61.         ld    c,a        ; Save
  62.         
  63.         bit    0,c        ; Bit 0, Rcv. character avail
  64.         ld    b,0
  65.         call    set
  66.         
  67.         bit    1,c        ; Bit 1, Interrupt pending
  68.         ld    b,1
  69.         call    set
  70.         
  71.         bit    2,c        ; Bit 2, Xmit buffer empty
  72.         ld    b,2
  73.         call    set
  74.         
  75.         bit    3,c        ; Bit 3, Data carrier detect
  76.         ld    b,3
  77.         call    set
  78.         
  79.         bit    4,c        ; Bit 4, ~SYNC status
  80.         ld    b,4
  81.         call    set
  82.         
  83.         bit    5,c        ; Bit 5, Clear to send
  84.         ld    b,5
  85.         call    set
  86.         
  87.         bit    6,c        ; Bit 6, Xmit Underrun
  88.         ld    b,6
  89.         call    set
  90.         
  91.         bit    7,c        ; Bit 7, Break/Abort
  92.         ld    b,7
  93.         call    set
  94.         
  95.         ld    b,8
  96.         ld    a,c
  97.         call    putreg        ; Put entire control byte in reg 6
  98.         ret
  99.         
  100. set:        push    bc
  101.         ld    a,0
  102.         jr    z,notset
  103.         inc    a
  104. notset:        call    putreg
  105.         pop    bc
  106.         ret
  107.         
  108. notwheel:    call    getmsg
  109.         or    a
  110.         ret    z        ; No message buffer, so just quit
  111.         ld    de,03
  112.         add    hl,de        ; Point to command status
  113.         ld    (hl),6        ; Enable error handling
  114.         ret            ; Return to CCP, RS232TST is invisible
  115.  
  116.  
  117.         
  118. msgerr:        call     eprint
  119.         defz    'No Z3 Message Buffer present.......',cr,lf
  120.         ret
  121.                         
  122. ; Set up document display with type and load address figures
  123. ;
  124. tell:    call    eprint
  125.                     ; #text
  126.     defb    '  RS232TST - Test RS232 status.  Version 2.0',cr,lf
  127.     defb    '    Reg 0 = Receive Character Available',cr,lf
  128.     defb    '    Reg 1 = Interrupt Pending',cr,lf
  129.     defb    '    Reg 2 = Transmit Buffer Empty status',cr,lf
  130.     defb    '    Reg 3 = Data Carrier Detect status',cr,lf
  131.     defb    '    Reg 4 = Inverted SYNC Input status',cr,lf
  132.     defb    '    Reg 5 = Clear To Send status',cr,lf
  133.     defb    '    Reg 6 = (Unused in asynch. communication)',cr,lf
  134.     defb    '    Reg 7 = Break/Abort',cr,lf
  135.     defb    '    Reg 8 = Complete SIO Status Register Byte',cr,lf
  136.     defz    '  Note:  RS232TST is '
  137.         
  138.         ld    a,(whlflg)
  139.         or    a        ; Check to see if wheel protected
  140.         jr    nz,skipnot    ; If protected, skip 'NOT'
  141.     
  142.         call    eprint
  143.         defz    'NOT '
  144.         
  145. skipnot:    call    eprint        
  146.         defz    'wheel protected.'        
  147.  
  148.         ld    a,(resflg)
  149.         or    a
  150.         ret    z
  151.         call    eprint
  152.         defz    0dh,0ah,'  Interrupt/Status reset enabled'
  153.         
  154.         ret
  155.                     ; #endtext
  156.