* 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 5.2 (Berkeley) %G%";
static char rcsid
[] = "$Header: asm.c,v 1.2 87/03/25 19:24:09 donn Exp $";
* Assembly language dependent symbol routines.
#define isdouble(range) ( \
range->symvalue.rangev.upper == 0 and range->symvalue.rangev.lower > 0 \
* Initialize assembly language information.
lang
= language_define("assembler", ".s");
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_MODINIT
, asm_modinit
);
language_setop(lang
, L_HASMODULES
, asm_hasmodules
);
language_setop(lang
, L_PASSADDR
, asm_passaddr
);
* Test if two types are compatible.
public Boolean
asm_typematch(type1
, type2
)
printf("%s = %d", symname(s
), s
->symvalue
.constval
->value
.lcon
);
printf("&%s = 0x%x", symname(s
), s
->symvalue
.offset
);
printf("%s (0x%x):", symname(s
), codeloc(s
));
printf("%s", symname(s
));
printf("[%s]", classname(s
));
* Print out the value on the top of the expression stack
* in the format for the type of the given symbol.
if (t
->class == RANGE
and istypename(t
->type
, "$char")) {
printf("\"%.*s\"", len
, sp
);
printf("0x%x", pop(Integer
));
* Treat subscripting as indirection through pointer to integer.
public Node
asm_buildaref(a
, slist
)
r
= build(O_MUL
, p
, build(O_LCON
, (long) size(eltype
)));
r
= build(O_ADD
, build(O_RVAL
, a
), r
);
* Evaluate a subscript index. Assumes dimension is [0..n].
public asm_evalaref(s
, base
, i
)
push(long, base
+ i
* size(t
->type
));
public asm_modinit (typetable
)
/* nothing for right now */
public boolean
asm_hasmodules ()
public boolean
asm_passaddr (param
, exprtype
)