- $sp = 1;
- foreach ($specs as list($start, $end, $step)) {
- if ($end) {
- if ($step > 1) {
- die("\nUNEXPECTED: step>1\n");
- printf("\tfor (i=0x%08X; i <= 0x%08X; i+= %d) { if (i == ch) return 1; }\n", $start, $end, $step);
+ printf(" switch((ch & 0x%08X) >> %d) {\n", $m, $b2);
+ foreach ($sws as $sw2 => $specs) {
+ printf(" case 0x%08X:\n", $sw2);
+ $sp = 2;
+ $start = null;
+ foreach ($specs as $index => $spec) {
+ if ($spec) {
+ list($start, $end, $step) = $spec;
+ if (isset($labels[$sw][$sw2])) {
+ $label = $labels[$sw][$sw2];
+ if ((!$end && $label == $start) || ($end && $label >= $start && $label <= $end)) {
+ printf("%sc_%08X:;\n", sp($sp), $label);
+ }
+ }
+ if ($end) {
+ if ($step > 1) {
+ die("\nUNEXPECTED: step>1\n");
+ printf("\tfor (i=0x%08X; i <= 0x%08X; i+= %d) { if (i == ch) return 1; }\n", $start, $end, $step);
+ } else {
+ printf("%sif (ch >= 0x%08X) {\n", sp($sp), $start);
+ printf("%sif (ch <= 0x%08X) return 1;\n", sp(++$sp), $end);
+ }
+ } else {
+ printf("%sif (ch == 0x%08X) return 1;\n", sp($sp), $start);
+ }