home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / compiler / rt / subprim.lisp < prev    next >
Encoding:
Text File  |  1991-11-06  |  1.8 KB  |  64 lines

  1. ;;; -*- Package: MIPS; Log: C.Log -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the Spice Lisp project at
  5. ;;; Carnegie-Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of Spice Lisp, please contact
  7. ;;; Scott Fahlman (FAHLMAN@CMUC). 
  8. ;;; **********************************************************************
  9. ;;;
  10. ;;; $Header: subprim.lisp,v 1.1 91/02/18 15:08:16 chiles Exp $
  11. ;;;
  12. ;;; Linkage information for standard static functions, and random vops.
  13. ;;;
  14. ;;; Written by William Lott.
  15. ;;; Converted for IBM RT by Bill Chiles.
  16. ;;;
  17.  
  18. (in-package "RT")
  19.  
  20.  
  21.  
  22. ;;;; Length
  23.  
  24. (define-vop (length/list)
  25.   (:translate length)
  26.   (:args (object :scs (descriptor-reg) :target ptr))
  27.   (:arg-types list)
  28.   (:temporary (:scs (descriptor-reg) :from (:argument 0)) ptr)
  29.   (:temporary (:scs (non-descriptor-reg) :type random) temp)
  30.   (:temporary (:scs (any-reg) :type fixnum :to (:result 0) :target result)
  31.           count)
  32.   (:results (result :scs (any-reg descriptor-reg)))
  33.   (:policy :fast-safe)
  34.   (:vop-var vop)
  35.   (:save-p :compute-only)
  36.   (:generator 50
  37.     (let ((done (gen-label))
  38.       (loop (gen-label))
  39.       (not-list (generate-cerror-code vop object-not-list-error object)))
  40.       (move ptr object)
  41.       (inst li count 0)
  42.  
  43.       (emit-label loop)
  44.  
  45.       (inst c ptr null-tn)
  46.       (inst bc :eq done)
  47.  
  48.       (test-type ptr temp not-list t vm:list-pointer-type)
  49.  
  50.       (loadw ptr ptr vm:cons-cdr-slot vm:list-pointer-type)
  51.       (inst inc count (fixnum 1))
  52.       (test-type ptr temp loop nil vm:list-pointer-type)
  53.  
  54.       (cerror-call vop done object-not-list-error ptr)
  55.  
  56.       (emit-label done)
  57.       (move result count))))
  58.        
  59.  
  60. (define-static-function length (object) :translate length)
  61.  
  62.  
  63.  
  64.