home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / avcall / avcall-m68k-amiga-swap < prev    next >
Encoding:
Text File  |  1996-04-15  |  1.2 KB  |  39 lines

  1. #!/usr/local/bin/clispsh
  2.  
  3. ;; Postprocess avcall-m68k-amiga.s.
  4. ;; Swap the two instructions
  5. ;;        addw #-1056,sp
  6. ;;        moveml #0x3f3c,sp@-
  7. ;; at the beginning and the two instructions
  8. ;;        moveml sp@+,#0x3cfc
  9. ;;        addw #1056,sp
  10. ;; at the end of the file.
  11.  
  12. ;; This can apparently not been done with `sed'. `perl'? - just say no.
  13.  
  14. (defun process-file (istream ostream)
  15.   (prog ((eof "EOF") line1 line2)
  16.     next-line1
  17.     (setq line1 (read-line istream nil eof))
  18.     (when (eq line1 eof) (return))
  19.     next-line2
  20.     (setq line2 (read-line istream nil eof))
  21.     (when (eq line2 eof) (write-line line1 ostream) (return))
  22.     (cond ((and (search ",sp$" (concatenate 'string line1 "$"))
  23.                 (search "moveml" line2)
  24.            )
  25.            (write-line line2 ostream) (write-line line1 ostream) (go next-line1)
  26.           )
  27.           ((and (search "moveml" line1)
  28.                 (search ",sp$" (concatenate 'string line2 "$"))
  29.            )
  30.            (write-line line2 ostream) (write-line line1 ostream) (go next-line1)
  31.           )
  32.           (t (write-line line1 ostream)
  33.              (setq line1 line2) (go next-line2)
  34.     )     )
  35. ) )
  36.  
  37. (process-file *standard-input* *standard-output*)
  38.  
  39.