I've created a little program to generate simple assembly source files and wish to call the assembler (PhxAss) directly from the C program. I've found that the Execute() function works nicely for this, but I'm having trouble getting it all the work properly. Here's the code of my function:
#include <exec/types.h>
#include <exec/libraries.h>
#include <dos/dos.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "assembler.h"
int assemble(char *file_name)
{
struct Library *DOSBase = NULL;
if (!(DOSBase = OpenLibrary(DOSNAME, 0)))
{
printf("Unable to open dos.library\n");
return FALSE;
}
else
{
char *command = NULL;
char *assembler_name = "PhxAss";
char *output_file_name = "file.err";
BPTR output_file = NULL;
if (!(command = (char *)malloc(sizeof(assembler_name) + sizeof(file_name) + 2)))
{
printf("Out of memory\n");
return FALSE;
}
strcat(command, assembler_name);
strcat(command, " ");
strcat(command, file_name);
output_file = Open(output_file_name, MODE_NEWFILE);
printf("%s\n", command);
Execute(command, NULL, output_file); /* Call the assembler. */
if (output_file)
{
Close(output_file);
}
CloseLibrary(DOSBase);
}
return TRUE;
}
This seems to work up to a point. It finds PhxAss which is in the default directory but fails to find the source file in the same directory. I get the following error in the output:
12 File doesn't exist (Init).
PhxAss failed returncode 20
This is a PhxAss error that means it can't find the file. I've tried adding the full path to the file name with the same results.
Does anyone have any idea what could be going on?
Thanks.