1 /* Copyright (c) 1982 Regents of the University of California */ 2 3 static char sccsid[] = "@(#)asm.c 1.3 (Berkeley) 06/23/84"; 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 language_setop(lang, L_HASMODULES, asm_hasmodules); 38 language_setop(lang, L_PASSADDR, asm_passaddr); 39 } 40 41 /* 42 * Test if two types are compatible. 43 */ 44 45 public Boolean asm_typematch(type1, type2) 46 Symbol type1, type2; 47 { 48 Boolean b; 49 50 b = false; 51 return b; 52 } 53 54 public asm_printdecl(s) 55 Symbol s; 56 { 57 switch (s->class) { 58 case VAR: 59 case REF: 60 printf("&%s = 0x%x", symname(s), s->symvalue.offset); 61 break; 62 63 case PROC: 64 case FUNC: 65 printf("%s (0x%x):", symname(s), codeloc(s)); 66 break; 67 68 default: 69 error("class %s in c_printdecl", classname(s)); 70 } 71 putchar('\n'); 72 } 73 74 /* 75 * Print out the value on the top of the expression stack 76 * in the format for the type of the given symbol. 77 */ 78 79 public asm_printval(s) 80 register Symbol s; 81 { 82 register Symbol t; 83 register Integer len; 84 85 switch (s->class) { 86 case ARRAY: 87 t = rtype(s->type); 88 if (t->class == RANGE and istypename(t->type, "$char")) { 89 len = size(s); 90 sp -= len; 91 printf("\"%.*s\"", len, sp); 92 } else { 93 printarray(s); 94 } 95 break; 96 97 default: 98 printf("0x%x", pop(Integer)); 99 break; 100 } 101 } 102 103 public boolean asm_hasmodules () 104 { 105 return false; 106 } 107 108 public boolean asm_passaddr (param, exprtype) 109 Symbol param, exprtype; 110 { 111 return false; 112 } 113