tac0S
Template Affectional Command Operating System
instr.h
1 /*
2  Copyright (c) 1992-1993 The Regents of the University of California.
3  All rights reserved. See copyright.h for copyright notice and limitation
4  of liability and disclaimer of warranty provisions.
5  */
6 
7 #include "copyright.h"
8 
9 /* Instruction formats */
10 
11 #define rd(i) (((i) >> 11) & 0x1f)
12 #define rt(i) (((i) >> 16) & 0x1f)
13 #define rs(i) (((i) >> 21) & 0x1f)
14 #define shamt(i) (((i) >> 6) & 0x1f)
15 #define immed(i) (((i) & 0x8000) ? (i)|(-0x8000) : (i)&0x7fff)
16 
17 #define off26(i) (((i)&((1<<26)-1))<<2)
18 #define top4(i) (((i)&(~((1<<28)-1))))
19 #define off16(i) (immed(i)<<2)
20 
21 #define extend(i, hibitmask) (((i)&(hibitmask)) ? ((i)|(-(hibitmask))) : (i))