~ubuntu-branches/ubuntu/intrepid/mit-scheme/intrepid-updates

« back to all changes in this revision

Viewing changes to src/compiler/etc/asm.scm

  • Committer: Bazaar Package Importer
  • Author(s): Chris Hanson
  • Date: 2002-03-14 17:04:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020314170407-m5lg1d6bdsl9lv0s
Tags: upstream-7.7.0
ImportĀ upstreamĀ versionĀ 7.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#| -*-Scheme-*-
 
2
 
 
3
$Id: asm.scm,v 1.3 1999/01/02 06:06:43 cph Exp $
 
4
 
 
5
Copyright (c) 1989-1999 Massachusetts Institute of Technology
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or (at
 
10
your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful, but
 
13
WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program; if not, write to the Free Software
 
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
20
|#
 
21
 
 
22
;;;; Source (lap) assembler
 
23
 
 
24
(declare (usual-integrations))
 
25
 
 
26
;; To be loaded in (compiler top-level)
 
27
 
 
28
;;; Example of `lap->code' usage:
 
29
 
 
30
(define bar
 
31
  ;; defines bar to be a procedure that adds 1 to its argument
 
32
  ;; with no type or range checks.
 
33
  (scode-eval
 
34
   (lap->code
 
35
    'start
 
36
    `((pea (@pcr proc))
 
37
      (or b (& ,(* (microcode-type 'compiled-entry) 4)) (@a 7))
 
38
      (mov l (@a+ 7) (@ao 6 8))
 
39
      (and b (& #x3) (@a 7))
 
40
      (rts)
 
41
      (dc uw #x0202)
 
42
      (block-offset proc)
 
43
      (label proc)
 
44
      (mov l (@a+ 7) (d 0))
 
45
      (addq l (& 1) (d 0))
 
46
      (mov l (d 0) (@ao 6 8))
 
47
      (and b (& #x3) (@a 7))
 
48
      (rts)))
 
49
   '()))
 
50
 
 
51
(define (lap->code label lap)
 
52
  (in-compiler
 
53
   (lambda ()
 
54
     (set! *lap* lap)
 
55
     (set! *entry-label* label)
 
56
     (set! *current-label-number* 0)
 
57
     (set! *next-constant* 0)
 
58
     (set! *interned-constants* '())
 
59
     (set! *interned-variables* '())
 
60
     (set! *interned-assignments* '())
 
61
     (set! *interned-uuo-links* '())
 
62
     (set! *block-label* (generate-label))
 
63
     (set! *external-labels* '())
 
64
     (set! *ic-procedure-headers* '())
 
65
     (phase/assemble)
 
66
     (phase/link)
 
67
     *result*)))
 
 
b'\\ No newline at end of file'