home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / CPM3 / CCP105P.ARK / SCANLN.ASM < prev    next >
Assembly Source File  |  1986-10-17  |  5KB  |  157 lines

  1. ;
  2. ;    S C A N L N . A S M
  3. ;
  4. ; This RSX scans the console stream for a particular pattern, if 
  5. ; this pattern is not found, the SCB error flag is set.
  6. ;
  7. ; This, being for LN.COM, looks for the pattern "1.07<cr><cr><lf>Base:".
  8. ; if it is found before/when "Base:" is found, then NO error messages
  9. ; were found.  This is looking for error messages between the ...1.07 signon
  10. ; message, and the statistics line.  Obviously, this is depending upon the
  11. ; version number of the linker.
  12. ;
  13. ; The purpose of this RSX is to make "MAKE" work more fully under CP/M plus.
  14. ;
  15. ; CCP105.ASM with makecolon turned "on" allows the "-i" function in "make"
  16. ; to be functional (stopping the make sequence upon a stepwise error) for
  17. ; those programs (typically compilers, linkers,assemblers) which set the SCB
  18. ; error code upon errors.  Since most (of my) programs don't even know about
  19. ; that error flag, something needs to be done: this RSX.  This RSX is to be
  20. ; attached to the appropriate compilers (etc), and the patterns set 
  21. ; appropriately.  The patterns needed are those put out by the compiler (etc)
  22. ; when it detects an error.  My C-compiler, for instance, puts out
  23. ; an "errors" count with compile-time errors, and "failure" with command-line
  24. ; errors. Thus, I would look for those two words in the output stream.
  25. ; I had used the "BDOSRSX" RSX to determine that my compiler uses bdos call
  26. ; 02 (console output) to stream its error message(s).
  27. ;
  28. ; The particular version of CP/M "Make" being referred to is my port
  29. ; of the "Aussie Make" -- which I posted to Usenet's net.micro.cpm .
  30. ;
  31. ; (C) Copyright 1986 by Michael D. Kersenbrock  Aloha, Oregon
  32. ;
  33.  
  34. serial:    db    0,0,0,0,0,0
  35.  
  36. start:    jmp    scan
  37.  
  38. next:    jmp    $-$
  39.  
  40. prev:    dw    0
  41.  
  42. remove:    db    0ffh            ; remove with next load
  43.  
  44. nonbank: db    0            ; both banked and non-banked are OK
  45.  
  46. thename:
  47.     db    'SCANLN  '        ; Scan console output RSX for ln
  48.  
  49. loader:    db    0            ; load for banked & non-banked systems
  50.  
  51.     db    0,0            ; system use junque
  52.  
  53. okflag    db    0            ; flag == 0 if the str1 string hasn't
  54.                     ; been found yet
  55.  
  56.  
  57. scan:                    ; note: no BDOS call has input in 'a'
  58.     mov    a,c            ; get bdos call number
  59.     cpi    2            ; console output stream?
  60.     jnz    next            ; no, so quickly bypass this RSX
  61.                     ; yep, so ....
  62.     push    psw            ; save all at entry
  63.     push    h
  64.     push    b
  65.     push    d
  66.  
  67.  
  68.     ;
  69.     ; The general scheme is to maintain a window into the stream
  70.     ; equal to the maximum width of the longest search string.  When
  71.     ; a character is sent to the console, it is added to the "window",
  72.     ; and then that window is compared with all the strings.  If
  73.     ; a match is made (at any time), then the SCB error flag is set.
  74.     ; The specific error flag set is:
  75.     ;                  FF12 == MAKE ERROR
  76.     ;
  77.     ; Note that comparisons (etc) are sort of done tail-end first
  78.     ; (the "current" character that just came in is the "tail-end"
  79.     ; of something).
  80.  
  81.                     ; Insert new character into window
  82.     lxi    h,window+winsize-2    ; source pointer to end-1 of window
  83.     lxi    d,window+winsize-1    ; destination pointer to end of window
  84.     lxi    b,winsize-1        ; want to move all but last character
  85.     db    0edh,0b8h        ; Z80 LDDR reverse block move
  86.     pop    d            ; get new character
  87.     push    d
  88.     mov    a,e
  89.     sta    window            ; insert the new character into window
  90.  
  91.     lxi    d,str1            ; point to first string
  92.     call    compare            ; compare string to window contents
  93.     jnz    scan2            ; go look for error if OK not found
  94.     mvi    a,1            ; get a non-zero
  95.     sta    okflag            ; indicate the "goodstring" is found
  96. scan2:    
  97.     lda    okflag            ; already found the "goodstring"?
  98.     ora    a
  99.     jnz    exit            ; yep, so skip further comparisons
  100.     lxi    d,str2            ; point to second string
  101.     call    compare            ; compare strin to window contents
  102.     cz    seterror        ; set SCB error if error found
  103.  
  104. exit:
  105.     pop    d            ; return all registers back
  106.     pop    b        
  107.     pop    h
  108.     pop    psw
  109.     jmp    next            ; and let it continue with its business
  110.  
  111.  
  112. window:
  113.     db    '            '        ; length >= longest of below strings
  114.  
  115. winsize equ    12            ; the above length
  116.  
  117.                     ; NOTE: the strings should be
  118.                     ; spelt backwards.
  119. str1:    db    ':esaB',0ah,0dh,0dh,'70.1',0    ; first string to look for 
  120.  
  121. str2:    db    ':esaB',0        ; second string to look for
  122.  
  123.  
  124.  
  125.         ; Compare strings at window and at (DE).  Return
  126.         ; with ZERO FLAG RESET FOR NOMATCH and SET for MATCH.
  127.         ; Note that the comparison strings terminate with a null.
  128.  
  129. compare:
  130.     lxi    h,window        ; *HL -> window, *DE -> compareString
  131.  
  132. cmploop:
  133.     ldax    d            ; get fixed-string character
  134.     ora    a            ; end of string?
  135.     rz                ; yep, so return with MATCH indicated
  136.     cmp    m            ; strings matching?
  137.     rnz                ; nope, so quit now & tell the caller
  138.     inx    h            ; point to next char in each string
  139.     inx    d
  140.     jmp    cmploop            ; and compare next character
  141.  
  142.  
  143. seterror:
  144.     mvi    c,6ch            ; BDOS function for set-return code
  145.     lxi    d,0ff12h        ; load MAKE ERROR CODE
  146.     jmp    next            ; go set code, then return to whomever
  147.                     ; called seterror
  148.  
  149. iness
  150.  
  151.  
  152. window:
  153.     db    '            '        ; length >= longest of below strings
  154.  
  155. winsize equ    12            ; the above length
  156.  
  157.