2014年11月26日水曜日

開発環境

計算機プログラムの構造と解釈[第2版](ハロルド エイブルソン (著)、ジュリー サスマン (著)、ジェラルド・ジェイ サスマン (著)、Harold Abelson (原著)、Julie Sussman (原著)、Gerald Jay Sussman (原著)、和田 英一 (翻訳)、翔泳社、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の5(レジスタ計算機での計算)、5.2(レジスタ計算機シミュレータ)、5.2.2(アセンブラ)、問題 5.8.を解いてみる。

その他参考書籍

問題 5.8.

制御がthereに達した時、レジスタaの内容は3となる。

同じラベル名が二つの異なる場所を指すように使われたら、エラーとする様に秋雨性。<・p>

コード(BBEdit, Emacs)

sample7.scm

(define (extract-labels text receive)
  (if (null? text)
      (receive '() '())
      (extract-labels
       (cdr text)
       (lambda (insts labels)
         (let ((next-inst (car text)))
           (if (symbol? next-inst)
               (if (assoc next-inst labels)
                   (error "Multiply defined label:" next-inst)
                   (receive insts
                            (cons (make-label-entry next-inst
                                                    insts)
                              labels)))
               (receive (cons (make-instruction next-inst)
                              insts)
                        labels)))))))

0 コメント:

コメントを投稿