//MACRO Entry Stack=!"", Stamp= !"", BaseReg[2]= [!"", !""], Export{boolean}= true //-------------------------------------------------------------------------------------------------- // // @ 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. // //-------------------------------------------------------------------------------------------------- // // // Check parameters // if (Label === "") return DVASM.putError("Label required for macro ENTRY"); if (Export) DVASM.formatLine("", "EXPORT", Label, ""); if (Stamp !== "") DVASM.formatLine("", Stamp, Label, ""); DVASM.formatLine(Label, "DWRD", "0[0]", ""); // // Stack is defined // if (Stack !== "") { var stackLabel= Stack + "."; // // Get right load/store MIs and word length // eval(DVASM.getEnv()[4]); var saveOpCode= "S" + abiWID; // // Standard linkage // DVASM.formatLine("", "ADDI", "sp,-" + stackLabel + "StackLen", "// Set sp to point to new stack frame"); DVASM.formatLine("", "BASESET", Stack + ", sp", "// Tell assembler about stack base"); DVASM.formatLine("", saveOpCode, "ra, " + stackLabel + "ra", "// Save ra"); // // Save registers // var lbl= stackLabel + "s"; for (var i= 0; i < (abiNoRegs <= 16 ? 2 : 12); i++) DVASM.formatLine("", saveOpCode, "s" + i + "," + lbl + i + ", Cond=YES", ""); // // Save float registers if any // if (abiNoFRegs > 0) { lbl= stackLabel + "fs"; var saveFloatOpCode= ("FS" + abiFWID); for (var i= 0; i < 12; i++) DVASM.formatLine("", saveFloatOpCode, "fs" + i + ", " + lbl + i + ", Cond=YES", ""); } } // // Set code base register if specified // if (BaseReg[0] !== "") { var lbl= DVASM.getNewLabel(); var displ20= "((" + BaseReg[1] + "-" + lbl + " + 0x1000) & 0xFFFFF000)"; var displ12= "(" + BaseReg[1] + "-" + lbl + " + 0x800) - " + displ20; DVASM.formatLine(lbl, "AUIPC", BaseReg[0] + ", " + displ20, "// Load 20 high bits displacement"); DVASM.formatLine("", "ADDI", BaseReg[0] + ", " + displ12, "// Add 12 bits low displacement"); DVASM.formatLine("", "BASESET", BaseReg[1] + "+0x800, " + BaseReg[0], "// Tell assembler about base"); }