[net.sources.games] fixes for corewars

budd@bu-cs.BU.EDU (Philip Budne) (09/10/86)

I have been unable to send this to the author, so I'm posting it:

In the corewars program by Peter Costantinidis, Jr.
(...!ucbvax!ucdavis!deneb!ccohesh001)

rcasm failed until I modified rcasm.l (v7.0);

16,26c16,26
< dat|DAT	return(opcode=DAT, orc=1, OPCODE);
< mov|MOV	return(opcode=MOV, orc=2, OPCODE);
< add|ADD	return(opcode=ADD, orc=2, OPCODE);
< sub|SUB	return(opcode=SUB, orc=2, OPCODE);
< jmp|JMP	return(opcode=JMP, orc=1, OPCODE);
< jmz|JMZ	return(opcode=JMZ, orc=2, OPCODE);
< djz|DJZ	return(opcode=DJZ, orc=2, OPCODE);
< cmp|CMP	return(opcode=CMP, orc=2, OPCODE);
< mul|MUL	return(opcode=MUL, orc=2, OPCODE);
< div|DIV	return(opcode=DIV, orc=2, OPCODE);
< rnd|RND	return(opcode=RND, orc=1, OPCODE);
---
> dat|DAT	{ opcode=DAT; orc=1; return(OPCODE); }
> mov|MOV	{ opcode=MOV; orc=2; return(OPCODE); }
> add|ADD	{ opcode=ADD; orc=2; return(OPCODE); }
> sub|SUB	{ opcode=SUB; orc=2; return(OPCODE); }
> jmp|JMP	{ opcode=JMP; orc=1; return(OPCODE); }
> jmz|JMZ	{ opcode=JMZ; orc=2; return(OPCODE); }
> djz|DJZ	{ opcode=DJZ; orc=2; return(OPCODE); }
> cmp|CMP	{ opcode=CMP; orc=2; return(OPCODE); }
> mul|MUL	{ opcode=MUL; orc=2; return(OPCODE); }
> div|DIV	{ opcode=DIV; orc=2; return(OPCODE); }
> rnd|RND	{ opcode=RND; orc=1; return(OPCODE); }

---
Here is a quickie that makes large offsets be displayed as smaller
negative offsets:

In print.c;

	if (fmt == fmt1)
		fprintf(fp, fmt, inst, addb, rel_fix( i->argb ) ); /* budd */
	else
		fprintf(fp, fmt, inst,
			adda, rel_fix( i->arga ), /* budd */
			addb, rel_fix( i->argb )); /* budd */
	return(FALSE);
}

rel_fix( i )			/* make output relative - budd */
int i;
{
    if( i > MAX_MEM/2 )		/* addr over half of memory away? */
	return( i - MAX_MEM );	/* yes, display as behind us */
    else
	return( i );
}


I wish that mars kept track of who last wrote a location so that you
could see who killed who.  I'm a bit bothered that imp never scores a
kill, it just possesses whatever it runs over, but thats the nature of
the beast!!

Thanks!!
	Phil Budne
	Boston University / Distributed Systems