home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / ucsdmagiscan2 / handle.text < prev    next >
Text File  |  2011-08-11  |  3KB  |  98 lines

  1.  
  2. .TITL   HANDLER
  3.  
  4. .PROC   GETBUF < FUNCTION GETBUF( SOH, EOP, TIMEOUT : INTEGER;
  5.                                   VAR S        : STRING ):BOOLEAN; >
  6.  
  7. ;-----------------------------------------------------------;
  8. ;                                                           ;
  9. ; written by H Balen    March 1986                          ;
  10. ;                                                           ;
  11. ; This is a microcode routine to receive a packet for the   ;
  12. ; Magiscans KERMIT program.                                 ;
  13. ;                                                           ;
  14. ; SOH = 'my_soh' start of packet                            ;
  15. ; EOP = 'my_eop' end of the packet                          ;
  16. ; TIMEOUT = number of loops before giving up                ;
  17. ; S = the buffer in which to store the data                 ;
  18. ;                                                           ;
  19. ;                                                           ;
  20. ;-----------------------------------------------------------;
  21.  
  22.  
  23. .REG EOP
  24. .REG SOH
  25. .REG STRPTR
  26. .REG INDPSN
  27. .REG WPSN
  28. .REG CBYTE
  29. .REG VALUE
  30. .REG WRDPTR
  31. .REG TCOUNT
  32. .REG TIMOUT
  33.  
  34. GETBUF: NOP                     :JSR DUMP2      ; Zero the count
  35.         ZER TCOUNT              :JSR ACPOP      ; and the posn
  36.         MOV AC,STRPTR           :JSR ACPOP      ; Set the string and word pointers
  37.         MOV AC,TIMOUT           :JSR ACPOP      ; get wait
  38.         MOV AC,EOP              :JSR ACPOP      ; get special characters
  39.         MOV AC,SOH
  40.  
  41. LAB1:   ZER INDPSN
  42.         MOV STRPTR,AC
  43.         MOV AC,WRDPTR
  44.  
  45. LOOP:   INC TCOUNT                              ; check the time out
  46.         MOV TIMOUT,AC
  47.         SUB AC,COUNT,#
  48.         MOV %0004,AC            :JMP LEAVE ZR
  49.         SUB AC,C16,RMSK                         ; check the status register
  50.         MOV C255,AC             :JSR STATSET
  51.         AND IO(RS),C1,AC
  52.         NOP                     :JMP LOOP NZ
  53.  
  54.         MOV %0038,IOA                           ; read the port
  55.         MOV IO,AC
  56.         AND AC,%7F,AC
  57.  
  58.         SUB AC,SOH,#                            ; check the special chars
  59.         SUB AC,EOP,#            :JMP LAB1 ZR
  60.         MOV AC,CBYTE            :JMP PEND ZR
  61.  
  62.         NOP                     :JSR STORUP     ; store the byte
  63.         NOP                     :JMP LOOP       ; continue to loop
  64.  
  65. PEND:   MOV STRPTR,MAF                          ; routine to leave the microcode procedure
  66.         MOV MM,AC                               ; store the length of the string
  67.         AND AC,%FF00,AC
  68.         MOV AC,VALUE
  69.         MOV INDPSN,AC
  70.         AND AC,%00FF,AC
  71.         OR  AC,VALUE,AC
  72.         MOV AC,MM
  73.         MOV C1,AC
  74. FEND:   NOP                     :JSR ACPUSH
  75.         NOP                     :JMP ENDIPC
  76. LEAVE:  ZER AC                  :JMP FEND
  77.  
  78. STORUP: INC INDPSN                              ; find the index
  79.         MOV INDPSN,AC
  80.         MOV WRDPTR,MAF
  81.         AND AC,C1,#                             ; if the index is odd then store in high byte of word
  82.         MOV MM,AC               :JMP ODD NZ
  83.         AND AC,%FF00,AC                         ; else store in the low byte
  84.         MOV AC,VALUE
  85.         MOV CBYTE,AC
  86.         AND AC,%00FF,AC
  87.         OR  AC,VALUE,AC
  88.         MOV AC,MM               :RET
  89.  
  90. ODD:    AND AC,%00FF,AC                         ; store in high byte
  91.         MOV AC,VALUE
  92.         MOV CBYTE,AC
  93.         AND AC(8L),%FF00,AC
  94.         OR  AC,VALUE,AC
  95.         MOV AC,MM
  96.         INC WRDPTR              :RET
  97.  
  98.