+ /* Create space on the stack */
+ g_space (F->Reserved);
+
+ /* Correct the stack pointer */
+ oursp -= F->Reserved;
+
+ /* Nothing more reserved */
+ F->Reserved = 0;
+ }
+}
+
+
+
+int F_AllocRegVar (Function* F, const type* Type)
+/* Allocate a register variable for the given variable type. If the allocation
+ * was successful, return the offset of the register variable in the register
+ * bank (zero page storage). If there is no register space left, return -1.
+ */
+{
+ /* Allow register variables only on top level and if enabled */
+ if (EnableRegVars && GetLexicalLevel () == LEX_LEVEL_FUNCTION) {
+
+ /* Get the size of the variable */
+ unsigned Size = CheckedSizeOf (Type);
+
+ /* Do we have space left? */
+ if (F->RegOffs >= Size) {
+ /* Space left. We allocate the variables from high to low addresses,
+ * so the adressing is compatible with the saved values on stack.
+ * This allows shorter code when saving/restoring the variables.
+ */
+ F->RegOffs -= Size;
+ return F->RegOffs;
+ }
+ }
+
+ /* No space left or no allocation */
+ return -1;
+}
+
+
+
+static void F_RestoreRegVars (Function* F)
+/* Restore the register variables for the local function if there are any. */
+{
+ const SymEntry* Sym;
+
+ /* If we don't have register variables in this function, bail out early */
+ if (F->RegOffs == RegisterSpace) {
+ return;
+ }
+
+ /* Save the accumulator if needed */
+ if (!F_HasVoidReturn (F)) {
+ g_save (CF_CHAR | CF_FORCECHAR);
+ }
+
+ /* Get the first symbol from the function symbol table */
+ Sym = F->FuncEntry->V.F.Func->SymTab->SymHead;
+
+ /* Walk through all symbols checking for register variables */
+ while (Sym) {
+ if (SymIsRegVar (Sym)) {
+
+ /* Check for more than one variable */
+ int Offs = Sym->V.R.SaveOffs;
+ unsigned Bytes = CheckedSizeOf (Sym->Type);
+
+ while (1) {