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