ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
chain.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#include "../../libs/msc1.h"
37
38/****************************************************************************
39 * CODE SECTION
40 ****************************************************************************/
41
42 /* <usermanual>
43@keyword CHAIN
44
45@english
46
47The ''CHAIN'' ​​command is a powerful tool used to load and execute another ugBASIC
48program from mass storage (such as a floppy disk), terminating the current program.
49This feature is useful on computers with limited memory, as it allows large
50applications to be broken down into smaller, more manageable modules or programs
51that can be "chained" together. Using ''CHAIN'' ​​allows you to create complex
52programs that would otherwise not fit entirely into the available RAM.
53
54The ''CHAIN'' ​​command syntax requires a ''filename'', which should represent the binary
55file located on the mass storage device. It is therefore not the name of the BASIC source
56file. When this instruction is executed, the current program is overwritten with the
57loaded one and executed from the beginning.
58
59Therefore, the ugBASIC program to be called with the ''CHAIN'' ​​command must first be
60compiled into the specified binary format. Only then should this compiled file be
61inserted into the ''STORAGE'' definition, and the symbolic name can be used to
62load the program.
63
64Finally, it is important to note that the program to be loaded must also use the
65''CHAIN'' ​​command or, alternatively, use the ''DEFINE CHAIN'' ​​directive at the
66head of the program.
67
68@italian
69
70Il comando ''CHAIN'' è un potente strumento utilizzato per caricare ed eseguire un
71altro programma ugBASIC dalla memoria di massa (come un disco floppy), terminando
72l'esecuzione del programma corrente. Questa funzionalità è utile nei computer con
73memoria limitata, in quanto consente di suddividere grandi applicazioni in moduli
74o programmi più piccoli e gestibili, che potevano essere "incatenati" tra loro.
75L'uso di ''CHAIN'' permette di creare programmi complessi che non avrebbero potuto
76essere caricati interamente nella RAM disponibile.
77
78La sintassi del comando ''CHAIN'' prevede un ''filename'', che dovrebbe rappresentare
79il file binario che si trova sul sistema di memorizzazione di massa. Non è, quindi,
80il nome del file BASIC. Quando questa istruzione viene eseguita, il programma
81corrente viene sovrascritto con quello caricato, e viene eseguito dall'inizio.
82
83Ne consegue che il programma BASIC da richiamare con il comando ''CHAIN'' va, prima
84di tutto, compilato nel formato binario specifico. Solo in seguito tale file
85compilato andrà inserito all'interno della definizione dello STORAGE, e il nome
86simbolico potrà essere utilizzato per caricare il programma.
87
88E' importante, infine, notare che il programma che andrà caricato dovrà utilizzare
89anch'esso il comando ''CHAIN'' oppure, in alternativa, usare la direttiva
90''DEFINE CHAIN'' in testa al programma.
91
92@syntax CHAIN filename
93
94@example CHAIN "t1"
95
96@target atari
97@target c64
98@target c128
99@target cpc
100</usermanual> */
101void chain( Environment * _environment, char * _filename ) {
102
103 if ( _environment->emptyProcedure ) {
104 return;
105 }
106
107 atari_chain( _environment, _filename );
108
109}
void chain(Environment *_environment, char *_filename)
Definition chain.c:101
void atari_chain(Environment *_environment, char *_filename)
Definition atari.c:1255
int emptyProcedure
Definition ugbc.h:2932
struct _Environment Environment
Structure of compilation environment.