ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
_vars.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#if defined(__pc1403__)
38
39/****************************************************************************
40 * CODE SECTION
41 ****************************************************************************/
42
43extern char DATATYPE_AS_STRING[][16];
44
45void vars_emit_constant_integer( Environment * _environment, char * _name, int _value ) {
46
47 outhead2("%s = $%4.4x", _name, _value );
48
49}
50
51void vars_emit_constants( Environment * _environment ) {
52
53 int i=0;
54
55 if ( _environment->constants ) {
56 Constant * actual = _environment->constants;
57 while( actual ) {
58 if ( ! actual->emitted ) {
59 switch( actual->type ) {
60 case CT_INTEGER:
61 vars_emit_constant_integer( _environment, actual->realName, actual->value );
62 break;
63 case CT_STRING:
64 break;
65 }
66 }
67 actual = actual->next;
68 }
69 }
70
71}
72
73
74void vars_emit_byte( Environment * _environment, char * _name, int _value ) {
75 if ( _name ) {
76 outline2("%s: .db 0x%2.2x", _name, (unsigned char)( _value & 0xff ) );
77 } else {
78 outline1(" .db 0x%2.2x", (unsigned char)( _value & 0xff ) );
79 }
80}
81
82void vars_emit_word( Environment * _environment, char * _name, int _value ) {
83 if ( _name ) {
84 outline3("%s: .db 0x%2.2x, 0x%2.2x", _name, (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff) );
85 } else {
86 outline2(" .db 0x%2.2x, 0x%2.2x", (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff) );
87 }
88}
89
90void vars_emit_dword( Environment * _environment, char * _name, int _value ) {
91 if ( _name ) {
92 outline5("%s: .db 0x%2.2x, 0x%2.2x, 0x%2.2x, 0x%2.2x", _name, (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff), (unsigned char)((_value>>16)&0xff), (unsigned char)((_value>>24)&0xff) );
93 } else {
94 outline4(" .db 0x%2.2x, 0x%2.2x, 0x%2.2x, 0x%2.2x", (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff), (unsigned char)((_value>>16)&0xff), (unsigned char)((_value>>24)&0xff) );
95 }
96}
97
98void vars_emit_number( Environment * _environment, char * _name, int _value ) {
99 if ( _name ) {
100 outline5("%s: .db 0x%2.2x, 0x%2.2x, 0x%2.2x, 0x%2.2x", _name, (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff), (unsigned char)((_value>>16)&0xff), (unsigned char)((_value>>24)&0xff) );
101 out(" .db" );
102 for( int i=0; i<(_environment->numberConfig.maxBytes - 4); ++i ) {
103 out("0x0");
104 if ( i == (_environment->numberConfig.maxBytes - 5) ) {
105 outline0(" ");
106 } else {
107 out(", ");
108 }
109 }
110 } else {
111 outline4(" .db 0x%2.2x, 0x%2.2x, 0x%2.2x, 0x%2.2x", (unsigned char)(_value&0xff), (unsigned char)((_value>>8)&0xff), (unsigned char)((_value>>16)&0xff), (unsigned char)((_value>>24)&0xff) );
112 out(" .db" );
113 for( int i=0; i<(_environment->numberConfig.maxBytes - 4); ++i ) {
114 out("0x0");
115 if ( i == (_environment->numberConfig.maxBytes - 5) ) {
116 outline0(" ");
117 } else {
118 out(", ");
119 }
120 }
121 }
122}
123
124void vars_emit_strips( Environment * _environment, char * _name, Strip * _strips ) {
125
126}
127
128#endif
void vars_emit_constant_integer(Environment *_environment, char *_name, int _value)
Definition _vars.c:46
void vars_emit_word(Environment *_environment, char *_name, int _value)
Definition _vars.c:92
void vars_emit_dword(Environment *_environment, char *_name, int _value)
Definition _vars.c:100
void vars_emit_number(Environment *_environment, char *_name, int _value)
Definition _vars.c:108
void vars_emit_constants(Environment *_environment)
Definition _vars.c:58
void vars_emit_byte(Environment *_environment, char *_name, int _value)
Definition _vars.c:84
void vars_emit_strips(Environment *_environment, char *_name, Strip *_strips)
Definition _vars.c:118
int emitted
Definition ugbc.h:827
int value
Definition ugbc.h:815
ConstantType type
Definition ugbc.h:805
struct _Constant * next
Definition ugbc.h:832
char * realName
Definition ugbc.h:803
NumberConfig numberConfig
Definition ugbc.h:2410
Constant * constants
Definition ugbc.h:2611
int maxBytes
Definition ugbc.h:2261
#define outline3(s, a, b, c)
Definition ugbc.h:4255
@ CT_STRING
Definition ugbc.h:789
@ CT_INTEGER
Definition ugbc.h:788
#define outline2(s, a, b)
Definition ugbc.h:4254
struct _Environment Environment
Structure of compilation environment.
struct _Strip Strip
struct _Constant Constant
Structure of a single constant.
#define outline0(s)
Definition ugbc.h:4252
#define outhead2(s, a, b)
Definition ugbc.h:4248
#define outline5(s, a, b, c, d, e)
Definition ugbc.h:4257
#define outline1(s, a)
Definition ugbc.h:4253
#define outline4(s, a, b, c, d)
Definition ugbc.h:4256
char DATATYPE_AS_STRING[][16]