3
$Id: instr1.scm,v 1.6 2002/02/22 04:38:10 cph Exp $
5
Copyright (c) 1987-1999, 2001, 2002 Massachusetts Institute of Technology
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
23
;;;; HP Spectrum instruction utilities
24
;;; Originally from Walt Hill, who did the hard part.
25
;;; package: (compiler lap-syntaxer)
27
(declare (usual-integrations))
29
(define-transformer complx
31
(vector (encode-S/SM completer)
35
(define-transformer compls
37
(vector (encode-MB completer)
41
(define-transformer compledb
43
(cons (encode-n completer)
44
(extract-deposit-condition completer))))
46
(define-transformer compled
48
(extract-deposit-condition completer)))
50
(define-transformer complalb
52
(cons (encode-n completer)
53
(arith-log-condition completer))))
55
(define-transformer complaltfb
57
(list (encode-n completer)
58
(let ((val (arith-log-condition completer)))
59
(if (not (zero? (cadr val)))
60
(error "complaltfb: Bad completer" completer)
63
(define-transformer complal
65
(arith-log-condition completer)))
67
(define-transformer complaltf
69
(let ((val (arith-log-condition completer)))
70
(if (not (zero? (cadr val)))
71
(error "complaltf: Bad completer" completer)
74
(define-transformer fpformat
76
(encode-fpformat completer)))
78
(define-transformer fpcond
80
(encode-fpcond completer)))
82
(define-transformer sr3
84
(let ((place (assq value '((0 . 0) (1 . 2) (2 . 4) (3 . 6)
85
(4 . 1) (5 . 3) (6 . 5) (7 . 7)))))
88
(error "sr3: Invalid space register descriptor" value)))))
92
(define-integrable (branch-extend-pco disp nullify?)
93
(if (and (= nullify? 1)
98
(define-integrable (branch-extend-nullify disp nullify?)
99
(if (and (= nullify? 1)
100
(not (negative? disp)))
104
(define-integrable (branch-extend-disp disp)
107
(define-integrable (branch-extend-edcc cc)
108
(remainder (+ cc 4) 8))
110
(define-integrable (encode-N completers)
111
(if (memq 'N completers)
115
(define-integrable (encode-S/SM completers)
116
(if (or (memq 'S completers) (memq 'SM completers))
120
(define-integrable (encode-MB completers)
121
(if (memq 'MB completers)
125
(define-integrable (m-val compl-list)
126
(if (or (memq 'M compl-list)
127
(memq 'SM compl-list)
128
(memq 'MA compl-list)
129
(memq 'MB compl-list))
133
(define-integrable (cc-val compl-list)
134
(cond ((memq 'P compl-list) 3)
135
((memq 'Q compl-list) 2)
136
((memq 'C compl-list) 1)
139
(define (extract-deposit-condition compl)
140
(cond ((or (null? compl) (memq 'NV compl)) 0)
141
((or (memq 'EQ compl) (memq '= compl)) 1)
142
((or (memq 'LT compl) (memq '< compl)) 2)
145
((or (memq 'LTGT compl) (memq '<> compl)) 5)
146
((or (memq 'GTEQ compl) (memq '>= compl)) 6)
149
;; This should really error out, but it's hard to
150
;; arrange given that the compl includes other
154
(define-integrable (encode-fpformat compl)
160
(error "Missing Floating Point Format" compl))))
162
(define-integrable (encode-fpcond fpcond)
163
(let ((place (assq fpcond float-condition-table)))
166
(error "encode-fpcond: Unknown condition" fpcond))))
168
(define float-condition-table
202
(define (arith-log-condition compl-list)
204
(let loop ((compl-list compl-list))
205
(if (null? compl-list)
207
(let ((val (assq (car compl-list) arith-log-condition-table)))
210
(loop (cdr compl-list)))))))
212
(define arith-log-condition-table
254
(define-integrable (tf-adjust opcode condition)
255
(+ opcode (* 2 (cadr condition))))
257
(define (tf-adjust-inverted opcode condition)
258
(+ opcode (* 2 (- 1 (cadr condition)))))
260
(define (make-operator name handler)
262
(if (exact-integer? value)
266
(let-syntax ((define-operator
267
(sc-macro-transformer
268
(lambda (form environment)
269
`(DEFINE ,(cadr form)
270
(MAKE-operator ',(cadr form)
271
,(close-syntax (caddr form)
274
(define-operator LEFT
276
(bit-string->signed-integer
277
(bit-substring (signed-integer->bit-string 32 number) 11 32))))
279
(define-operator RIGHT
281
(bit-string->unsigned-integer
282
(bit-substring (signed-integer->bit-string 32 number) 0 11)))))
b'\\ No newline at end of file'