Generate mnemonics from subrule / cat? #131
-
I have a series of very similar mnemonics like this:
The mnemonic is of course a subset of possible 4 bit numbers. I can create a subrule associating these mnemonics to their numbers but I'm not sure there's a way to compress this code using it. The closest I've gotten is something like this for my conditional relative jumps:
Which enables the following slightly unsatisfying formatting:
Is there a nicer way to do either of these things? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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 About your jump instruction, the assembler should accept |
Beta Was this translation helpful? Give feedback.
Hmm, how about something like this?
I've extracted the common logic to the
threeRegs
subrule! …