//MACRO Avl.__setpa PReg, DReg, SReg, AReg, Balance, Link, Clear, ParentField //-------------------------------------------------------------------------------------------------- // // @ CopyRight Roberti & Parau Enterprises, Inc. 2021-2023 // // This work is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License. // To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/4.0/ // or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. // //-------------------------------------------------------------------------------------------------- // if (Label !== "") DVASM.formatLine(Label, "BYTE", "0[0]", ""); // // Get store MI and word length // eval(DVASM.getEnv()[4]); var st= "S" + abiWID; var ndx; // // Check parameters // ndx= ["CLEAR", "NOCLEAR"].indexOf(Clear.toUpperCase()); if (ndx < 0) return DVASM.putError("Positional parameter [" + Clear.toUpperCase() + "] is invalid"); Clear= (ndx == 0); if (Balance === "" && Link === "" && AReg === "") return DVASM.putError("Positional parameters [AReg], [Balance] and [Link] are all null"); var bits= 0; var mask= 0; var insComm= ""; if (Balance !== "") { ndx = ["PLUS", "EVEN", "MINUS"].indexOf(Balance.toUpperCase()); if (ndx < 0) return DVASM.putError("Positional parameter Balance [" + Balance.toUpperCase() + "] is invalid"); bits|= [2, 1, 0][ndx]; mask|= 3; insComm= "balance"; } if (Link !== "") { ndx= ["RIGHT", "LEFT"].indexOf(Link); if (ndx < 0) return DVASM.putError("Positional parameter Link [" + Link.toUpperCase() + "] is invalid"); bits|= ndx << 2; mask|= 4; if (insComm === "") insComm= "link"; else insComm= insComm + " and link"; } insComm= "Set " + insComm + " bits"; var andMask= -mask-1; if (AReg !== "") andMask+= +8; if (andMask == 0) DVASM.formatLine("", "ORI", DReg + ", " + bits + "[" + AReg + "]", "// Set parent addr, link type and balance"); else if (bits == mask && AReg === "") DVASM.formatLine("", "ORI", DReg + ", " + bits + "[" + SReg + "]", "// " + insComm); else if (Clear) { DVASM.formatLine("", "ANDI", DReg + ", " + andMask + "[" + SReg + "]", "// Clear bits"); if (bits != 0) DVASM.formatLine("", "ORI", DReg + ", " + bits + "[" + DReg + "]", "// " + insComm); if (AReg !== "") DVASM.formatLine("", "OR", DReg +", " + AReg, "// Insert new parent addr"); } else { if (bits == 0) { if (AReg === "") { if (PReg === "") { if (DReg !== SReg) DVASM.formatLine("", "MV", DReg + ", " + SReg, "// Copy parent field - " + insComm); else DVASM.formatLine("", "", "", "// " + insComm + " - NoOp"); } else return DVASM.formatLine("", st, SReg + ", " + ParentField + "[" + PReg + "]", "// Store parent field into node - " + insComm); } else { if (PReg === "") DVASM.formatLine("", "MV", DReg + ", " + AReg, "// Copy parent addr - " + insComm); else return DVASM.formatLine("", st, SReg + ", " + ParentField + "[" + PReg + "]", "// Store parent field into node - " + insComm); } } else { DVASM.formatLine("", "ORI", DReg + ", " + bits + "[" + SReg + "]", "// " + insComm); if (AReg !== "") DVASM.formatLine("", "OR", DReg +", " + AReg, "// Insert new parent addr"); } } if (PReg !== "") DVASM.formatLine("", st, DReg + ", " + ParentField + "[" + PReg + "]", "// Store result in parent field");