home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d519
/
oaklisp.lha
/
OakLisp
/
src.lzh
/
instruction-table.oak
< prev
next >
Wrap
Text File
|
1988-11-10
|
1KB
|
39 lines
;;; Copyright (C) 1988 Kevin Lang & Barak Pearlmutter, CMU Oaklisp Project.
;;; Dump a table of all the instructions in a format suitable for
;;; compilation into the emulator.
(let ((aux (lambda (s instr i)
(format s " \"~S\"," instr)
(if (= (modulo i 10) 0)
(format s " /* ~D */~%" i)
(format s "~%")))))
(define (dump-instruction-table f)
(let ((t0 (make simple-vector %argless-instructions))
(t1 (make simple-vector %arged-instructions)))
(dolist (x (list-type opcode-descriptor-hash-table))
(destructure* (instr opcode argfield . #t) x
(cond ((= opcode 0) (set! (nth t0 argfield) instr))
(else (set! (nth t1 opcode) instr)))))
(with-open-file (s f out)
(format s "#ifndef FAST~%~%")
(format s "char *ArglessInstrs[] = {~%")
(dotimes (i %argless-instructions)
(aux s (nth t0 i) i))
(format s "};~%~%")
(format s "char *Instrs[] = {~%")
(dotimes (i %arged-instructions)
(aux s (nth t1 i) i))
(format s "};~%~%")
(format s "#endif FAST~%~%")))))
;;; eof