freedreno/afuc: Fix printing preemptleave on a5xx
[mesa.git] / src / freedreno / afuc / disasm.c
1 /*
2 * Copyright (c) 2017 Rob Clark <robdclark@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #include <err.h>
25 #include <stdint.h>
26 #include <stdbool.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <stdarg.h>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <assert.h>
34 #include <getopt.h>
35
36 #include "afuc.h"
37 #include "rnn.h"
38 #include "rnndec.h"
39
40 static int gpuver;
41
42
43 static struct rnndeccontext *ctx;
44 static struct rnndb *db;
45 static struct rnndomain *control_regs;
46 struct rnndomain *dom[2];
47 const char *variant;
48
49 /* non-verbose mode should output something suitable to feed back into
50 * assembler.. verbose mode has additional output useful for debugging
51 * (like unexpected bits that are set)
52 */
53 static bool verbose = false;
54
55 static void print_gpu_reg(uint32_t regbase)
56 {
57 struct rnndomain *d = NULL;
58
59 if (regbase < 0x100)
60 return;
61
62 if (rnndec_checkaddr(ctx, dom[0], regbase, 0))
63 d = dom[0];
64 else if (rnndec_checkaddr(ctx, dom[1], regbase, 0))
65 d = dom[1];
66
67 if (d) {
68 struct rnndecaddrinfo *info = rnndec_decodeaddr(ctx, d, regbase, 0);
69 if (info) {
70 printf("\t; %s", info->name);
71 free(info->name);
72 free(info);
73 return;
74 }
75 }
76 }
77
78 static void printc(const char *c, const char *fmt, ...)
79 {
80 va_list args;
81 printf("%s", c);
82 va_start(args, fmt);
83 vprintf(fmt, args);
84 va_end(args);
85 printf("%s", ctx->colors->reset);
86 }
87
88 #define printerr(fmt, ...) printc(ctx->colors->err, fmt, ##__VA_ARGS__)
89 #define printlbl(fmt, ...) printc(ctx->colors->btarg, fmt, ##__VA_ARGS__)
90
91 static void print_reg(unsigned reg)
92 {
93 // XXX seems like *reading* $00 --> literal zero??
94 // seems like read from $1c gives packet remaining len??
95 // $01 current packet header, writing to $01 triggers
96 // parsing header and jumping to appropriate handler.
97 if (reg == 0x1c)
98 printf("$rem"); /* remainding dwords in packet */
99 else if (reg == 0x1d)
100 printf("$addr");
101 else if (reg == 0x1e)
102 printf("$addr2"); // XXX
103 else if (reg == 0x1f)
104 printf("$data");
105 else
106 printf("$%02x", reg);
107 }
108
109 static void print_src(unsigned reg)
110 {
111 print_reg(reg);
112 }
113
114 static void print_dst(unsigned reg)
115 {
116 print_reg(reg);
117 }
118
119 static void print_alu_name(afuc_opc opc, uint32_t instr)
120 {
121 if (opc == OPC_ADD) {
122 printf("add ");
123 } else if (opc == OPC_ADDHI) {
124 printf("addhi ");
125 } else if (opc == OPC_SUB) {
126 printf("sub ");
127 } else if (opc == OPC_SUBHI) {
128 printf("subhi ");
129 } else if (opc == OPC_AND) {
130 printf("and ");
131 } else if (opc == OPC_OR) {
132 printf("or ");
133 } else if (opc == OPC_XOR) {
134 printf("xor ");
135 } else if (opc == OPC_NOT) {
136 printf("not ");
137 } else if (opc == OPC_SHL) {
138 printf("shl ");
139 } else if (opc == OPC_USHR) {
140 printf("ushr ");
141 } else if (opc == OPC_ISHR) {
142 printf("ishr ");
143 } else if (opc == OPC_ROT) {
144 printf("rot ");
145 } else if (opc == OPC_MUL8) {
146 printf("mul8 ");
147 } else if (opc == OPC_MIN) {
148 printf("min ");
149 } else if (opc == OPC_MAX) {
150 printf("max ");
151 } else if (opc == OPC_CMP) {
152 printf("cmp ");
153 } else if (opc == OPC_MSB) {
154 printf("msb ");
155 } else {
156 printerr("[%08x]", instr);
157 printf(" ; alu%02x ", opc);
158 }
159 }
160
161 static const char *getpm4(uint32_t id)
162 {
163 return rnndec_decode_enum(ctx, "adreno_pm4_type3_packets", id);
164 }
165
166 static inline unsigned
167 _odd_parity_bit(unsigned val)
168 {
169 /* See: http://graphics.stanford.edu/~seander/bithacks.html#ParityParallel
170 * note that we want odd parity so 0x6996 is inverted.
171 */
172 val ^= val >> 16;
173 val ^= val >> 8;
174 val ^= val >> 4;
175 val &= 0xf;
176 return (~0x6996 >> val) & 1;
177 }
178
179 static struct {
180 uint32_t offset;
181 uint32_t num_jump_labels;
182 uint32_t jump_labels[256];
183 } jump_labels[1024];
184 int num_jump_labels;
185
186 static void add_jump_table_entry(uint32_t n, uint32_t offset)
187 {
188 int i;
189
190 if (n > 128) /* can't possibly be a PM4 PKT3.. */
191 return;
192
193 for (i = 0; i < num_jump_labels; i++)
194 if (jump_labels[i].offset == offset)
195 goto add_label;
196
197 num_jump_labels = i + 1;
198 jump_labels[i].offset = offset;
199 jump_labels[i].num_jump_labels = 0;
200
201 add_label:
202 jump_labels[i].jump_labels[jump_labels[i].num_jump_labels++] = n;
203 assert(jump_labels[i].num_jump_labels < 256);
204 }
205
206 static int get_jump_table_entry(uint32_t offset)
207 {
208 int i;
209
210 for (i = 0; i < num_jump_labels; i++)
211 if (jump_labels[i].offset == offset)
212 return i;
213
214 return -1;
215 }
216
217 static uint32_t label_offsets[0x512];
218 static int num_label_offsets;
219
220 static int label_idx(uint32_t offset, bool create)
221 {
222 int i;
223 for (i = 0; i < num_label_offsets; i++)
224 if (offset == label_offsets[i])
225 return i;
226 if (!create)
227 return -1;
228 label_offsets[i] = offset;
229 num_label_offsets = i+1;
230 return i;
231 }
232
233 static const char *
234 label_name(uint32_t offset, bool allow_jt)
235 {
236 static char name[8];
237 int lidx;
238
239 if (allow_jt) {
240 lidx = get_jump_table_entry(offset);
241 if (lidx >= 0) {
242 int j;
243 for (j = 0; j < jump_labels[lidx].num_jump_labels; j++) {
244 uint32_t jump_label = jump_labels[lidx].jump_labels[j];
245 const char *str = getpm4(jump_label);
246 if (str)
247 return str;
248 }
249 // if we don't find anything w/ known name, maybe we should
250 // return UNKN%d to at least make it clear that this is some
251 // sort of jump-table entry?
252 }
253 }
254
255 lidx = label_idx(offset, false);
256 if (lidx < 0)
257 return NULL;
258 sprintf(name, "l%03d", lidx);
259 return name;
260 }
261
262
263 static uint32_t fxn_offsets[0x512];
264 static int num_fxn_offsets;
265
266 static int fxn_idx(uint32_t offset, bool create)
267 {
268 int i;
269 for (i = 0; i < num_fxn_offsets; i++)
270 if (offset == fxn_offsets[i])
271 return i;
272 if (!create)
273 return -1;
274 fxn_offsets[i] = offset;
275 num_fxn_offsets = i+1;
276 return i;
277 }
278
279 static const char *
280 fxn_name(uint32_t offset)
281 {
282 static char name[8];
283 int fidx = fxn_idx(offset, false);
284 if (fidx < 0)
285 return NULL;
286 sprintf(name, "fxn%02d", fidx);
287 return name;
288 }
289
290 static void print_control_reg(uint32_t id)
291 {
292 if (rnndec_checkaddr(ctx, control_regs, id, 0)) {
293 struct rnndecaddrinfo *info = rnndec_decodeaddr(ctx, control_regs, id, 0);
294 printf("@%s", info->name);
295 free(info->name);
296 free(info);
297 } else {
298 printf("0x%03x", id);
299 }
300 }
301
302 static void disasm(uint32_t *buf, int sizedwords)
303 {
304 uint32_t *instrs = buf;
305 const int jmptbl_start = instrs[1] & 0xffff;
306 uint32_t *jmptbl = &buf[jmptbl_start];
307 afuc_opc opc;
308 bool rep;
309 int i;
310
311
312 /* parse jumptable: */
313 for (i = 0; i < 0x80; i++) {
314 unsigned offset = jmptbl[i];
315 unsigned n = i;// + CP_NOP;
316 add_jump_table_entry(n, offset);
317 }
318
319 /* do a pre-pass to find instructions that are potential branch targets,
320 * and add labels for them:
321 */
322 for (i = 0; i < jmptbl_start; i++) {
323 afuc_instr *instr = (void *)&instrs[i];
324
325 afuc_get_opc(instr, &opc, &rep);
326
327 switch (opc) {
328 case OPC_BRNEI:
329 case OPC_BREQI:
330 case OPC_BRNEB:
331 case OPC_BREQB:
332 label_idx(i + instr->br.ioff, true);
333 break;
334 case OPC_PREEMPTLEAVE6:
335 if (gpuver >= 6)
336 label_idx(instr->call.uoff, true);
337 break;
338 case OPC_CALL:
339 fxn_idx(instr->call.uoff, true);
340 break;
341 default:
342 break;
343 }
344 }
345
346 /* print instructions: */
347 for (i = 0; i < jmptbl_start; i++) {
348 int jump_label_idx;
349 afuc_instr *instr = (void *)&instrs[i];
350 const char *fname, *lname;
351 afuc_opc opc;
352 bool rep;
353
354 afuc_get_opc(instr, &opc, &rep);
355
356 lname = label_name(i, false);
357 fname = fxn_name(i);
358 jump_label_idx = get_jump_table_entry(i);
359
360 if (jump_label_idx >= 0) {
361 int j;
362 printf("\n");
363 for (j = 0; j < jump_labels[jump_label_idx].num_jump_labels; j++) {
364 uint32_t jump_label = jump_labels[jump_label_idx].jump_labels[j];
365 const char *name = getpm4(jump_label);
366 if (name) {
367 printlbl("%s", name);
368 } else {
369 printlbl("UNKN%d", jump_label);
370 }
371 printf(":\n");
372 }
373 }
374
375 if (fname) {
376 printlbl("%s", fname);
377 printf(":\n");
378 }
379
380 if (lname) {
381 printlbl(" %s", lname);
382 printf(":");
383 } else {
384 printf(" ");
385 }
386
387
388 if (verbose) {
389 printf("\t%04x: %08x ", i, instrs[i]);
390 } else {
391 printf(" ");
392 }
393
394 switch (opc) {
395 case OPC_NOP: {
396 /* a6xx changed the default immediate, and apparently 0
397 * is illegal now.
398 */
399 const uint32_t nop = gpuver >= 6 ? 0x1000000 : 0x0;
400 if (instrs[i] != nop) {
401 printerr("[%08x]", instrs[i]);
402 printf(" ; ");
403 }
404 if (rep)
405 printf("(rep)");
406 printf("nop");
407 print_gpu_reg(instrs[i]);
408
409 break;
410 }
411 case OPC_ADD:
412 case OPC_ADDHI:
413 case OPC_SUB:
414 case OPC_SUBHI:
415 case OPC_AND:
416 case OPC_OR:
417 case OPC_XOR:
418 case OPC_NOT:
419 case OPC_SHL:
420 case OPC_USHR:
421 case OPC_ISHR:
422 case OPC_ROT:
423 case OPC_MUL8:
424 case OPC_MIN:
425 case OPC_MAX:
426 case OPC_CMP: {
427 bool src1 = true;
428
429 if (opc == OPC_NOT)
430 src1 = false;
431
432 if (rep)
433 printf("(rep)");
434
435 print_alu_name(opc, instrs[i]);
436 print_dst(instr->alui.dst);
437 printf(", ");
438 if (src1) {
439 print_src(instr->alui.src);
440 printf(", ");
441 }
442 printf("0x%04x", instr->alui.uimm);
443 print_gpu_reg(instr->alui.uimm);
444
445 /* print out unexpected bits: */
446 if (verbose) {
447 if (instr->alui.src && !src1)
448 printerr(" (src=%02x)", instr->alui.src);
449 }
450
451 break;
452 }
453 case OPC_MOVI: {
454 if (rep)
455 printf("(rep)");
456 printf("mov ");
457 print_dst(instr->movi.dst);
458 printf(", 0x%04x", instr->movi.uimm);
459 if (instr->movi.shift)
460 printf(" << %u", instr->movi.shift);
461
462 /* using mov w/ << 16 is popular way to construct a pkt7
463 * header to send (for ex, from PFP to ME), so check that
464 * case first
465 */
466 if ((instr->movi.shift == 16) &&
467 ((instr->movi.uimm & 0xff00) == 0x7000)) {
468 unsigned opc, p;
469
470 opc = instr->movi.uimm & 0x7f;
471 p = _odd_parity_bit(opc);
472
473 /* So, you'd think that checking the parity bit would be
474 * a good way to rule out false positives, but seems like
475 * ME doesn't really care.. at least it would filter out
476 * things that look like actual legit packets between
477 * PFP and ME..
478 */
479 if (1 || p == ((instr->movi.uimm >> 7) & 0x1)) {
480 const char *name = getpm4(opc);
481 printf("\t; ");
482 if (name)
483 printlbl("%s", name);
484 else
485 printlbl("UNKN%u", opc);
486 break;
487 }
488 }
489
490 print_gpu_reg(instr->movi.uimm << instr->movi.shift);
491
492 break;
493 }
494 case OPC_ALU: {
495 bool src1 = true;
496
497 if (instr->alu.alu == OPC_NOT || instr->alu.alu == OPC_MSB)
498 src1 = false;
499
500 if (instr->alu.pad)
501 printf("[%08x] ; ", instrs[i]);
502
503 if (rep)
504 printf("(rep)");
505
506 /* special case mnemonics:
507 * reading $00 seems to always yield zero, and so:
508 * or $dst, $00, $src -> mov $dst, $src
509 * Maybe add one for negate too, ie.
510 * sub $dst, $00, $src ???
511 */
512 if ((instr->alu.alu == OPC_OR) && !instr->alu.src1) {
513 printf("mov ");
514 src1 = false;
515 } else {
516 print_alu_name(instr->alu.alu, instrs[i]);
517 }
518
519 print_dst(instr->alu.dst);
520 if (src1) {
521 printf(", ");
522 print_src(instr->alu.src1);
523 }
524 printf(", ");
525 print_src(instr->alu.src2);
526
527 /* print out unexpected bits: */
528 if (verbose) {
529 if (instr->alu.pad)
530 printerr(" (pad=%03x)", instr->alu.pad);
531 if (instr->alu.src1 && !src1)
532 printerr(" (src1=%02x)", instr->alu.src1);
533 }
534 break;
535 }
536 case OPC_CWRITE6:
537 case OPC_CREAD6:
538 case OPC_STORE6:
539 case OPC_LOAD6: {
540 if (rep)
541 printf("(rep)");
542
543 bool is_control_reg = true;
544 if (gpuver >= 6) {
545 switch (opc) {
546 case OPC_CWRITE6:
547 printf("cwrite ");
548 break;
549 case OPC_CREAD6:
550 printf("cread ");
551 break;
552 case OPC_STORE6:
553 is_control_reg = false;
554 printf("store ");
555 break;
556 case OPC_LOAD6:
557 is_control_reg = false;
558 printf("load ");
559 break;
560 default:
561 assert(!"unreachable");
562 }
563 } else {
564 switch (opc) {
565 case OPC_CWRITE5:
566 printf("cwrite ");
567 break;
568 case OPC_CREAD5:
569 printf("cread ");
570 break;
571 default:
572 fprintf(stderr, "A6xx control opcode on A5xx?\n");
573 exit(1);
574 }
575 }
576
577 print_src(instr->control.src1);
578 printf(", [");
579 print_src(instr->control.src2);
580 printf(" + ");
581 if (is_control_reg && instr->control.flags != 0x4)
582 print_control_reg(instr->control.uimm);
583 else
584 printf("0x%03x", instr->control.uimm);
585 printf("], 0x%x", instr->control.flags);
586 break;
587 }
588 case OPC_BRNEI:
589 case OPC_BREQI:
590 case OPC_BRNEB:
591 case OPC_BREQB: {
592 unsigned off = i + instr->br.ioff;
593
594 assert(!rep);
595
596 /* Since $00 reads back zero, it can be used as src for
597 * unconditional branches. (This only really makes sense
598 * for the BREQB.. or possible BRNEI if imm==0.)
599 *
600 * If bit=0 then branch is taken if *all* bits are zero.
601 * Otherwise it is taken if bit (bit-1) is clear.
602 *
603 * Note the instruction after a jump/branch is executed
604 * regardless of whether branch is taken, so use nop or
605 * take that into account in code.
606 */
607 if (instr->br.src || (opc != OPC_BRNEB)) {
608 bool immed = false;
609
610 if (opc == OPC_BRNEI) {
611 printf("brne ");
612 immed = true;
613 } else if (opc == OPC_BREQI) {
614 printf("breq ");
615 immed = true;
616 } else if (opc == OPC_BRNEB) {
617 printf("brne ");
618 } else if (opc == OPC_BREQB) {
619 printf("breq ");
620 }
621 print_src(instr->br.src);
622 if (immed) {
623 printf(", 0x%x,", instr->br.bit_or_imm);
624 } else {
625 printf(", b%u,", instr->br.bit_or_imm);
626 }
627 } else {
628 printf("jump");
629 if (verbose && instr->br.bit_or_imm) {
630 printerr(" (src=%03x, bit=%03x) ",
631 instr->br.src, instr->br.bit_or_imm);
632 }
633 }
634
635 printf(" #");
636 printlbl("%s", label_name(off, true));
637 if (verbose)
638 printf(" (#%d, %04x)", instr->br.ioff, off);
639 break;
640 }
641 case OPC_CALL:
642 assert(!rep);
643 printf("call #");
644 printlbl("%s", fxn_name(instr->call.uoff));
645 if (verbose) {
646 printf(" (%04x)", instr->call.uoff);
647 if (instr->br.bit_or_imm || instr->br.src) {
648 printerr(" (src=%03x, bit=%03x) ",
649 instr->br.src, instr->br.bit_or_imm);
650 }
651 }
652 break;
653 case OPC_RET:
654 assert(!rep);
655 if (instr->pad)
656 printf("[%08x] ; ", instrs[i]);
657 printf("ret");
658 break;
659 case OPC_WIN:
660 assert(!rep);
661 if (instr->waitin.pad)
662 printf("[%08x] ; ", instrs[i]);
663 printf("waitin");
664 if (verbose && instr->waitin.pad)
665 printerr(" (pad=%x)", instr->waitin.pad);
666 break;
667 case OPC_PREEMPTLEAVE6:
668 if (gpuver < 6) {
669 printf("[%08x] ; op38", instrs[i]);
670 } else {
671 printf("preemptleave #");
672 printlbl("%s", label_name(instr->call.uoff, true));
673 }
674 break;
675 default:
676 printerr("[%08x]", instrs[i]);
677 printf(" ; op%02x ", opc);
678 print_dst(instr->alui.dst);
679 printf(", ");
680 print_src(instr->alui.src);
681 print_gpu_reg(instrs[i] & 0xffff);
682 break;
683 }
684 printf("\n");
685 }
686
687 /* print jumptable: */
688 if (verbose) {
689 printf(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");
690 printf("; JUMP TABLE\n");
691 for (i = 0; i < 0x7f; i++) {
692 int n = i;// + CP_NOP;
693 uint32_t offset = jmptbl[i];
694 const char *name = getpm4(n);
695 printf("%3d %02x: ", n, n);
696 printf("%04x", offset);
697 if (name) {
698 printf(" ; %s", name);
699 } else {
700 printf(" ; UNKN%d", n);
701 }
702 printf("\n");
703 }
704 }
705 }
706
707 #define CHUNKSIZE 4096
708
709 static char * readfile(const char *path, int *sz)
710 {
711 char *buf = NULL;
712 int fd, ret, n = 0;
713
714 fd = open(path, O_RDONLY);
715 if (fd < 0)
716 return NULL;
717
718 while (1) {
719 buf = realloc(buf, n + CHUNKSIZE);
720 ret = read(fd, buf + n, CHUNKSIZE);
721 if (ret < 0) {
722 free(buf);
723 *sz = 0;
724 return NULL;
725 } else if (ret < CHUNKSIZE) {
726 n += ret;
727 *sz = n;
728 return buf;
729 } else {
730 n += CHUNKSIZE;
731 }
732 }
733 }
734
735 static void usage(void)
736 {
737 fprintf(stderr, "Usage:\n"
738 "\tdisasm [-g GPUVER] [-v] [-c] filename.asm\n"
739 "\t\t-g - specify GPU version (5, etc)\n"
740 "\t\t-c - use colors\n"
741 "\t\t-v - verbose output\n"
742 );
743 exit(2);
744 }
745
746 int main(int argc, char **argv)
747 {
748 uint32_t *buf;
749 char *file, *control_reg_name;
750 bool colors = false;
751 int sz, c;
752
753 /* Argument parsing: */
754 while ((c = getopt (argc, argv, "g:vc")) != -1) {
755 switch (c) {
756 case 'g':
757 gpuver = atoi(optarg);
758 break;
759 case 'v':
760 verbose = true;
761 break;
762 case 'c':
763 colors = true;
764 break;
765 default:
766 usage();
767 }
768 }
769
770 if (optind >= argc) {
771 fprintf(stderr, "no file specified!\n");
772 usage();
773 }
774
775 file = argv[optind];
776
777 /* if gpu version not specified, infer from filename: */
778 if (!gpuver) {
779 if (strstr(file, "a5")) {
780 gpuver = 5;
781 } else if (strstr(file, "a6")) {
782 gpuver = 6;
783 }
784 }
785
786 switch (gpuver) {
787 case 6:
788 printf("; a6xx microcode\n");
789 variant = "A6XX";
790 control_reg_name = "A6XX_CONTROL_REG";
791 break;
792 case 5:
793 printf("; a5xx microcode\n");
794 variant = "A5XX";
795 control_reg_name = "A5XX_CONTROL_REG";
796 break;
797 default:
798 fprintf(stderr, "unknown GPU version!\n");
799 usage();
800 }
801
802 rnn_init();
803 db = rnn_newdb();
804
805 ctx = rnndec_newcontext(db);
806 ctx->colors = colors ? &envy_def_colors : &envy_null_colors;
807
808 rnn_parsefile(db, "adreno.xml");
809 rnn_prepdb(db);
810 if (db->estatus)
811 errx(db->estatus, "failed to parse register database");
812 dom[0] = rnn_finddomain(db, variant);
813 dom[1] = rnn_finddomain(db, "AXXX");
814 control_regs = rnn_finddomain(db, control_reg_name);
815
816 rnndec_varadd(ctx, "chip", variant);
817
818 buf = (uint32_t *)readfile(file, &sz);
819
820 printf("; Disassembling microcode: %s\n", file);
821 printf("; Version: %08x\n\n", buf[1]);
822 disasm(&buf[1], sz/4 - 1);
823
824 return 0;
825 }