/*****************************************************************************/
/* */
-/* objfile.c */
+/* objfile.c */
/* */
-/* Object file writing routines for the ca65 macroassembler */
+/* Object file writing routines for the ca65 macroassembler */
/* */
/* */
/* */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
static FILE* F = 0;
/* Default extension */
-#define OBJ_EXT ".o"
+#define OBJ_EXT ".o"
/* Header structure */
static ObjHeader Header = {
/*****************************************************************************/
-/* Internally used functions */
+/* Internally used functions */
/*****************************************************************************/
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
{
/* Do we have a name for the output file? */
if (OutFile == 0) {
- /* We don't have an output name explicitly given, construct one from
- * the name of the input file.
- */
- OutFile = MakeFilename (InFile, OBJ_EXT);
+ /* We don't have an output name explicitly given, construct one from
+ * the name of the input file.
+ */
+ OutFile = MakeFilename (InFile, OBJ_EXT);
}
/* Create the output file */
F = fopen (OutFile, "w+b");
if (F == 0) {
- Fatal ("Cannot open output file `%s': %s", OutFile, strerror (errno));
+ Fatal ("Cannot open output file `%s': %s", OutFile, strerror (errno));
}
/* Write a dummy header */
{
/* Go back to the beginning */
if (fseek (F, 0, SEEK_SET) != 0) {
- ObjWriteError ();
+ ObjWriteError ();
}
/* If we have debug infos, set the flag in the header */
/* Close the file */
if (fclose (F) != 0) {
- ObjWriteError ();
+ ObjWriteError ();
}
}
/* Write an 8 bit value to the file */
{
if (putc (V, F) == EOF) {
- ObjWriteError ();
+ ObjWriteError ();
}
}
* needing 5 bytes if a 32 bit value is written to file.
*/
do {
- unsigned char C = (V & 0x7F);
- V >>= 7;
- if (V) {
- C |= 0x80;
- }
- ObjWrite8 (C);
+ unsigned char C = (V & 0x7F);
+ V >>= 7;
+ if (V) {
+ C |= 0x80;
+ }
+ ObjWrite8 (C);
} while (V != 0);
}
/* Write literal data to the file */
{
if (fwrite (Data, 1, Size, F) != Size) {
- ObjWriteError ();
+ ObjWriteError ();
}
}
ObjWriteVar (Pos->Line);
ObjWriteVar (Pos->Col);
if (Pos->Name == 0) {
- /* Position is outside file scope, use the main file instead */
- ObjWriteVar (0);
+ /* Position is outside file scope, use the main file instead */
+ ObjWriteVar (0);
} else {
ObjWriteVar (Pos->Name - 1);
}