Ejemplo n.º 1
0
// Switch to new zone ("!zone" or "!zn"). Has to be re-entrant.
static enum eos_t PO_zone(void) {
	section_t	entry_values;// buffer for outer zone
	char*		new_title;
	bool		allocated;

	// remember everything about current structure
	entry_values = *Section_now;
	// set default values in case there is no valid title
	new_title = untitled;
	allocated = FALSE;
	// Check whether a zone title is given. If yes and it can be read,
	// get copy, remember pointer and remember to free it later on.
	if(BYTEFLAGS(GotByte) & CONTS_KEYWORD) {
		// Because we know of one character for sure,
		// there's no need to check the return value.
		Input_read_keyword();
		new_title = DynaBuf_get_copy(GlobalDynaBuf);
		allocated = TRUE;
	}
	// setup new section
	// section type is "subzone", just in case a block follows
	Section_new_zone(Section_now, "Subzone", new_title, allocated);
	if(Parse_optional_block()) {
		// Block has been parsed, so it was a SUBzone.
		Section_finalize(Section_now);// end inner zone
		*Section_now = entry_values;// restore entry values
	} else {
		// no block found, so it's a normal zone change
		Section_finalize(&entry_values);// end outer zone
		Section_now->type = type_zone;// change type to "zone"
	}
	return(ENSURE_EOS);
}
Ejemplo n.º 2
0
// start offset assembly
static enum eos_t PO_pseudopc(void)
{
// future algo: remember outer memaddress and outer pseudopc
	int		outer_state	= uses_pseudo_pc;
	intval_t	new_pc,
			outer_offset	= current_offset;
	int		outer_flags	= CPU_pc.flags;

	// set new
	new_pc = ALU_defined_int();	// FIXME - allow for undefined pseudopc!
	current_offset = (current_offset + new_pc - CPU_pc.intval) & 0xffff;
	CPU_pc.intval = new_pc;
	CPU_pc.flags |= MVALUE_DEFINED;	// FIXME - remove!
	uses_pseudo_pc = TRUE;
	// if there's a block, parse that and then restore old value!
	if (Parse_optional_block()) {
		// restore old
		uses_pseudo_pc = outer_state;
		CPU_pc.flags = outer_flags;
		CPU_pc.intval = (outer_offset + CPU_pc.intval - current_offset) & 0xffff;
		current_offset = outer_offset;
// future algo: new outer pseudopc = (old outer pseudopc + (current memaddress - outer memaddress)) & 0xffff
	} else {
		Throw_first_pass_warning(Warning_old_offset_assembly);
	}
	return ENSURE_EOS;
}
Ejemplo n.º 3
0
Archivo: cpu.c Proyecto: Jedzia/acm3
// Set register length, block-wise if needed.
static enum eos_t set_register_length(bool *var, bool long_reg) {
	bool	buffer	= *var;

	// Set new register length (or complain - whichever is more fitting)
	check_and_set_reg_length(var, long_reg);
	// If there's a block, parse that and then restore old value!
	if(Parse_optional_block())
		check_and_set_reg_length(var, buffer);// restore old length
	return(ENSURE_EOS);
}
Ejemplo n.º 4
0
// set register length, block-wise if needed.
static enum eos_t set_register_length(int *var, int make_long)
{
	int	old_size	= *var;

	// set new register length (or complain - whichever is more fitting)
	check_and_set_reg_length(var, make_long);
	// if there's a block, parse that and then restore old value!
	if (Parse_optional_block())
		check_and_set_reg_length(var, old_size);	// restore old length
	return ENSURE_EOS;
}
Ejemplo n.º 5
0
Archivo: cpu.c Proyecto: Jedzia/acm3
// Select CPU ("!cpu" pseudo opcode)
static enum eos_t PO_cpu(void) {
	struct cpu_t*	cpu_buffer	= CPU_now;	// remember current cpu

	if(Input_read_and_lower_keyword())
		if(!CPU_find_cpu_struct(&CPU_now))
			Throw_error("Unknown processor.");
	// If there's a block, parse that and then restore old value!
	if(Parse_optional_block())
		CPU_now = cpu_buffer;
	return(ENSURE_EOS);
}
Ejemplo n.º 6
0
Archivo: cpu.c Proyecto: Jedzia/acm3
// Start offset assembly
static enum eos_t PO_pseudopc(void) {
	bool		outer_state	= uses_pseudo_pc;
	intval_t	new_pc,
			outer_offset	= current_offset;
	int		outer_flags	= CPU_pc.flags;

	// set new
	new_pc = ALU_defined_int();
	current_offset = (current_offset + new_pc - CPU_pc.intval) & 0xffff;
	CPU_pc.intval = new_pc;
	CPU_pc.flags |= MVALUE_DEFINED | MVALUE_IS_ADDRESS;
	uses_pseudo_pc = TRUE;
	// If there's a block, parse that and then restore old value!
	if(Parse_optional_block()) {
		// restore old
		uses_pseudo_pc = outer_state;
		CPU_pc.flags = outer_flags;
		CPU_pc.intval = (outer_offset + CPU_pc.intval - current_offset) & 0xffff;
		current_offset = outer_offset;
	} else
		Throw_first_pass_warning(Warning_old_offset_assembly);
	return(ENSURE_EOS);
}