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 / SCANAS.ASM < prev    next >
Assembly Source File  |  1986-10-17  |  4KB  |  138 lines

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