hi.
in an attempt to shift & merge returned results, i find i
cannot use '>>' or '<<' in a p::rd executable block; i
must instead divide and multiply, respectively.
e.g. in this code, 'goodrule' works, 'badrule' does not:
sub_rule : /[0-7]/
goodrule : /reg1/i '=' sub_rule ',' /reg2/i '=' sub_rule ';'
{
$main::machineword = $item[3] * 8 | $item[7];
1
}
badrule : /reg1/i '=' sub_rule ',' /reg2/i '=' sub_rule ';'
{
$main::machineword = $item[3] << 3 | $item[7];
1
}
by 'not working' i mean i get undefined sub-rules and
such as if i was getting file/stream type redirection
instead of the shifts i want.
as a result, i've ended up with exe blocks that look like:
{
$main::Instruction_upper = 0x440000
| ($item[1] / 2048)
| $item[4]
| ($item[8] / 512)
| ($item[10] * 16)
| (($item[26] & 0x000010) / 16)
| ($item[32] / 2)
;
$main::Instruction_lower = 0x000000
| ($item[14] * 2)
| ($item[16] / 2048)
| ($item[20] * 16)
| ($item[22] / 128)
| (($item[26] & 0x00000C) * 1048576)
| (($item[28] & 0xC00000) / 16384)
| (($item[28] & 0x000003) * 1024)
| (($item[34] & 0xC00000) / 1024)
| (($item[34] & 0x000003) * 16384)
;
1
}
it does what's desired, but from a maintenance point of view
it is just not clear, without doing some math, what the
various shifts are.
not to mention the increased chances of a typo in these magic
numbers!
any ideas about where i've gone wrong in trying to use the
bit shifts?
or is this a bug in p::rd ?
thanks.
hwn