1 /* 2 * Copyright (c) 1985 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)ops.tahoe.c 5.6 (Berkeley) 05/23/89"; 20 #endif /* not lint */ 21 22 /* 23 * Machine operators. 24 */ 25 26 #include "defs.h" 27 #include "ops.h" 28 29 #ifndef public 30 typedef unsigned char Opcode; 31 32 /* 33 * Opcode definitions. 34 */ 35 36 /* 37 * Argument access types 38 */ 39 #define ACCA (8<<3) /* address only */ 40 #define ACCR (1<<3) /* read */ 41 #define ACCW (2<<3) /* write */ 42 #define ACCM (3<<3) /* modify */ 43 #define ACCB (4<<3) /* branch displacement */ 44 #define ACCI (5<<3) /* XFC code */ 45 46 /* 47 * Argument data types 48 */ 49 #define TYPB 0 /* byte */ 50 #define TYPW 1 /* word */ 51 #define TYPL 2 /* long */ 52 #define TYPQ 3 /* quad */ 53 #define TYPF 4 /* float */ 54 #define TYPD 5 /* double */ 55 56 /* 57 * Addressing modes. 58 */ 59 #define LITSHORT 0x0 /* short literals */ 60 #define LITUPTO31 0x1 61 #define LITUPTO47 0x2 62 #define LITUPTO63 0x3 63 #define INDEX 0x4 /* i[r] */ 64 #define REG 0x5 /* r */ 65 #define REGDEF 0x6 /* (r) */ 66 #define AUTODEC 0x7 /* -(r) */ 67 #define AUTOINC 0x8 /* (r)+ */ 68 #define AUTOINCDEF 0x9 /* *(r)+ */ 69 #define BYTEDISP 0xA /* BD(r) */ 70 #define BYTEDISPDEF 0xB /* *BD(r) */ 71 #define WORDDISP 0xC /* WD(r) */ 72 #define WORDDISPDEF 0xD /* *WD(r) */ 73 #define LONGDISP 0xE /* LD(r) */ 74 #define LONGDISPDEF 0xF /* *LD(r) */ 75 76 #define is_branch_disp(arg) ((arg & ACCB) != 0) 77 #define typelen(arg) (arg & 07) 78 #define regnm(mode) (mode & 0xF) 79 #define addrmode(mode) (mode >> 4) 80 81 /* 82 * Certain opcodes values are used either in calculating 83 * the next address a process will go to, or for other 84 * random reasons -- these are defined here. 85 */ 86 #define O_AOBLEQ 0x3f 87 #define O_AOBLSS 0x2f 88 #define O_BBC 0x1e 89 #define O_BBS 0x0e 90 #define O_BBSSI 0x5f 91 #define O_BCC 0xf1 92 #define O_BCS 0xe1 93 #define O_BEQL 0x31 94 #define O_BGEQ 0x81 95 #define O_BGEQU 0xe1 96 #define O_BGTR 0x41 97 #define O_BGTRU 0xa1 98 #define O_BLEQ 0x51 99 #define O_BLEQU 0xb1 100 #define O_BLSS 0x91 101 #define O_BLSSU 0xf1 102 #define O_BNEQ 0x21 103 #define O_BPT 0x30 104 #define O_BRB 0x11 105 #define O_BRW 0x13 106 #define O_BTCS 0xce 107 #define O_BVC 0xc1 108 #define O_BVS 0xd1 109 #define O_CALLF 0xfe 110 #define O_CALLS 0xbf 111 #define O_CASEL 0xfc 112 #define O_JMP 0x71 113 #define O_KCALL 0xcf 114 #define O_RET 0x40 115 116 /* 117 * Operator information structure. 118 */ 119 typedef struct { 120 char *iname; 121 char val; 122 char numargs; 123 char argtype[6]; 124 } Optab; 125 126 #define SYSSIZE 151 /* # of system calls */ 127 #endif 128 129 #ifndef ADBINSTRS 130 #define ADBINSTRS "../../bin/adb/adb.tahoe/instrs.adb" 131 #endif 132 133 public Optab optab[] = { 134 #define OP(a,b,c,d,e,f,g,h,i) {a,b,c,d,e,f,g,h,i} 135 #include ADBINSTRS 136 0}; 137 138 /* 139 * Register names. 140 */ 141 142 public String regname[] = { 143 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 144 "r8", "r9", "r10","r11","r12", "fp", "sp", "pc" 145 }; 146 147 public String systab[SYSSIZE] = { 148 "indir", "exit", "fork", "read", 149 "write", "open", "close", "owait", 150 "creat", "link", "unlink", "execv", 151 "chdir", "otime", "mknod", "chmod", 152 "chown", "obreak", "ostat", "lseek", 153 "getpid", "mount", "umount", "osetuid", 154 "getuid", "ostime", "ptrace", "oalarm", 155 "ofstat", "opause", "outime", "ostty", 156 "ogtty", "access", "onice", "oftime", 157 "sync", "kill", "stat", "osetpgrp", 158 "lstat", "dup", "pipe", "otimes", 159 "profil", 0, "osetgid", "getgid", 160 "osig", 0, 0, "acct", 161 "ophys", "olock", "ioctl", "reboot", 162 "ompxchan", "symlink", "readlink", "execve", 163 "umask", "chroot", "fstat", 0, 164 "getpagesize", "mremap", "vfork", "ovread", 165 "ovwrite", "sbrk", "sstk", "mmap", 166 "ovadvise", "munmap", "mprotect", "madvise", 167 "vhangup", "ovlimit", "mincore", "getgroups", 168 "setgroups", "getpgrp", "setpgrp", "setitimer", 169 "wait", "swapon", "getitimer", "gethostname", 170 "sethostname", "getdtablesize","dup2", "getdopt", 171 "fcntl", "select", "setdopt", "fsync", 172 "setpriority", "socket", "connect", "accept", 173 "getpriority", "send", "recv", "osocketaddr", 174 "bind", "setsockopt", "listen", "ovtimes", 175 "sigvec", "sigblock", "sigsetmask", "sigpause", 176 "sigstack", "recvmsg", "sendmsg", "vtrace", 177 "gettimeofday", "getrusage", "getsockopt", "resuba", 178 "readv", "writev", "settimeofday", "fchown", 179 "fchmod", "recvfrom", "setreuid", "setregid", 180 "rename", "truncate", "ftruncate", "flock", 181 0, "sendto", "shutdown", "socketpair", 182 "mkdir", "rmdir", "utimes", 0, 183 0, "getpeername", "gethostid", "sethostid", 184 "getrlimit", "setrlimit", "killpg", 0, 185 "quota", "qquota", "getsockname", 186 }; 187