BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
staticslib.c File Reference
#include "blitzlib.h"

Data Structures

struct  staticent

Functions

void allocst (void)
void locallocst (void)
 $C501 (localstat) - allocate the NEWTYPE memory of local statics.
static void alloc_statics (const struct staticent *tab, UWORD n, UBYTE *base)
static void allocst_c (const struct staticent *tab, UWORD n)
 $C500 (alstat) - allocate the NEWTYPE memory of global statics.

Function Documentation

◆ alloc_statics()

void alloc_statics ( const struct staticent * tab,
UWORD n,
UBYTE * base )
static

◆ allocst()

void allocst ( void )

◆ allocst_c()

void allocst_c ( const struct staticent * tab,
UWORD n )
static

$C500 (alstat) - allocate the NEWTYPE memory of global statics.

For every table entry a cleared block of size bytes (memlib localloc) is allocated and its address stored at offset from a5. a0/a1 are preserved (memlib's localloc keeps them, so the original does too).

Parameters
taba2: the compiler's table (calcstatic, blitz2.s 6740)
nd4: the number of entries - 1

◆ locallocst()

void locallocst ( void )

$C501 (localstat) - allocate the NEWTYPE memory of local statics.

The loop of alstat in assembler, with a0 = the table, a1 = the offset from a4, d4 = the count, around memlib localloc (which keeps a0-a1). Saves d0-d1/d4 and changes a0/a1 only: C cannot keep d0/d1 without a thunk. Fixed (#1063): the original changes d2 (the offset) and d4 (the DBF count) although the compiler calls it in the procedure prologue with the parameters still in d0-d5, so the third parameter of a procedure with a local NEWTYPE variable was wrong (a fifth one too, if the compiler did not save d4); it also leaves a2 behind the table. Here only a0/a1 change (test: library cases "d2 kept" and "d4 kept", bug-orig test staticslib-localstat-d2).

As alstat, with the offsets from a4 (the original swaps a4/a5 around a call of allocst). Keeps d0-d7/a2-a6: the compiler calls it in the procedure prologue with the parameters in d0-d5 (perf-analysis thunks.md 1.4); a0 and a1 are free (the original keeps them), no third-party library calls it.

  • a2 tab, the compiler's table (calcstatic, blitz2.s 6740)
  • d4 n, the number of entries - 1