ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
out.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
48/* <usermanual>
49@keyword OUT
50
51@english
52
53The ''OUT'' command is a statement that allows your program to interact directly
54with your computer's hardware, specifically its input/output (I/O) ports. This
55command is especially useful in contexts where you want to control external
56devices connected to your computer, such as printers, sound cards, or
57data acquisition devices.
58
59When you use the ''OUT'' command, you specify a port address and a value to
60send to that port. The port address identifies a particular hardware
61device connected to your computer, while the value sent determines the action
62the device will perform.
63
64The use of the ''OUT'' command is highly dependent on the specific hardware
65of your computer. The port addresses and values to send vary depending on
66the type of device connected and the system configuration.
67
68Improper use of the ''OUT'' command can damage the hardware or cause the
69system to malfunction. It is essential to have a thorough understanding
70of the hardware you are interacting with and to use this command with caution.
71
72@italian
73
74Il comando ''OUT'' è un'istruzione che consente al programma di interagire
75direttamente con l'hardware del computer, in particolare con le porte di
76input/output (I/O). Questo comando è particolarmente utile nei contesti
77in cui si desidera controllare dispositivi esterni collegati al computer,
78come stampanti, schede audio o dispositivi di acquisizione dati.
79
80Quando si utilizza il comando ''OUT'', si specifica un indirizzo di porta
81e un valore da inviare a tale porta. L'indirizzo di porta identifica un
82particolare dispositivo hardware collegato al computer, mentre il valore
83inviato determina l'azione che il dispositivo eseguirà.
84
85L'utilizzo del comando ''OUT'' dipende in larga misura dall'hardware
86specifico del computer. Gli indirizzi di porta e i valori da inviare
87variano a seconda del tipo di dispositivo collegato e della configurazione
88del sistema.
89
90L'utilizzo improprio del comando ''OUT'' può danneggiare l'hardware o
91causare malfunzionamenti del sistema. È essenziale avere una conoscenza
92approfondita dell'hardware con cui si sta interagendo e utilizzare questo
93comando con cautela.
94
95@syntax OUT port, value
96
97@example OUT &HBC00, 0
98
99@target c128z
100@target coleco
101@target cpc
102@target msx1
103@target sc3000
104@target sg1000
105@target vg5000
106@target zx
107</usermanual> */
108void out_var( Environment * _environment, char * _port, char * _value ) {
109
110 Variable * port = variable_retrieve_or_define( _environment, _port, VT_WORD, 0 );
111
112 Variable * value = variable_retrieve_or_define( _environment, _value, VT_BYTE, 0 );
113
114 cpu_out( _environment, port->realName, value->realName );
115
116}
void cpu_out(Environment *_environment, char *_port, char *_value)
Definition 6309.c:6353
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
void out_var(Environment *_environment, char *_port, char *_value)
Emit ASM code for OUT.
Definition out.c:108
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_BYTE
Definition ugbc.h:450