accomodate the sign of the displacement.
#| -*-Scheme-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/spectrum/instr1.scm,v 1.2 1990/07/19 04:03:55 jinx Rel $
+$Id: instr1.scm,v 1.3 1993/02/13 05:37:22 gjr Exp $
-Copyright (c) 1987, 1989, 1990 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
;;;; HP Spectrum instruction utilities
;;; Originally from Walt Hill, who did the hard part.
+;;; package: (compiler lap-syntaxer)
(declare (usual-integrations))
\f
(lambda (completer)
(arith-log-condition completer)))
+(define-transformer complaltf
+ (lambda (completer)
+ (let ((val (arith-log-condition completer)))
+ (if (not (zero? (cadr val)))
+ (error "complaltf: Bad completer" completer)
+ val))))
+
(define-transformer fpformat
(lambda (completer)
(encode-fpformat completer)))
#| -*-Scheme-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/spectrum/instr2.scm,v 1.3 1990/08/05 05:41:27 jinx Rel $
+$Id: instr2.scm,v 1.4 1993/02/13 05:37:27 gjr Exp $
-Copyright (c) 1987, 1989, 1990 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
;;;; HP Spectrum Instruction Set Description
;;; Originally from Walt Hill, who did the hard part.
+;;; package: (compiler lap-syntaxer)
(declare (usual-integrations))
\f
(defpseudo COMIB #X21 (immed-5 right-signed))
(defpseudo ADDIB #x29 (immed-5 right-signed)))
\f
+;;;; Pseudo branch instructions.
+
+#|
+
+These nullify the following instruction when the branch is taken.
+irrelevant of the sign of the displacement (unlike the real instructions).
+If the displacement is positive, they use the nullify bit.
+If the displacement is negative, they use a NOP.
+
+ combn,cc r1,r2,label
+
+becomes either
+
+ comb,cc,n r1,r2,label
+
+if label is downstream (forward branch)
+
+or
+
+ comb,cc r1,r2,label
+ nop
+
+if label is upstream (backward branch)
+
+If the displacement is too large, it becomes
+
+ comb,!cc,n r1,r2,tlabel ; pco = 0
+ b,n label
+tlabel
+
+Note: Only those currently used by the code generator are implemented.
+|#
+\f
+(let-syntax
+ ((defccbranch
+ (macro (keyword completer opcode1 opcode2 opr1)
+ `(define-instruction ,keyword
+ ;; No @PCO form. It is a pseudo-instruction generated by the assembler
+
+ (((? compl ,completer) (? ,(car opr1)) (? reg-2) (@PCR (? l)))
+ (VARIABLE-WIDTH
+ (disp `(- ,l (+ *PC* 8)))
+ ((#x-2000 -1)
+ ;; Backward branch. No nullification, insert NOP.
+ (LONG (6 ,opcode1) ; COMB,cc
+ (5 reg-2)
+ (5 ,@opr1)
+ (3 (car compl))
+ (11 disp ASSEMBLE12:X)
+ (1 0)
+ (1 disp ASSEMBLE12:Y)
+
+ (6 #x02) ; NOP (OR 0 0 0)
+ (10 #b0000000000)
+ (3 0)
+ (1 0)
+ (7 #x12)
+ (5 #b00000)))
+
+ ((0 #x1FFF)
+ ;; Forward branch. Nullify.
+ (LONG (6 ,opcode1) ; COMB,cc,n
+ (5 reg-2)
+ (5 ,@opr1)
+ (3 (car compl))
+ (11 disp ASSEMBLE12:X)
+ (1 1)
+ (1 disp ASSEMBLE12:Y)))
+
+ ((() ())
+ (LONG (6 ,opcode2) ; COMB!,n
+ (5 reg-2)
+ (5 ,@opr1)
+ (3 (car compl))
+ (11 0 ASSEMBLE12:X)
+ (1 1)
+ (1 0 ASSEMBLE12:Y)
+
+ (6 #x3a) ; B,n
+ (5 0)
+ (5 (branch-extend-disp disp) ASSEMBLE17:X)
+ (3 0)
+ (11 (branch-extend-disp disp) ASSEMBLE17:Y)
+ (1 1)
+ (1 (branch-extend-disp disp) ASSEMBLE17:Z)))))))))
+
+ (define-macro (defcond name opcode1 opcode2 opr1)
+ `(defccbranch ,name complaltf ,opcode1 ,opcode2 ,opr1))
+
+ (define-macro (defpseudo name opcode opr1)
+ `(defccbranch ,name complal
+ (TF-adjust ,opcode compl)
+ (TF-adjust-inverted ,opcode compl)
+ ,opr1))
+
+ (defcond COMIBTN #X21 #x23 (immed-5 right-signed))
+ (defcond COMIBFN #X23 #x21 (immed-5 right-signed))
+
+ (defpseudo COMBN #X20 (reg-1)))
+\f
;;;; Miscellaneous control
(let-syntax
#| -*-Scheme-*-
-$Id: lapgen.scm,v 4.40 1992/09/11 22:34:34 cph Exp $
+$Id: lapgen.scm,v 4.41 1993/02/13 05:37:15 gjr Exp $
-Copyright (c) 1988-92 Massachusetts Institute of Technology
+Copyright (c) 1988-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(DEP () 0 31 2 ,regnum:addil-result)
(LDO () (OFFSET (- ,label *PC*) 0 ,regnum:addil-result) ,target)))
\f
-;; NOPs are inserted since conditional nullification only nullifies
-;; depending on the sign of the branch offset, which is unknown at
-;; this point. Linearizer can be changed, fairly easily, to tell us
-;; which direction the branch goes so we can decide whether the NOP is
-;; needed.
+;; COMIBTN, COMIBFN, and COMBN are pseudo-instructions that nullify
+;; the following instruction when the branch is taken. Since COMIBT,
+;; etc. nullify according to the sign of the displacement, the branch
+;; tensioner inserts NOPs as necessary (backward branches).
(define (compare-immediate cc i r2)
(cond ((zero? i)
(set-branches!
(lambda (label)
- (LAP (COMIBT (,cc) ,i ,r2 (@PCR ,label))
- (NOP ())))
+ (LAP (COMIBTN (,cc) ,i ,r2 (@PCR ,label))))
(lambda (label)
- (LAP (COMIBF (,cc) ,i ,r2 (@PCR ,label))
- (NOP ()))))
+ (LAP (COMIBFN (,cc) ,i ,r2 (@PCR ,label)))))
(LAP)))
((fits-in-11-bits-signed? i)
(set-current-branches!
(define (compare condition r1 r2)
(set-current-branches!
(lambda (label)
- (LAP (COMB (,condition) ,r1 ,r2 (@PCR ,label))
- (NOP ())))
+ (LAP (COMBN (,condition) ,r1 ,r2 (@PCR ,label))))
(lambda (label)
- (LAP (COMB (,(invert-condition condition)) ,r1 ,r2 (@PCR ,label))
- (NOP ()))))
+ (LAP (COMBN (,(invert-condition condition)) ,r1 ,r2 (@PCR ,label)))))
(LAP))
\f
;;;; Conditions
shortcircuit-apply-8
stack-and-interrupt-check))
+;; Why is this NOP here? We could use BLE,N, and adjust
+;; the return address within the hook.
+
(define (invoke-hook hook)
(LAP (BLE () (OFFSET ,hook 4 ,regnum:scheme-to-interface-ble))
(NOP ())))