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

Functions

void stringass (void)
 $C700 (lastring) / $C701 (astring) - assign the string at a3 to a local / global string variable.
void gstringass (void)
static void strcopy_c (ULONG len, UBYTE *d)
 the copy of lastring/astring: the characters from a3 to the variable's memory, then the terminating 0 ('nofree, BL_STRCOPY; 'endass: CLR.b (a1)); a3 is advanced by len.

Function Documentation

◆ gstringass()

void gstringass ( void )

◆ strcopy_c()

void strcopy_c ( ULONG len,
UBYTE * d )
static

the copy of lastring/astring: the characters from a3 to the variable's memory, then the terminating 0 ('nofree, BL_STRCOPY; 'endass: CLR.b (a1)); a3 is advanced by len.

Uses only d0, d1, a0, a1 and a3 and saves nothing (checked in the disassembly), so the front end around it saves only d1.

Parameters
lend0: the length
da0: the characters of the variable

◆ stringass()

void stringass ( void )

$C700 (lastring) / $C701 (astring) - assign the string at a3 to a local / global string variable.

The original's front end: if the new string fits into the allocated length, the memory is reused and only its length set (CMP.l -8(a1),d0:BHI 'lengthen); otherwise the old memory, if there is one, is freed ('lengthen: alloc'd len + 9 bytes, JSR 4(a6) locfree), len + 9 bytes are allocated ('allocnews: JSR (a6) localloc, MEMF_PUBLIC), both lengths set to len and the address of the characters stored in the variable. gstringass adds 8 to a6 first (globalloc/globfree) and falls into stringass, as in the original: a6 stays +8. Then strcopy_c copies the characters (C, BL_STRCOPY). The original skips the copy for a string of length 0 that fits (BEQ 'endass); here strcopy_c writes only the 0 then.

Registers: the compiler relies on d1-d7 and a2 across the call (the later string parameters of a procedure are still in d1-d5; a comma list of assignments advances a2 after it, thunks.md 1.4); d1 is saved (the alloc flags, BL_STRCOPY), memlib and strcopy_c keep the others. The length is removed from the stack (MOVE.l (a7)+,(a7):RTS).

  • 4(a7) len, the length, removed by the routine
  • a2 var, the address of the string variable
  • a6 mem, memlib's membase table