Skip to content

Generate mnemonics from subrule / cat? #131

Answered by hlorenzi
fisherdog1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm, how about something like this?

#subruledef gpreg
{
	r1 => 0x1
	r2 => 0x2
	r3 => 0x3
}

#subruledef threeRegs
{
	{rd: gpreg}, {rs: gpreg}, {rt: gpreg} => rd @ rs @ rt
}

#ruledef
{	
	ad {args: threeRegs} => 0x0`4 @ args
	su {args: threeRegs} => 0x1`4 @ args
	ic {args: threeRegs} => 0x2`4 @ args
	dc {args: threeRegs} => 0x3`4 @ args
	ls {args: threeRegs} => 0x4`4 @ args
	rs {args: threeRegs} => 0x5`4 @ args
	
	an {args: threeRegs} => 0x8`4 @ args
	or {args: threeRegs} => 0x9`4 @ args
	eo {args: threeRegs} => 0xA`4 @ args
	
	ar {args: threeRegs} => 0xD`4 @ args
	cp {args: threeRegs} => 0xE`4 @ args
}

ad r1, r2, r3
su r2, r3, r1

I've extracted the common logic to the threeRegs subrule! …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fisherdog1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants