; To load the VM into Scheme 48:
;   ,exec ,load README
;
; Then, for example,
;  (start-vm "~/s48/initial.image" 4000000 20000 '#())
; in the user package will start up the VM with the initial image.
; Be patient.  It will take a while.  Running the initial image as
; above on a SGI Indy (100 mhz R4000) it took over 70 minutes to
; get the - prompt.  scheme48.image starts up faster as it does little
; in the way of initialization.
;
; You will need to have a large heap to start with. -h 12000000 works
; for loading the initial image in version 0.35, smaller heaps may also
; work.
(config)
(load "ps-interface.scm")
(load "interfaces.scm")
(load "s48-package-defs.scm")
(load "package-defs.scm")
(load-package 'destructuring)  ; used in FOR-SYNTAX clause
(load-package 'bigbit)
(load-package 'interpreter)
(user)
(open 'pre-scheme)
(open 'interpreter)
(open 'memory-debug)
(run '
(define (start-vm image-file heap-size stack-size start-args)
  (reinitialize-memory)
  (let ((needed-space (+ (quotient (check-image-header image-file) 4)
	                 (required-init-space start-args (vector-length start-args)))))
    (cond ((< heap-size (* 16 needed-space))
           (display "Heap too small, want at least ")
           (display (* 16 needed-space))
           (newline))
          (else
           (let ((heap (allocate-memory heap-size))
                 (stack (allocate-memory stack-size)))
             (initialize-vm heap (quotient heap-size 4)
			    stack (quotient stack-size 4))
             (call-startup-procedure (read-image image-file 0)
                                     start-args
                                     (vector-length start-args)))))))
)