restore keywords
[unix-history] / usr / src / old / dbx / asm.c
index fb2ce4f..8845123 100644 (file)
@@ -1,6 +1,14 @@
-/* Copyright (c) 1982 Regents of the University of California */
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
 
 
-static char sccsid[] = "@(#)@(#)asm.c 1.1 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)asm.c      5.1 (Berkeley) %G%";
+#endif not lint
+
+static char rcsid[] = "$Header: asm.c,v 1.5 84/12/26 10:38:19 linton Exp $";
 
 /*
  * Assembly language dependent symbol routines.
 
 /*
  * Assembly language dependent symbol routines.
@@ -34,6 +42,10 @@ public asm_init()
     language_setop(lang, L_PRINTDECL, asm_printdecl);
     language_setop(lang, L_PRINTVAL, asm_printval);
     language_setop(lang, L_TYPEMATCH, asm_typematch);
     language_setop(lang, L_PRINTDECL, asm_printdecl);
     language_setop(lang, L_PRINTVAL, asm_printval);
     language_setop(lang, L_TYPEMATCH, asm_typematch);
+    language_setop(lang, L_BUILDAREF, asm_buildaref);
+    language_setop(lang, L_EVALAREF, asm_evalaref);
+    language_setop(lang, L_HASMODULES, asm_hasmodules);
+    language_setop(lang, L_PASSADDR, asm_passaddr);
 }
 
 /*
 }
 
 /*
@@ -53,6 +65,10 @@ public asm_printdecl(s)
 Symbol s;
 {
     switch (s->class) {
 Symbol s;
 {
     switch (s->class) {
+       case CONST:
+           printf("%s = %d", symname(s), s->symvalue.constval->value.lcon);
+           break;
+
        case VAR:
        case REF:
            printf("&%s = 0x%x", symname(s), s->symvalue.offset);
        case VAR:
        case REF:
            printf("&%s = 0x%x", symname(s), s->symvalue.offset);
@@ -63,8 +79,17 @@ Symbol s;
            printf("%s (0x%x):", symname(s), codeloc(s));
            break;
 
            printf("%s (0x%x):", symname(s), codeloc(s));
            break;
 
+       case TYPE:
+           printf("%s", symname(s));
+           break;
+
+       case ARRAY:
+           printf("$string");
+           break;
+
        default:
        default:
-           error("class %s in c_printdecl", classname(s));
+           printf("[%s]", classname(s));
+           break;
     }
     putchar('\n');
 }
     }
     putchar('\n');
 }
@@ -97,3 +122,48 @@ register Symbol s;
            break;
     }
 }
            break;
     }
 }
+
+/*
+ * Treat subscripting as indirection through pointer to integer.
+ */
+
+public Node asm_buildaref(a, slist)
+Node a, slist;
+{
+    Symbol t, eltype;
+    Node p, r;
+
+    t = rtype(a->nodetype);
+    eltype = t->type;
+    p = slist->value.arg[0];
+    r = build(O_MUL, p, build(O_LCON, (long) size(eltype)));
+    r = build(O_ADD, build(O_RVAL, a), r);
+    r->nodetype = eltype;
+    return r;
+}
+
+/*
+ * Evaluate a subscript index.  Assumes dimension is [0..n].
+ */
+
+public asm_evalaref(s, base, i)
+Symbol s;
+Address base;
+long i;
+{
+    Symbol t;
+
+    t = rtype(s);
+    push(long, base + i * size(t->type));
+}
+
+public boolean asm_hasmodules ()
+{
+    return false;
+}
+
+public boolean asm_passaddr (param, exprtype)
+Symbol param, exprtype;
+{
+    return false;
+}