MaxLen a$=n (tokens maxlen $D000 for a global, lmaxlen $D001 for a local string) - give a string variable a buffer of n characters.
domaxlenl - local string; domaxlen: global string, ADDQ #8,a6 first (an assembler entry in front of the C function, as in the original: a6 stays +8). The old memory is freed (len = alloc'd+9) and the variable cleared; for n <> 0, n+9 bytes are allocated: alloc'd len = n, string len 0, empty string. A statement of the compiler (perf-analysis thunks.md 1.4): nothing is live across it, no third-party library calls it; the C function keeps d2-d7/a2-a5 (and a6 for domaxlenl), a0 and a1 are free (the original leaves them unchanged on some paths only: no old memory / n = 0). DIFF: d2/a2 are kept (the original leaves n and the variable address there).
Errors: n < 0 is runtime error 1, but only with the debugger (echk1).
- Parameters
-
| var | d0: the address of the string variable. |
| n | d1: the maximum length. |
| mem | a6: memlib's membase table (!libs 65530,la6); +8 for the global versions. |
- Returns
- d0: the new variable contents (0 for n = 0).