home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
s
/
s48.zip
/
VM
/
ARCH.SCM
next >
Wrap
Text File
|
1992-06-17
|
4KB
|
136 lines
; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*-
; Copyright (c) 1992 by Richard Kelsey and Jonathan Rees. See file COPYING.
; This is file arch.scm.
;;;; Architecture description
; Things that the VM and the runtime system both need to know.
; Bytecodes: for compiler and interpreter
(define bits-used-per-byte 8)
(define-enumeration op
(check-nargs= ;nargs -- error if *nargs* not= operand
check-nargs>= ;nargs -- error if *nargs* < operand
nargs ; -- move *nargs* to *val*
make-env ;nargs -- cons an environment
make-heap-env ;nargs -- cons an environment in the heap
pop-env ; -- use superior env
make-rest-list ;nargs -- pop all but nargs things off the stack into a
; list
literal ;index -- value to *val*
local ;back over
local0 ;over -- back encoded into op-code for efficiency
local1 ;over -- "
local2 ;over -- "
set-local! ;back over
global ;index -- value to *val*
set-global! ;index -- new value in *val*
closure ;index -- environment in *env*
push ; -- push *val* onto stack
pop ; -- pop top of stack into *val*
stack-ref ;index -- index'th element of stack into *val*
stack-set! ;index -- *val* to index'th element of stack
make-cont ;count delta -- save state
call ;nargs -- proc in *val*, state in *cont*
move-args-and-call ;nargs -- proc in *val*, state in *cont*
jump-if-false ;delta -- boolean in *val*
jump ;delta
computed-goto ;n deltas -- jump using delta specified by *val*
; default to instruction after deltas
return ; -- continuation in *cont*, value in *val*
current-cont ; -- copy *cont* to *val*
with-continuation ; -- call *val* with continuation (pop)
apply ;nargs -- spread argument list in *val*, call (pop)
native ; -- start running native code (?)
get-cont-from-heap ; -- copy cont from heap to stack
;; Scalar primitives
eq?
number?
integer?
rational?
real?
complex?
exact? exact->inexact inexact->exact
+ - * / = <
quotient remainder
floor numerator denominator
real-part imag-part
exp log sin cos tan asin acos atan sqrt
angle magnitude make-polar make-rectangular
bitwise-not bitwise-and bitwise-ior bitwise-xor
arithmetic-shift
char?
char=?
char<?
char->ascii
ascii->char
eof-object?
;; Data manipulation
pair? cons car cdr set-car! set-cdr!
symbol? make-symbol symbol->string
location? make-location location-id contents set-contents!
location-defined? set-location-defined?!
closure? make-closure closure-env closure-template
code-vector? make-code-vector code-vector-length
code-vector-ref code-vector-set!
string? make-string string-length string-ref string-set!
vector? make-vector vector-length vector-ref vector-set!
record? make-record record-length record-ref record-set!
extended-number? make-extended-number extended-number-length
extended-number-ref extended-number-set!
continuation? make-continuation continuation-length
continuation-ref continuation-set!
;; I/O
open-port
close-port
input-port?
output-port?
read-char
peek-char
write-char
write-string
force-output
;; Misc
unassigned
unspecified
halt
trap ; -- raise exception specified by argument
false ; -- return #f (for bootstrapping)
write-image
collect
find-all-symbols
get-dynamic-state
set-dynamic-state!
set-exception-handler!
set-interrupt-handlers!
set-enabled-interrupts!
return-from-interrupt
vm ; access to the virtual machine
vm-extension ; access to extensions of the virtual machine
vm-return ; return from the vm in a restartable fashion
;; Unnecessary primitives
string=?
string-hash
reverse-list->string
intern
lookup
))
(define-enumeration interrupt
(periodic ; order matters - higher priority first
keyboard
))