ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
_linker.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
48void linker_setup( Environment * _environment ) {
49 cfghead0("FEATURES {");
50 cfgline0("STARTADDRESS: default = $1001;");
51 cfghead0("}");
52 cfghead0("SYMBOLS {");
53 cfgline0("__LOADADDR__: type = import;");
54 cfghead0("}");
55 cfghead0("MEMORY {");
56 cfgline0("ZP: file = \"\", start = $0002, size = $001A, define = yes;");
57 cfgline0("LOADADDR: file = %O, start = %S - 2, size = $0002;");
58 cfgline0("MAIN: file = %O, start = %S, size = $57FF - %S;");
59 MemoryArea * actual = _environment->memoryAreas;
60 while( actual ) {
61 if ( actual->type == MAT_RAM ) {
62 cfgline3("RAM%3.3x: file = \"\", start = $%4.4x, size = $%4.4x;", actual->id, (unsigned short)actual->start, (unsigned short)(actual->end - actual->start) );
63 }
64 actual = actual->next;
65 }
66
67 cfghead0("}");
68 cfghead0("SEGMENTS {");
69 cfgline0("ZEROPAGE: load = ZP, type = zp, optional = yes;");
70 cfgline0("LOADADDR: load = LOADADDR, type = ro;");
71 cfgline0("EXEHDR: load = MAIN, type = ro, optional = yes;");
72 cfgline0("CODE: load = MAIN, type = rw;");
73 cfgline0("RODATA: load = MAIN, type = ro, optional = yes;");
74 cfgline0("DATA: load = MAIN, type = rw, optional = yes;");
75 cfgline0("BSS: load = MAIN, type = bss, optional = yes, define = yes;");
76
77 actual = _environment->memoryAreas;
78 while( actual ) {
79 if ( actual->type == MAT_RAM ) {
80 cfgline3("MA%3.3x: load = RAM%3.3x, type = overwrite, optional = yes, start = $%4.4x;", actual->id, actual->id, actual->start);
81 } else {
82 cfgline2("MA%3.3x: load = MAIN, type = overwrite, optional = yes, start = $%4.4x;", actual->id, actual->start);
83 }
84 actual = actual->next;
85 }
86
87}
88
96void linker_cleanup( Environment * _environment ) {
97
98 cfghead0("}");
99
100}
void linker_setup(Environment *_environment)
Emit tail of linker's configuration file lines.
Definition _linker.c:48
void linker_cleanup(Environment *_environment)
Emit tail of linker's configuration file lines.
Definition _linker.c:133
MemoryArea * memoryAreas
Definition ugbc.h:2689
int start
Definition ugbc.h:737
struct _MemoryArea * next
Definition ugbc.h:760
int id
Definition ugbc.h:732
MemoryAreaType type
Definition ugbc.h:757
int end
Definition ugbc.h:747
@ MAT_RAM
Definition ugbc.h:726
#define cfgline0(s)
Definition ugbc.h:4273
struct _Environment Environment
Structure of compilation environment.
struct _MemoryArea MemoryArea
#define cfgline2(s, a, b)
Definition ugbc.h:4275
#define cfgline3(s, a, b, c)
Definition ugbc.h:4276
#define cfghead0(s)
Definition ugbc.h:4267