|
|
1.1 root 1: /*
2: * Copyright (c) 1983 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)ops.vax.c 5.10 (Berkeley) 6/30/90";
22: #endif /* not lint */
23:
24: /*
25: * Machine operators.
26: */
27:
28: #include "defs.h"
29: #include "ops.h"
30:
31: #ifndef public
32: typedef unsigned char VaxOpcode;
33:
34: #define O_HALT 0x00 /* halt */
35: #define O_NOP 0x01 /* no operation */
36: #define O_REI 0x02 /* return from exception or interrupt */
37: #define O_BPT 0x03 /* break point fault */
38: #define O_RET 0x04 /* return from called procedure */
39: #define O_RSB 0x05 /* return from subroutine */
40: #define O_LDPCTX 0x06 /* load process context */
41: #define O_SVPCTX 0x07 /* save process context */
42: #define O_CVTPS 0x08 /* convert packed to leading separate numeric */
43: #define O_CVTSP 0x09 /* convert leading separate numeric to packed */
44: #define O_INDEX 0x0A /* compute index */
45: #define O_CRC 0x0B /* calculate cyclic redundancy check */
46: #define O_PROBER 0x0C /* probe read access */
47: #define O_PROBEW 0x0D /* probe write access */
48: #define O_INSQUE 0x0E /* insert into queue */
49: #define O_REMQUE 0x0F /* remove from queue */
50: #define O_BSBB 0x10 /* branch to subroutine with byte disp */
51: #define O_BRB 0x11 /* branch with byte disp */
52: #define O_BNEQ 0x12 /* branch on not equal (also BNEQU) */
53: #define O_BEQL 0x13 /* branch on equal (also BEQLU */
54: #define O_BGTR 0x14 /* branch on greater */
55: #define O_BLEQ 0x15 /* branch on less or equal */
56: #define O_JSB 0x16 /* jump to subroutine */
57: #define O_JMP 0x17 /* jump */
58: #define O_BGEQ 0x18 /* branch on greater or equal */
59: #define O_BLSS 0x19 /* branch on less */
60: #define O_BGTRU 0x1A /* branch on greater unsigned */
61: #define O_BLEQU 0x1B /* branch on less of equal unsigned */
62: #define O_BVC 0x1C /* branch on overflow clear */
63: #define O_BVS 0x1D /* branch on overflow set */
64: #define O_BCC 0x1E /* branch on carry clear (also BGEQU) */
65: #define O_BCS 0x1F /* branch on carry set (also BLSSU) */
66: #define O_ADDP4 0x20 /* add packed 4 operand */
67: #define O_ADDP6 0x21 /* add packed 6 operand */
68: #define O_SUBP4 0x22 /* subtract packed 4 operand */
69: #define O_SUBP6 0x23 /* subtract packed 6 operand */
70: #define O_CVTPT 0x24 /* convert packed to trailing numeric */
71: #define O_MULP 0x25 /* multiply packed */
72: #define O_CVTTP 0x26 /* convert trailing numeric to packed */
73: #define O_DIVP 0x27 /* divide packed */
74: #define O_MOVC3 0x28 /* move character 3 operand */
75: #define O_CMPC3 0x29 /* compare character 3 operand */
76: #define O_SCANC 0x2A /* scan for character */
77: #define O_SPANC 0x2B /* span characters */
78: #define O_MOVC5 0x2C /* move character 5 operand */
79: #define O_CMPC5 0x2D /* compare character 5 operand */
80: #define O_MOVTC 0x2E /* move translated characters */
81: #define O_MOVTUC 0x2F /* move translated until character */
82: #define O_BSBW 0x30 /* branch to subroutine with word disp */
83: #define O_BRW 0x31 /* branch with word disp */
84: #define O_CVTWL 0x32 /* convert word to long */
85: #define O_CVTWB 0x33 /* convert word to byte */
86: #define O_MOVP 0x34 /* move packed */
87: #define O_CMPP3 0x35 /* compare packed 3 operand */
88: #define O_CVTPL 0x36 /* convert packed to long */
89: #define O_CMPP4 0x37 /* compare packed 4 operand */
90: #define O_EDITPC 0x38 /* edit packed to character */
91: #define O_MATCHC 0x39 /* match characters */
92: #define O_LOCC 0x3A /* locate characters */
93: #define O_SKPC 0x3B /* skip character */
94: #define O_MOVZWL 0x3C /* move zero-extended word to long */
95: #define O_ACBW 0x3D /* add compare and branch word */
96: #define O_MOVAW 0x3E /* move address of word */
97: #define O_PUSHAW 0x3F /* push address of word */
98: #define O_ADDF2 0x40 /* add floating 2 operand */
99: #define O_ADDF3 0x41 /* add floating 3 operand */
100: #define O_SUBF2 0x42 /* subtract floating 2 operand */
101: #define O_SUBF3 0x43 /* subtract floating 3 operand */
102: #define O_MULF2 0x44 /* multiply floating 2 operand */
103: #define O_MULF3 0x45 /* multiply floating 3 operand */
104: #define O_DIVF2 0x46 /* divide floating 2 operand */
105: #define O_DIVF3 0x47 /* divide floating 3 operand */
106: #define O_CVTFB 0x48 /* convert float to byte */
107: #define O_CVTFW 0x49 /* convert float to word */
108: #define O_CVTFL 0x4A /* convert float to long */
109: #define O_CVTRFL 0x4B /* convert rounded float to long */
110: #define O_CVTBF 0x4C /* convert byte to float */
111: #define O_CVTWF 0x4D /* convert word to float */
112: #define O_CVTLF 0x4E /* convert long to float */
113: #define O_ACBF 0x4F /* add compare and branch floating */
114: #define O_MOVF 0x50 /* move float */
115: #define O_CMPF 0x51 /* compare floating */
116: #define O_MNEGF 0x52 /* move negated floating */
117: #define O_TSTF 0x53 /* test float */
118: #define O_EMODF 0x54 /* extended modulus floating */
119: #define O_POLYF 0x55 /* evaluate polynomial floating */
120: #define O_CVTFD 0x56 /* convert float to double */
121: #define O_DUMMY57 0x57 /* RESERVED to DIGITAL */
122: #define O_ADAWI 0x58 /* add aligned word interlocked */
123: #define O_DUMMY59 0x59 /* RESERVED to DIGITAL */
124: #define O_DUMMY5a 0x5A /* RESERVED to DIGITAL */
125: #define O_DUMMY5b 0x5B /* RESERVED to DIGITAL */
126: #define O_INSQHI 0x5C /* insert into queue head, interlocked */
127: #define O_INSQTI 0x5D /* insert into queue tail, interlocked */
128: #define O_REMQHI 0x5E /* remove from queue head, interlocked */
129: #define O_REMQTI 0x5F /* remove from queue tail, interlocked */
130: #define O_ADDD2 0x60 /* add double 2 operand */
131: #define O_ADDD3 0x61 /* add double 3 operand */
132: #define O_SUBD2 0x62 /* subtract double 2 operand */
133: #define O_SUBD3 0x63 /* subtrace double 3 operand */
134: #define O_MULD2 0x64 /* multiply double 2 operand */
135: #define O_MULD3 0x65 /* multiply double 3 operand */
136: #define O_DIVD2 0x66 /* divide double 2 operand */
137: #define O_DIVD3 0x67 /* divide double 3 operand */
138: #define O_CVTDB 0x68 /* convert double to byte */
139: #define O_CVTDW 0x69 /* convert double to word */
140: #define O_CVTDL 0x6A /* convert double to long */
141: #define O_CVTRDL 0x6B /* convert rounded double to long */
142: #define O_CVTBD 0x6C /* convert byte to double */
143: #define O_CVTWD 0x6D /* convert word to double */
144: #define O_CVTLD 0x6E /* convert long to double */
145: #define O_ACBD 0x6F /* add compare and branch double */
146: #define O_MOVD 0x70 /* move double */
147: #define O_CMPD 0x71 /* compare double */
148: #define O_MNEGD 0x72 /* move negated double */
149: #define O_TSTD 0x73 /* test double */
150: #define O_EMODD 0x74 /* extended modulus double */
151: #define O_POLYD 0x75 /* evaluate polynomial double */
152: #define O_CVTDF 0x76 /* convert double to float */
153: #define O_DUMMY77 0x77 /* RESERVED to DIGITAL */
154: #define O_ASHL 0x78 /* arithmetic shift long */
155: #define O_ASHQ 0x79 /* arithmetic shift quad */
156: #define O_EMUL 0x7A /* extended multiply */
157: #define O_EDIV 0x7B /* extended divide */
158: #define O_CLRQ 0x7C /* clear quad (also CLRD) */
159: #define O_MOVQ 0x7D /* move quad */
160: #define O_MOVAQ 0x7E /* move address of quad (also MOVAD) */
161: #define O_PUSHAQ 0x7F /* push address of quad (also PUSHAD) */
162: #define O_ADDB2 0x80 /* add byte 2 operand */
163: #define O_ADDB3 0x81 /* add byte 3 operand */
164: #define O_SUBB2 0x82 /* subtract byte 2 operand */
165: #define O_SUBB3 0x83 /* subtract byte 3 operand */
166: #define O_MULB2 0x84 /* multiply byte 2 operand */
167: #define O_MULB3 0x85 /* multiply byte 3 operand */
168: #define O_DIVB2 0x86 /* divide byte 2 operand */
169: #define O_DIVB3 0x87 /* divide byte 3 operand */
170: #define O_BISB2 0x88 /* bit set byte 2 operand */
171: #define O_BISB3 0x89 /* bit set byte 3 operand */
172: #define O_BICB2 0x8A /* bit clear byte 2 operand */
173: #define O_BICB3 0x8B /* bit clear byte 3 operand */
174: #define O_XORB2 0x8C /* exclusive or byte 2 operand */
175: #define O_XORB3 0x8D /* exclusive or byte 3 operand */
176: #define O_MNEGB 0x8E /* move negated byte */
177: #define O_CASEB 0x8F /* case byte */
178: #define O_MOVB 0x90 /* move byte */
179: #define O_CMPB 0x91 /* compare byte */
180: #define O_MCOMB 0x92 /* move complemented byte */
181: #define O_BITB 0x93 /* bit test byte */
182: #define O_CLRB 0x94 /* clear byte */
183: #define O_TSTB 0x95 /* test byte */
184: #define O_INCB 0x96 /* increment byte */
185: #define O_DECB 0x97 /* decrement byte */
186: #define O_CVTBL 0x98 /* convert byte to long */
187: #define O_CVTBW 0x99 /* convert byte to word */
188: #define O_MOVZBL 0x9A /* move zero-extended byte to long */
189: #define O_MOVZBW 0x9B /* move zero-extended byte to word */
190: #define O_ROTL 0x9C /* rotate long */
191: #define O_ACBB 0x9D /* add compare and branch byte */
192: #define O_MOVAB 0x9E /* move address of byte */
193: #define O_PUSHAB 0x9F /* push address of byte */
194: #define O_ADDW2 0xA0 /* add word 2 operand */
195: #define O_ADDW3 0xA1 /* add word 3 operand */
196: #define O_SUBW2 0xA2 /* subtract word 2 operand */
197: #define O_SUBW3 0xA3 /* subtract word 3 operand */
198: #define O_MULW2 0xA4 /* multiply word 2 operand */
199: #define O_MULW3 0xA5 /* multiply word 3 operand */
200: #define O_DIVW2 0xA6 /* divide word 2 operand */
201: #define O_DIVW3 0xA7 /* divide word 3 operand */
202: #define O_BISW2 0xA8 /* bit set word 2 operand */
203: #define O_BISW3 0xA9 /* bit set word 3 operand */
204: #define O_BICW2 0xAA /* bit clear word 2 operand */
205: #define O_BICW3 0xAB /* bit clear word 3 operand */
206: #define O_XORW2 0xAC /* exclusive or word 2 operand */
207: #define O_XORW3 0xAD /* exclusive or word 3 operand */
208: #define O_MNEGW 0xAE /* move negated word */
209: #define O_CASEW 0xAF /* case word */
210: #define O_MOVW 0xB0 /* move word */
211: #define O_CMPW 0xB1 /* compare word */
212: #define O_MCOMW 0xB2 /* move complemented word */
213: #define O_BITW 0xB3 /* bit test word */
214: #define O_CLRW 0xB4 /* clear word */
215: #define O_TSTW 0xB5 /* test word */
216: #define O_INCW 0xB6 /* increment word */
217: #define O_DECW 0xB7 /* decrement word */
218: #define O_BISPSW 0xB8 /* bit set processor status word */
219: #define O_BICPSW 0xB9 /* bit clear processor status word */
220: #define O_POPR 0xBA /* pop register */
221: #define O_PUSHR 0xBB /* push register */
222: #define O_CHMK 0xBC /* change mode to kernel */
223: #define O_CHME 0xBD /* change mode to executive */
224: #define O_CHMS 0xBE /* change mode to supervisor */
225: #define O_CHMU 0xBF /* change mode to user */
226: #define O_ADDL2 0xC0 /* add long 2 operand */
227: #define O_ADDL3 0xC1 /* add long 3 operand */
228: #define O_SUBL2 0xC2 /* subtract long 2 operand */
229: #define O_SUBL3 0xC3 /* subtract long 3 operand */
230: #define O_MULL2 0xC4 /* multiply long 2 operand */
231: #define O_MULL3 0xC5 /* multiply long 3 operand */
232: #define O_DIVL2 0xC6 /* divide long 2 operand */
233: #define O_DIVL3 0xC7 /* divide long 3 operand */
234: #define O_BISL2 0xC8 /* bit set long 2 operand */
235: #define O_BISL3 0xC9 /* bit set long 3 operand */
236: #define O_BICL2 0xCA /* bit clear long 2 operand */
237: #define O_BICL3 0xCB /* bit clear long 3 operand */
238: #define O_XORL2 0xCC /* exclusive or long 2 operand */
239: #define O_XORL3 0xCD /* exclusive or long 3 operand */
240: #define O_MNEGL 0xCE /* move negated long */
241: #define O_CASEL 0xCF /* case long */
242: #define O_MOVL 0xD0 /* move long */
243: #define O_CMPL 0xD1 /* compare long */
244: #define O_MCOML 0xD2 /* move complemented long */
245: #define O_BITL 0xD3 /* bit test long */
246: #define O_CLRL 0xD4 /* clear long (also CLRF) */
247: #define O_TSTL 0xD5 /* test long */
248: #define O_INCL 0xD6 /* increment long */
249: #define O_DECL 0xD7 /* decrement long */
250: #define O_ADWC 0xD8 /* add with carry */
251: #define O_SBWC 0xD9 /* subtrace with carry */
252: #define O_MTPR 0xDA /* move to processor register */
253: #define O_MFPR 0xDB /* move from processor register */
254: #define O_MOVPSL 0xDC /* move processor status longword */
255: #define O_PUSHL 0xDD /* push long */
256: #define O_MOVAL 0xDE /* move address of long (also MOVAF) */
257: #define O_PUSHAL 0xDF /* push address of long (also PUSHAF) */
258: #define O_BBS 0xE0 /* branch on bit set */
259: #define O_BBC 0xE1 /* branch on bit clear */
260: #define O_BBSS 0xE2 /* branch on bit set and set */
261: #define O_BBCS 0xE3 /* branch on bit clear and set */
262: #define O_BBSC 0xE4 /* branch on bit set and clear */
263: #define O_BBCC 0xE5 /* branch on bit clear and clear */
264: #define O_BBSSI 0xE6 /* branch on bit set and set interlocked */
265: #define O_BBCCI 0xE7 /* branch on bit clear and clear interlocked */
266: #define O_BLBS 0xE8 /* branch on low bit set */
267: #define O_BLBC 0xE9 /* branch on low bit clear */
268: #define O_FFS 0xEA /* find first set bit */
269: #define O_FFC 0xEB /* find first clear bit */
270: #define O_CMPV 0xEC /* compare field */
271: #define O_CMPZV 0xED /* compare zero-extended field */
272: #define O_EXTV 0xEE /* extract field */
273: #define O_EXTZV 0xEF /* extract zero-extended field */
274: #define O_INSV 0xF0 /* insert field */
275: #define O_ACBL 0xF1 /* add compare and branch long */
276: #define O_AOBLSS 0xF2 /* add one and branch on less */
277: #define O_AOBLEQ 0xF3 /* add one and branch on less or equal */
278: #define O_SOBGEQ 0xF4 /* subtract one and branch on gtr or equal */
279: #define O_SOBGTR 0xF5 /* subtract one and branch on greater */
280: #define O_CVTLB 0xF6 /* convert long to byte */
281: #define O_CVTLW 0xF7 /* convert long to word */
282: #define O_ASHP 0xF8 /* arithmetic shift and round packed */
283: #define O_CVTLP 0xF9 /* convert long to packed */
284: #define O_CALLG 0xFA /* call with general argument list */
285: #define O_CALLS 0xFB /* call with stack */
286: #define O_XFC 0xFC /* extended function call */
287: #define O_ESCD 0xFD /* ESCD to DIGITAL */
288: #define O_ESCE 0xFE /* ESCE to DIGITAL */
289: #define O_ESCF 0xFF /* ESCF to DIGITAL */
290:
291: /*
292: * Addressing modes.
293: */
294:
295: #define LITSHORT 0x0 /* short literals */
296: #define LITUPTO31 0x1
297: #define LITUPTO47 0x2
298: #define LITUPTO63 0x3
299: #define INDEX 0x4 /* i[r] */
300: #define REG 0x5 /* r */
301: #define REGDEF 0x6 /* (r) */
302: #define AUTODEC 0x7 /* -(r) */
303: #define AUTOINC 0x8 /* (r)+ */
304: #define AUTOINCDEF 0x9 /* *(r)+ */
305: #define BYTEDISP 0xA /* BD(r) */
306: #define BYTEDISPDEF 0xB /* *BD(r) */
307: #define WORDDISP 0xC /* WD(r) */
308: #define WORDDISPDEF 0xD /* *WD(r) */
309: #define LONGDISP 0xE /* LD(r) */
310: #define LONGDISPDEF 0xF /* *LD(r) */
311:
312: #define is_branch_disp(arg) ((arg & ACCB) != 0)
313: #define typelen(arg) (arg & 0xF)
314: #define regnm(mode) (mode & 0xF)
315: #define addrmode(mode) (mode >> 4)
316:
317: /*
318: * Operator information structure.
319: */
320:
321: typedef struct {
322: char *iname;
323: unsigned char format;
324: unsigned char val;
325: char numargs;
326: char argtype[6];
327: } Optab;
328:
329: #ifndef ASINSTRS
330: #define ASINSTRS "../../pgrm/as.vax/instrs.h"
331: #endif
332:
333: #ifndef ADBINSTRS
334: #define ADBINSTRS "../../bin/adb/adb.vax/obj/instrs.adb"
335: #endif
336:
337: #define INSTTAB
338: #include ASINSTRS
339:
340: #endif
341:
342: #define OP(name,eopcode,popdcode,nargs,a1,a2,a3,a4,a5,a6) {name,eopcode,popdcode,nargs,a1,a2,a3,a4,a5,a6}
343:
344: public Optab optab[] = {
345: #include ADBINSTRS
346: 0};
347:
348: /*
349: * Register names.
350: */
351:
352: public String regname[] = {
353: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
354: "r8", "r9", "r10","r11","ap", "fp", "sp", "pc"
355: };
356:
357: /*
358: * Floating point immediate operands.
359: */
360:
361: public String fltimm[] = {
362: "0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875", "0.9375",
363: "1.0", "1.125", "1.25", "1.375", "1.5", "1.625", "1.75", "1.875",
364: "2.0", "2.25", "2.5", "2.75", "3.0", "3.25", "3.5", "3.75",
365: "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5",
366: "8.0", "9.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0",
367: "16.0", "18.0", "20.0", "22.0", "24.0", "26.0", "28.0", "30.0",
368: "32.0", "36.0", "40.0", "44.0", "48.0", "52.0", "56.0", "60.0",
369: "64.0", "72.0", "80.0", "88.0", "96.0", "104.0", "112.0", "120.0"
370: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.