add info on mpcc; remove extraneous paragraph, minor cleanup
[unix-history] / usr / src / old / dbx / asm.c
CommitLineData
2a24676e
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
a63d483c 6
2a24676e 7#ifndef lint
adbf81b2 8static char sccsid[] = "@(#)asm.c 5.2 (Berkeley) %G%";
2a24676e 9#endif not lint
0022c355 10
adbf81b2 11static char rcsid[] = "$Header: asm.c,v 1.2 87/03/25 19:24:09 donn Exp $";
a63d483c
ML
12
13/*
14 * Assembly language dependent symbol routines.
15 */
16
17#include "defs.h"
18#include "symbols.h"
19#include "asm.h"
20#include "languages.h"
21#include "tree.h"
22#include "eval.h"
23#include "operators.h"
24#include "mappings.h"
25#include "process.h"
26#include "runtime.h"
27#include "machine.h"
28
29#define isdouble(range) ( \
30 range->symvalue.rangev.upper == 0 and range->symvalue.rangev.lower > 0 \
31)
32
33/*
34 * Initialize assembly language information.
35 */
36
37public asm_init()
38{
39 Language lang;
40
41 lang = language_define("assembler", ".s");
42 language_setop(lang, L_PRINTDECL, asm_printdecl);
43 language_setop(lang, L_PRINTVAL, asm_printval);
44 language_setop(lang, L_TYPEMATCH, asm_typematch);
0022c355
ML
45 language_setop(lang, L_BUILDAREF, asm_buildaref);
46 language_setop(lang, L_EVALAREF, asm_evalaref);
adbf81b2 47 language_setop(lang, L_MODINIT, asm_modinit);
2fd0f574
SL
48 language_setop(lang, L_HASMODULES, asm_hasmodules);
49 language_setop(lang, L_PASSADDR, asm_passaddr);
a63d483c
ML
50}
51
52/*
53 * Test if two types are compatible.
54 */
55
56public Boolean asm_typematch(type1, type2)
57Symbol type1, type2;
58{
59 Boolean b;
60
61 b = false;
62 return b;
63}
64
65public asm_printdecl(s)
66Symbol s;
67{
68 switch (s->class) {
0022c355
ML
69 case CONST:
70 printf("%s = %d", symname(s), s->symvalue.constval->value.lcon);
71 break;
72
a63d483c
ML
73 case VAR:
74 case REF:
75 printf("&%s = 0x%x", symname(s), s->symvalue.offset);
76 break;
77
78 case PROC:
79 case FUNC:
80 printf("%s (0x%x):", symname(s), codeloc(s));
81 break;
82
0022c355
ML
83 case TYPE:
84 printf("%s", symname(s));
85 break;
86
87 case ARRAY:
88 printf("$string");
89 break;
90
a63d483c 91 default:
0022c355
ML
92 printf("[%s]", classname(s));
93 break;
a63d483c
ML
94 }
95 putchar('\n');
96}
97
98/*
99 * Print out the value on the top of the expression stack
100 * in the format for the type of the given symbol.
101 */
102
103public asm_printval(s)
104register Symbol s;
105{
106 register Symbol t;
107 register Integer len;
108
109 switch (s->class) {
110 case ARRAY:
111 t = rtype(s->type);
112 if (t->class == RANGE and istypename(t->type, "$char")) {
113 len = size(s);
114 sp -= len;
115 printf("\"%.*s\"", len, sp);
116 } else {
117 printarray(s);
118 }
119 break;
120
121 default:
122 printf("0x%x", pop(Integer));
123 break;
124 }
125}
2fd0f574 126
0022c355
ML
127/*
128 * Treat subscripting as indirection through pointer to integer.
129 */
130
131public Node asm_buildaref(a, slist)
132Node a, slist;
133{
134 Symbol t, eltype;
135 Node p, r;
136
137 t = rtype(a->nodetype);
138 eltype = t->type;
139 p = slist->value.arg[0];
140 r = build(O_MUL, p, build(O_LCON, (long) size(eltype)));
141 r = build(O_ADD, build(O_RVAL, a), r);
142 r->nodetype = eltype;
143 return r;
144}
145
146/*
147 * Evaluate a subscript index. Assumes dimension is [0..n].
148 */
149
150public asm_evalaref(s, base, i)
151Symbol s;
152Address base;
153long i;
154{
155 Symbol t;
156
157 t = rtype(s);
158 push(long, base + i * size(t->type));
159}
160
adbf81b2
DS
161public asm_modinit (typetable)
162Symbol typetable[];
163{
164 /* nothing for right now */
165}
166
2fd0f574
SL
167public boolean asm_hasmodules ()
168{
169 return false;
170}
171
172public boolean asm_passaddr (param, exprtype)
173Symbol param, exprtype;
174{
175 return false;
176}