ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
dojo_create_port.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
37extern char DATATYPE_AS_STRING[][16];
38
39/* <usermanual>
40@keyword CREATE PORT
41
42@english
43
44The ''CREATE PORT'' statement creates a communication port on the DOJO server, which allows you to send and
45receive messages. Each port has 256 independent communication channels, on which you can send and receive
46messages. This statement returns a unique port identifier, which can be communicated to the user via the
47''PRINT'' command and used as a 32-bit number. For this reason, the code contains 8 hexadecimal digits.
48The identifier must be used to open a connection via the ''OPEN PORT'' command, in case you want to reuse
49the connection at a later time or to coordinate the participants in a communication.
50
51@italian
52
53L'istruzione ''CREATE PORT'' consente di creare una porta di comunicazione sul server DOJO, che consente di
54inviare e ricevere messaggi. Ogni porta dispone di 256 canali di comunicazione indipendenti, sui quali è
55possibile inviare e ricevere messaggi. Questa istruzione restituisce un i dentificativo univoco della porta,
56che può essere comunicato all'utente per mezzo del comando ''PRINT'' e usato come un numero di 32 bit.
57Per questa ragione il codice contiene 8 cifre esadecimali. L'identificativo dovrà essere utilizzato per aprire
58una connessione tramite il comando OPEN PORT, laddove si voglia riutilizzare la connessione in un secondo
59tempo o per coordinare i partecipanti a una comunicazione.
60
61@syntax [DOJO] CREATE PORT [()]
62
63@example handle = CREATE PORT
64
65@alias DOJO CREATE PORT
66
67@seeAlso OPEN PORT
68
69@target atari, coco
70</usermanual> */
71
72/* <usermanual>
73@keyword DOJO CREATE PORT
74
75@english
76
77@italian
78
79@alias CREATE PORT
80
81@target atari, coco
82</usermanual> */
83
85
87
88 Variable * dojoHandle = variable_temporary( _environment, VT_DOJOKA, "(dojo handle)" );
89 Variable * result = variable_temporary( _environment, VT_BYTE, "(unique id)" );
90
91 dojo_begin( _environment );
92 dojo_put_request0( _environment, DOJO_CMD_CREATE_PORT, NULL, NULL, result->realName );
93 cpu_compare_and_branch_8bit_const( _environment, result->realName, 0, label, 0 );
94 dojo_partial( _environment );
95 dojo_get_responsed( _environment, result->realName, dojoHandle->realName, NULL );
96
97 cpu_label( _environment, label );
98 dojo_end( _environment );
99
100 cpu_move_8bit( _environment, result->realName, "DOJOERROR" );
101
102 return dojoHandle;
103
104}
void cpu_label(Environment *_environment, char *_label)
Definition 6309.c:356
void cpu_move_8bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 8 bit
Definition 6309.c:743
void cpu_compare_and_branch_8bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
CPU 6309: emit code to compare two 8 bit values and jump if they are equal/different
Definition 6309.c:876
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
void dojo_put_request0(Environment *_environment, int _command, char *_param1, char *_param2, char *_result)
Definition dojo.c:63
void dojo_partial(Environment *_environment)
Definition dojo.c:103
void dojo_get_responsed(Environment *_environment, char *_status, char *_data, char *_size)
Definition dojo.c:133
void dojo_end(Environment *_environment)
Definition dojo.c:173
void dojo_begin(Environment *_environment)
Definition dojo.c:53
Variable * dojo_create_port(Environment *_environment)
char * realName
Definition ugbc.h:982
#define DOJO_CMD_CREATE_PORT
Definition ugbc.h:4731
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_DOJOKA
Definition ugbc.h:534
@ VT_BYTE
Definition ugbc.h:450
#define MAKE_LABEL
Definition ugbc.h:3351
char DATATYPE_AS_STRING[][16]