1#| -*-Scheme-*- 2 3Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 5 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts 6 Institute of Technology 7 8This file is part of MIT/GNU Scheme. 9 10MIT/GNU Scheme is free software; you can redistribute it and/or modify 11it under the terms of the GNU General Public License as published by 12the Free Software Foundation; either version 2 of the License, or (at 13your option) any later version. 14 15MIT/GNU Scheme is distributed in the hope that it will be useful, but 16WITHOUT ANY WARRANTY; without even the implied warranty of 17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18General Public License for more details. 19 20You should have received a copy of the GNU General Public License 21along with MIT/GNU Scheme; if not, write to the Free Software 22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 23USA. 24 25|# 26 27;;;; MIPS instruction set 28 29(declare (usual-integrations)) 30 31(let-syntax 32 ((opcodes 33 (sc-macro-transformer 34 (lambda (form environment) 35 environment 36 `(BEGIN 37 ,@(let loop ((names (caddr form)) (value 0)) 38 (if (pair? names) 39 (if (symbol? (car names)) 40 (cons `(DEFINE-INTEGRABLE 41 ,(symbol-append (car names) (cadr form)) 42 ,value) 43 (loop (cdr names) (+ value 1))) 44 (loop (cdr names) (+ value 1))) 45 '()))))))) 46 ; OP CODES 47 (opcodes '-OP 48 (special bcond j jal beq bne blez bgtz ; 0 - 7 49 addi addiu slti sltiu andi ori xori lui ; 8 - 15 50 cop0 cop1 cop2 cop3 () () () () ; 16 - 23 51 () () () () () () () () ; 24 - 31 52 lb lh lwl lw lbu lhu lwr () ; 32 - 39 53 sb sh swl sw () () swr () ; 40 - 47 54 lwc0 lwc1 lwc2 lwc3 () () () () ; 48 - 55 55 swc0 swc1 swc2 swc3 () () () ())) ; 56 - 63 56 57 ; Special Function Codes 58 (opcodes '-FUNCT 59 (sll () srl sra sllv () srlv srav ; 0 - 7 60 jr jalr () () syscall break () () ; 8 - 15 61 mfhi mthi mflo mtlo () () () () ; 16 - 23 62 mult multu div divu () () () () ; 24 - 31 63 add addu sub subu and or xor nor ; 32 - 39 64 () () slt sltu () () () () ; 40 - 47 65 () () () () () () () () ; 48 - 55 66 () () () () () () () ())) ; 56 - 63 67 68 ; Condition codes for BCOND 69 (opcodes '-COND 70 (bltz bgez () () () () () () ; 0 - 7 71 () () () () () () () () ; 8 - 15 72 bltzal bgezal () () () () () () ; 16 - 23 73 () () () () () () () ())) ; 24 - 31 74 75 ; Floating point function codes for use with COP1 instruction 76 (opcodes 'F-OP 77 (add sub mul div () abs mov neg ; 0 - 7 78 () () () () () () () () ; 8 - 15 79 () () () () () () () () ; 16 - 23 80 () () () () () () () () ; 24 - 31 81 cvt.s cvt.d () () cvt.w () () () ; 32 - 39 82 () () () () () () () () ; 40 - 47 83 c.f c.un c.eq c.ueq c.olt c.ult c.ole c.ule ; 48 - 55 84 c.sf c.ngle c.seq c.ngl c.lt c.nge c.le c.ngt)) ; 56 - 63 85) ; let-syntax 86 87; Operations on co-processors (for BCzFD, BCzT, CFCz, COPz, CTCz, 88; MFCz, and MTCz instructions) 89; This is confusing ... according to the diagrams, these occupy bits 90; 16 through 25, inclusive (10 bits). But the tables indicate that 91; only bits 16, and 21 through 25 matter. In fact, bit 25 is always 0 92; since that denotes a COPz instruction; hence COPz has 32 encodings 93; and all the others have two encodings. 94 95(define-integrable mf-cp-op #x000) 96(define-integrable mt-cp-op #x080) 97(define-integrable bcf-cp-op #x100) 98(define-integrable bct-cp-op #x101) 99(define-integrable cf-cp-op #x040) 100(define-integrable ct-cp-op #x0C0) 101 102(define-integrable mf-cp-op-alternate #x001) 103(define-integrable mt-cp-op-alternate #x081) 104(define-integrable bcf-cp-op-alternate #x180) 105(define-integrable bct-cp-op-alternate #x181) 106(define-integrable cf-cp-op-alternate #x041) 107(define-integrable ct-cp-op-alternate #x0C1) 108 109; Operations on co-processor 0 110(define-integrable cop0-op:tlbr 1) 111(define-integrable cop0-op:tlbwi 2) 112(define-integrable cop0-op:tlbwr 6) 113(define-integrable cop0-op:tlbp 8) 114(define-integrable cop0-op:rfe 16) 115 116; Floating point formats 117(define-integrable single-precision-float 0) 118(define-integrable double-precision-float 1) 119