ugBASIC
1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
clear.c
Go to the documentation of this file.
1
/*****************************************************************************
2
* ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3
*****************************************************************************
4
* Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*----------------------------------------------------------------------------
18
* Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19
* (la "Licenza"); è proibito usare questo file se non in conformità alla
20
* Licenza. Una copia della Licenza è disponibile all'indirizzo:
21
*
22
* http://www.apache.org/licenses/LICENSE-2.0
23
*
24
* Se non richiesto dalla legislazione vigente o concordato per iscritto,
25
* il software distribuito nei termini della Licenza è distribuito
26
* "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27
* implicite. Consultare la Licenza per il testo specifico che regola le
28
* autorizzazioni e le limitazioni previste dalla medesima.
29
****************************************************************************/
30
31
/****************************************************************************
32
* INCLUDE SECTION
33
****************************************************************************/
34
35
#include "
../../ugbc.h
"
36
37
/****************************************************************************
38
* CODE SECTION
39
****************************************************************************/
40
41
/* <usermanual>
42
@keyword CLEAR
43
44
@english
45
46
The ''CLEAR'' command serves two purposes: the primary semantics of the ''CLEAR''
47
command is to re-initialize (integers) variables to their starting values.
48
Which are usually zero but, of course, can be different from zero. At the moment,
49
their starting value is equal to the assignment during the definition. Other data
50
types (like FLOAT or BIT) are not re-initialized. This is especially useful at the
51
beginning of a program to ensure that there are no residual values from previous
52
executions.
53
54
The other semantics, which is expressed through the numeric parameter, is related to
55
the space occupied by the strings. This space is fixed and is used as a sort of
56
dynamic "heap". The numeric parameter provides, in fact, the maximum size allocated
57
for the strings. This value is equivalent to assigning a value with the
58
''DEFINE STRING SPACE'' pragma. Dynamic strings are reinitialized to empty strings
59
with this command, too.
60
61
The criterion of the size given with this parameter should be to minimize the
62
memory footprint in order to leave as much space as possible to the code and
63
resources (which shares the same data area). In other words, assuming that the
64
available space in the target is 32 KB, and the code and graphical resources
65
occupies 20 KB, and that we choose to use the default value on the number of
66
dynamic strings for the target (e.g. n=128), the maximum value to give to
67
''CLEAR'' will be 32KB - 20KB - (4*n) = 11776 / 2 = 5.888 bytes.
68
69
@italian
70
71
Il comando ''CLEAR'' ha due scopi: la semantica primaria del comando ''CLEAR''
72
è quella di reinizializzare le variabili (intere) ai loro valori iniziali.
73
Che di solito sono zero ma, naturalmente, possono essere diversi da zero.
74
Attualmente, il loro valore iniziale è uguale all'assegnazione durante la
75
definizione. Altri tipi di dati (come FLOAT o BIT) non vengono reinizializzati.
76
Ciò è particolarmente utile all'inizio di un programma per garantire che non
77
vi siano valori residui da esecuzioni precedenti.
78
79
L'altra semantica, che è espressa tramite il parametro numerico, è relativa allo
80
spazio occupato dalle stringhe. Questo spazio è fisso e viene utilizzato come
81
una sorta di "heap" dinamico. Il parametro numerico fornisce, infatti, la
82
dimensione massima allocata per le stringhe. Questo valore equivale ad assegnare
83
un valore con il pragma ''DEFINE STRING SPACE''. Anche le stringhe dinamiche
84
vengono reinizializzate a stringhe vuote con questo comando.
85
86
Il criterio per la dimensione data con questo parametro dovrebbe essere quello
87
di minimizzare l'ingombro di memoria per lasciare più spazio possibile per il codice e
88
le risorse (che condividono la stessa area dati). In altre parole, supponendo che
89
lo spazio disponibile nel target sia di 32 KB, e che il codice e le risorse grafiche
90
occupino 20 KB, e che scegliamo di usare il valore predefinito sul numero di
91
stringhe dinamiche per il target (ad esempio n=128), il valore massimo da dare a
92
''CLEAR'' sarà 32 KB - 20 KB - (4*n) = 11776 / 2 = 5.888 byte.
93
94
@syntax CLEAR size
95
96
@example CLEAR 2048
97
98
@alias CLR
99
</usermanual> */
100
101
/* <usermanual>
102
@keyword CLR
103
104
@syntax CLR size
105
106
@example CLR 2048
107
108
@alias CLEAR
109
</usermanual> */
110
void
clear
(
Environment
* _environment ) {
111
112
cpu_call
( _environment,
"VARINITCLEAR"
);
113
114
}
cpu_call
void cpu_call(Environment *_environment, char *_label)
Definition
6309.c:3755
clear
void clear(Environment *_environment)
Definition
clear.c:41
ugbc.h
Environment
struct _Environment Environment
Structure of compilation environment.
Z:
ugbasic
ugbc
src
targets
c128
clear.c
Generated by
1.16.1