|
|
1.1 ! root 1: /* Copyright (c) 1982 Regents of the University of California */ ! 2: ! 3: static char sccsid[] = "@(#)asm.c 1.2 12/15/82"; ! 4: ! 5: /* ! 6: * Assembly language dependent symbol routines. ! 7: */ ! 8: ! 9: #include "defs.h" ! 10: #include "symbols.h" ! 11: #include "asm.h" ! 12: #include "languages.h" ! 13: #include "tree.h" ! 14: #include "eval.h" ! 15: #include "operators.h" ! 16: #include "mappings.h" ! 17: #include "process.h" ! 18: #include "runtime.h" ! 19: #include "machine.h" ! 20: ! 21: #define isdouble(range) ( \ ! 22: range->symvalue.rangev.upper == 0 and range->symvalue.rangev.lower > 0 \ ! 23: ) ! 24: ! 25: /* ! 26: * Initialize assembly language information. ! 27: */ ! 28: ! 29: public asm_init() ! 30: { ! 31: Language lang; ! 32: ! 33: lang = language_define("assembler", ".s"); ! 34: language_setop(lang, L_PRINTDECL, asm_printdecl); ! 35: language_setop(lang, L_PRINTVAL, asm_printval); ! 36: language_setop(lang, L_TYPEMATCH, asm_typematch); ! 37: } ! 38: ! 39: /* ! 40: * Test if two types are compatible. ! 41: */ ! 42: ! 43: public Boolean asm_typematch(type1, type2) ! 44: Symbol type1, type2; ! 45: { ! 46: Boolean b; ! 47: ! 48: b = false; ! 49: return b; ! 50: } ! 51: ! 52: public asm_printdecl(s) ! 53: Symbol s; ! 54: { ! 55: switch (s->class) { ! 56: case VAR: ! 57: case REF: ! 58: printf("&%s = 0x%x", symname(s), s->symvalue.offset); ! 59: break; ! 60: ! 61: case PROC: ! 62: case FUNC: ! 63: printf("%s (0x%x):", symname(s), codeloc(s)); ! 64: break; ! 65: ! 66: default: ! 67: error("class %s in c_printdecl", classname(s)); ! 68: } ! 69: putchar('\n'); ! 70: } ! 71: ! 72: /* ! 73: * Print out the value on the top of the expression stack ! 74: * in the format for the type of the given symbol. ! 75: */ ! 76: ! 77: public asm_printval(s) ! 78: register Symbol s; ! 79: { ! 80: register Symbol t; ! 81: register Integer len; ! 82: ! 83: switch (s->class) { ! 84: case ARRAY: ! 85: t = rtype(s->type); ! 86: if (t->class == RANGE and istypename(t->type, "$char")) { ! 87: len = size(s); ! 88: sp -= len; ! 89: printf("\"%.*s\"", len, sp); ! 90: } else { ! 91: printarray(s); ! 92: } ! 93: break; ! 94: ! 95: default: ! 96: printf("0x%x", pop(Integer)); ! 97: break; ! 98: } ! 99: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.