ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
_build.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
41extern char OUTPUT_FILE_TYPE_AS_STRING[][16];
42
43void target_linkage( Environment * _environment ) {
44
45 char commandLine[8*MAX_TEMPORARY_STORAGE];
46 char executableName[MAX_TEMPORARY_STORAGE];
47 char listingFileName[MAX_TEMPORARY_STORAGE];
48
49 if ( _environment->outputFileType != OUTPUT_FILE_TYPE_K7_ORIGINAL && _environment->outputFileType != OUTPUT_FILE_TYPE_K7_NEW ) {
51 }
52
53 BUILD_SAFE_REMOVE( _environment, _environment->exeFileName );
54
55 BUILD_TOOLCHAIN_ASM6809_GET_EXECUTABLE( _environment, executableName );
56
57 BUILD_TOOLCHAIN_ASM6809_GET_LISTING_FILE( _environment, listingFileName );
58
59 BUILD_TOOLCHAIN_ASM6809EXEC( _environment, "-B", 10240, executableName, listingFileName );
60
61 if ( _environment->listingFileName ) {
62
63 if ( _environment->profileFileName && _environment->profileCycles ) {
64 if ( _environment->executerFileName ) {
65 sprintf(executableName, "%s", _environment->executerFileName );
66 } else if( access( "run6809.exe", F_OK ) == 0 ) {
67 sprintf(executableName, "%s", "run6809.exe" );
68 } else {
69 sprintf(executableName, "%s", "run6809" );
70 }
71
72 sprintf( commandLine, "\"%s\" -i \"%s\" -R 3000 -b -l 3000 \"%s\" -p \"%s\" %d",
73 executableName,
74 _environment->listingFileName,
75 _environment->exeFileName,
76 _environment->profileFileName,
77 _environment->profileCycles ? _environment->profileCycles : 1000000
78 );
79
80 if ( system_call( _environment, commandLine ) ) {
81 printf("The profiling of assembly program failed.\n\n");
82 return;
83 };
84
85 }
86
87 }
88
89 if ( _environment->outputFileType == OUTPUT_FILE_TYPE_K7_NEW ) {
90 convertbintok7( _environment );
91 } else {
92 convertbintok7_original( _environment );
93 }
94
95}
96
97void target_cleanup( Environment * _environment ) {
98
99 remove( _environment->asmFileName );
100
101 if ( _environment->analysis && _environment->listingFileName ) {
102 target_analysis( _environment );
103 }
104
105}
int system_call(Environment *_environment, char *_commandline)
Call an external executable.
void target_linkage(Environment *_environment)
Convert C64's assembly to executable.
Definition _build.c:327
void target_cleanup(Environment *_environment)
Definition _build.c:343
void target_analysis(Environment *_environment)
Definition _cleanup.c:68
int convertbintok7_original(Environment *_environment)
int convertbintok7(Environment *_environment)
Definition _cleanup.c:120
char * listingFileName
Definition ugbc.h:2305
int analysis
Definition ugbc.h:2365
char * executerFileName
Definition ugbc.h:2315
OutputFileType outputFileType
Definition ugbc.h:2452
char * profileFileName
Definition ugbc.h:2310
char * asmFileName
Definition ugbc.h:2285
int profileCycles
Definition ugbc.h:2375
char * exeFileName
Definition ugbc.h:2290
#define BUILD_TOOLCHAIN_ASM6809_GET_LISTING_FILE(_environment, listingFileName)
Definition ugbc.h:4872
@ OUTPUT_FILE_TYPE_K7_NEW
Definition ugbc.h:262
@ OUTPUT_FILE_TYPE_K7_ORIGINAL
Definition ugbc.h:261
#define BUILD_SAFE_REMOVE(_environment, filename)
Definition ugbc.h:4748
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
#define BUILD_TOOLCHAIN_ASM6809EXEC(_environment, flag, startingAddress, executableName, listingFileName)
Definition ugbc.h:4880
struct _Environment Environment
Structure of compilation environment.
#define BUILD_TOOLCHAIN_ASM6809_GET_EXECUTABLE(_environment, executableName)
Definition ugbc.h:4855
#define CRITICAL_UNSUPPORTED_OUTPUT_FILE_TYPE(t)
Definition ugbc.h:3537
char OUTPUT_FILE_TYPE_AS_STRING[][16]