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 >
Text File  |  1992-06-17  |  4KB  |  136 lines

  1. ; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*-
  2. ; Copyright (c) 1992 by Richard Kelsey and Jonathan Rees.  See file COPYING.
  3.  
  4.  
  5. ; This is file arch.scm.
  6.  
  7. ;;;; Architecture description
  8.  
  9. ; Things that the VM and the runtime system both need to know.
  10.  
  11. ; Bytecodes: for compiler and interpreter
  12.  
  13. (define bits-used-per-byte 8)
  14.  
  15. (define-enumeration op
  16.   (check-nargs=       ;nargs   -- error if *nargs* not= operand
  17.    check-nargs>=      ;nargs   -- error if *nargs* < operand
  18.    nargs              ;        -- move *nargs* to *val*
  19.    make-env           ;nargs   -- cons an environment
  20.    make-heap-env      ;nargs   -- cons an environment in the heap
  21.    pop-env            ;        -- use superior env
  22.    make-rest-list     ;nargs   -- pop all but nargs things off the stack into a
  23.                       ;           list
  24.    literal            ;index   -- value to *val*
  25.    local              ;back over
  26.    local0             ;over    -- back encoded into op-code for efficiency
  27.    local1             ;over    --  "
  28.    local2             ;over    --  "
  29.    set-local!         ;back over
  30.    global             ;index   -- value to *val*
  31.    set-global!        ;index   -- new value in *val*
  32.    closure            ;index   -- environment in *env*
  33.    push               ;        -- push *val* onto stack
  34.    pop                ;        -- pop top of stack into *val*
  35.    stack-ref          ;index   -- index'th element of stack into *val*
  36.    stack-set!         ;index   -- *val* to index'th element of stack
  37.    make-cont          ;count delta   -- save state
  38.    call               ;nargs   -- proc in *val*, state in *cont*
  39.    move-args-and-call ;nargs   -- proc in *val*, state in *cont*
  40.    jump-if-false      ;delta   -- boolean in *val*
  41.    jump               ;delta
  42.    computed-goto      ;n deltas -- jump using delta specified by *val*
  43.                       ;            default to instruction after deltas
  44.    return             ;        -- continuation in *cont*, value in *val*
  45.    current-cont       ;        -- copy *cont* to *val*
  46.    with-continuation  ;        -- call *val* with continuation (pop)
  47.    apply              ;nargs   -- spread argument list in *val*, call (pop)
  48.    native             ;        -- start running native code (?)
  49.    get-cont-from-heap ;        -- copy cont from heap to stack
  50.  
  51.    ;; Scalar primitives
  52.    eq?
  53.  
  54.    number?
  55.    integer?
  56.    rational?
  57.    real?
  58.    complex?
  59.    exact? exact->inexact inexact->exact
  60.  
  61.    + - * / = <
  62.    quotient remainder
  63.    floor numerator denominator
  64.    real-part imag-part
  65.    exp log sin cos tan asin acos atan sqrt
  66.    angle magnitude make-polar make-rectangular
  67.    bitwise-not bitwise-and bitwise-ior bitwise-xor
  68.    arithmetic-shift
  69.    char?
  70.    char=?
  71.    char<?
  72.    char->ascii
  73.    ascii->char
  74.    eof-object?
  75.  
  76.    ;; Data manipulation
  77.    pair? cons car cdr set-car! set-cdr!
  78.    symbol? make-symbol symbol->string
  79.    location? make-location location-id contents set-contents!
  80.      location-defined? set-location-defined?!
  81.    closure? make-closure closure-env closure-template
  82.    code-vector? make-code-vector code-vector-length
  83.      code-vector-ref code-vector-set!
  84.    string? make-string string-length string-ref string-set!
  85.    vector? make-vector vector-length vector-ref vector-set!
  86.    record? make-record record-length record-ref record-set!
  87.    extended-number? make-extended-number extended-number-length
  88.      extended-number-ref extended-number-set!
  89.    continuation? make-continuation continuation-length
  90.      continuation-ref continuation-set!
  91.  
  92.    ;; I/O
  93.    open-port
  94.    close-port
  95.    input-port?
  96.    output-port?
  97.    read-char
  98.    peek-char
  99.    write-char
  100.    write-string
  101.    force-output
  102.  
  103.    ;; Misc
  104.    unassigned
  105.    unspecified
  106.    halt 
  107.    trap               ;        -- raise exception specified by argument
  108.    false              ;        -- return #f (for bootstrapping)
  109.    write-image
  110.    collect
  111.    find-all-symbols
  112.    get-dynamic-state
  113.    set-dynamic-state!
  114.    set-exception-handler!
  115.    set-interrupt-handlers!
  116.    set-enabled-interrupts!
  117.    return-from-interrupt
  118.    vm                  ; access to the virtual machine
  119.    vm-extension        ; access to extensions of the virtual machine
  120.    vm-return           ; return from the vm in a restartable fashion
  121.  
  122.    ;; Unnecessary primitives
  123.    string=?
  124.    string-hash
  125.    reverse-list->string
  126.    intern
  127.    lookup
  128.  
  129.    ))
  130.  
  131. (define-enumeration interrupt
  132.   (periodic     ; order matters - higher priority first
  133.    keyboard
  134.    ))
  135.  
  136.