1*48069Sbostic /*- 2*48069Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*48069Sbostic * All rights reserved. 4*48069Sbostic * 5*48069Sbostic * %sccs.include.redist.c% 622557Sdist */ 75536Slinton 822557Sdist #ifndef lint 9*48069Sbostic static char sccsid[] = "@(#)assign.c 5.3 (Berkeley) 04/16/91"; 10*48069Sbostic #endif /* not lint */ 115536Slinton 125536Slinton /* 135536Slinton * assign the value of an expression to a variable (or term) 145536Slinton */ 155536Slinton 165536Slinton #include "defs.h" 175536Slinton #include "tree.h" 185536Slinton #include "sym.h" 195536Slinton #include "process.h" 205536Slinton #include "tree.rep" 2130852Smckusick #include "process/process.rep" 2230852Smckusick #include "process/pxinfo.h" 235536Slinton 245536Slinton assign(var, exp) 255536Slinton NODE *var; 265536Slinton NODE *exp; 275536Slinton { 285536Slinton ADDRESS addr; 295536Slinton int varsize; 305536Slinton char cvalue; 315536Slinton short svalue; 325536Slinton long lvalue; 335536Slinton 345536Slinton if (!compatible(var->nodetype, exp->nodetype)) { 355536Slinton error("incompatible types"); 365536Slinton } 375536Slinton addr = lval(var); 385536Slinton eval(exp); 395536Slinton varsize = size(var->nodetype); 405536Slinton if (varsize < sizeof(long)) { 415536Slinton lvalue = pop(long); 425536Slinton switch (varsize) { 435536Slinton case sizeof(char): 445536Slinton cvalue = lvalue; 455536Slinton dwrite(&cvalue, addr, varsize); 465536Slinton break; 475536Slinton 485536Slinton case sizeof(short): 495536Slinton svalue = lvalue; 505536Slinton dwrite(&svalue, addr, varsize); 515536Slinton break; 525536Slinton 535536Slinton default: 5430852Smckusick goto othersize; 5530852Smckusick /* 565536Slinton panic("bad size %d", varsize); 5730852Smckusick */ 585536Slinton } 595536Slinton } else { 6030852Smckusick othersize: 615536Slinton sp -= varsize; 625536Slinton dwrite(sp, addr, varsize); 6330852Smckusick #ifdef tahoe 6430852Smckusick downalignstack(); 6530852Smckusick #endif 665536Slinton } 675536Slinton } 68