Ejemplo n.º 1
0
// Select dump file
static enum eos_t PO_sl(void)
{
	// bugfix: first read filename, *then* check for first pass.
	// if skipping right away, quoted colons might be misinterpreted as EOS
	// FIXME - why not just fix the skipping code to handle quotes? :)
	// "!to" has been fixed as well

	// read filename to global dynamic buffer
	// if no file name given, exit (complaining will have been done)
	if (Input_read_filename(FALSE))
		return SKIP_REMAINDER;

	// only process this pseudo opcode in first pass
	if (pass_count)
		return SKIP_REMAINDER;

	// if label dump file already chosen, complain and exit
	if (labeldump_filename) {
		Throw_warning("Label dump file already chosen.");
		return SKIP_REMAINDER;
	}

	// get malloc'd copy of filename
	labeldump_filename = DynaBuf_get_copy(GlobalDynaBuf);
	// ensure there's no garbage at end of line
	return ENSURE_EOS;
}
Ejemplo n.º 2
0
Archivo: macro.c Proyecto: lhz/acme
// This function is called when an already existing macro is re-defined.
// It first outputs a warning and then a serious error, stopping assembly.
// Showing the first message as a warning guarantees that ACME does not reach
// the maximum error limit inbetween.
static void report_redefinition(struct rwnode *macro_node)
{
    struct macro	*original_macro	= macro_node->body;

    // show warning with location of current definition
    Throw_warning(exception_macro_twice);
    // CAUTION, ugly kluge: fiddle with Input_now and Section_now
    // data to generate helpful error messages
    Input_now->original_filename = original_macro->def_filename;
    Input_now->line_number = original_macro->def_line_number;
    Section_now->type = "original";
    Section_now->title = "definition";
    // show serious error with location of original definition
    Throw_serious_error(exception_macro_twice);
}
Ejemplo n.º 3
0
// Include binary file
static enum eos_t PO_binary(void) {
	FILE*		fd;
	int		byte;
	intval_t	size	= -1,	// means "not given" => "until EOF"
			skip	= 0,
			interleave = 1;
	int skipByte;

	// if file name is missing, don't bother continuing
	if(Input_read_filename(TRUE))
		return(SKIP_REMAINDER);
	// try to open file
	fd = fopen(GLOBALDYNABUF_CURRENT, FILE_READBINARY);
	if(fd == NULL) {
		Throw_error(exception_cannot_open_input_file);
		return(SKIP_REMAINDER);
	}
	// read optional arguments
	if(Input_accept_comma()) {
		if(ALU_optional_defined_int(&size)
		&& (size <0))
			Throw_serious_error("Negative size argument.");
		if(Input_accept_comma())
		{
			ALU_optional_defined_int(&skip);// read skip

			if(Input_accept_comma())
			{
				ALU_optional_defined_int(&interleave);// read interleave
				if (interleave <= 1)
				{
					Throw_serious_error("Negative size argument.");
				}
			}
		}
	}
	skipByte = interleave;
	// check whether including is a waste of time
	if((size >= 0) && (pass_undefined_count || pass_real_errors))
		Output_fake(size);	// really including is useless anyway
	else {
		// really insert file
		fseek(fd, skip, SEEK_SET);	// set read pointer
		// if "size" non-negative, read "size" bytes.
		// otherwise, read until EOF.
		while(size != 0) {
			byte = getc(fd);
			if(byte == EOF)
				break;
			skipByte++;
			if (skipByte >= interleave)
			{
				Output_byte(byte);
				size--;
				skipByte = 0;
			}
		}
		// if more should have been read, warn and add padding
		if(size > 0) {
			Throw_warning("Padding with zeroes.");
			do
				Output_byte(0);
			while(--size);
		}
	}
	fclose(fd);
	// if verbose, produce some output
	if((pass_count == 0) && (Process_verbosity > 1))
		printf("Loaded %d ($%x) bytes from file offset %ld ($%lx).\n",
		CPU_2add, CPU_2add, skip, skip);
	return(ENSURE_EOS);
}