home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 77 < prev    next >
Encoding:
Internet Message Format  |  1991-06-04  |  56.5 KB

  1. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  2. Newsgroups: comp.sources.apple2
  3. Subject: v001SRC057:  coff -- Dump OMF Files Under Orca (GS), Part02/04
  4. Message-ID: <Jun.1.12.21.11.1991.13059@yoko.rutgers.edu>
  5. Date: 1 Jun 91 16:21:11 GMT
  6. Approved: jac@paul.rutgers.edu
  7.  
  8.  
  9. Submitted-by: Albert Chin (acmfiu@fiu.edu)
  10. Posting-number: Volume 1, Source:57
  11. Archive-name: util/gs/shell/orca/coff/part02
  12. Architecture: ONLY_2gs
  13. Version-number: 1.00
  14.  
  15.  
  16. =coff.c
  17. -/*
  18. -    utility to dump contents of OMF files
  19. -
  20. -    1990-1991, The UNIX Consortium developer project
  21. -
  22. -    albert chin-a-young ... acmfiu@fiu.edu ... 26285659t@servax.fiu.edu
  23. -
  24. -    -------------------------------------------------------------------
  25. -
  26. -    calling parameters:
  27. -        coff [-OPTIONS] filename [segments..] [loadsegments..]
  28. -
  29. -    OPTIONS     DESCRIPTION
  30. -    -v [+version]    display coff's version number
  31. -    -d [+asm]    dump segment body in 65816-format disassembly
  32. -    -T [+tool]    interpret Toolbox, GS/OS, ProDOS, ROM calls
  33. -    -x [+hex]    dump segment body in hex (can be used with '+asm')
  34. -    -l [+label]    print expressions using labels (default is offsets)
  35. -    -t [+infix]    display expressions in infix form
  36. -    -p [+postfix]    display expressions in postfix form (default)
  37. -    -m [+merlin]    format of '+asm' to use merlin opcodes (default)
  38. -    -o [+orca]    format of '+asm' to use orca/m opcodes
  39. -    -a [+shorta]    8-bit accumulator
  40. -    -i [+shorti]    8-bit index registers
  41. -    -s [+header]    dump segment headers only
  42. -    -n [+noheader]    do not print segment headers
  43. -    -f [+nooffset]    do not print offset into file
  44. -    -h [+help]    print this information, then quit
  45. -
  46. -    filename    name of file to dump
  47. -    [segments]    names of segments in file to dump
  48. -    [loadsegments]    names of load segments in file to dump
  49. -
  50. -    ----------------------------------------------------------------------
  51. -
  52. -    history:
  53. -
  54. -    v1.0d    may 2, 1991                    albert chin
  55. -        +longa, +longi removed and replaced by
  56. -            +shorta, +shorti
  57. -        fixed bug if OMF file looked like
  58. -            pea    $<num>
  59. -            jsl    ><name>
  60. -            (thanks tim meekins)
  61. -        fixed bug for dangling asm opcodes at end
  62. -            of OMF segment
  63. -            (thanks tim meekins)
  64. -
  65. -    v1.0c    april 30, 1991                    albert chin
  66. -        new implementation of hex mode
  67. -            (thanks to tim meekins)
  68. -        +tool option recognizes toolbox, GS/OS,
  69. -            ProDOS calls, ROM addresses
  70. -            (thanks to morgan davis, dave lyons)
  71. -        removed all global variables except flags
  72. -        removed inline asm bug fix (my fault)
  73. -        cleaned up code
  74. -        minimal speed improvement
  75. -        program name changed to 'coff' to match UNIX
  76. -        minor bug fixes
  77. -        bug fix to 65816 expression at end of CONST
  78. -            record. parsing the syntax of this opcode
  79. -            was dead wrong.
  80. -        minimize parentheses routine for disassembly
  81. -            (thanks to tim meekins)
  82. -
  83. -    v1.0b    january 22, 1991                albert chin
  84. -        fix pause, oa-period
  85. -            (thanks to jawaid bazyar, tim meekins)
  86. -        fix to disassembly routines
  87. -        set reload bit
  88. -
  89. -    v0.9b    january 12, 1991                albert chin
  90. -        fix to disasm routines
  91. -        fix to displacement, code counter
  92. -        +infix option working
  93. -        +nooffset option working
  94. -        +postfix option added
  95. -        +label option added
  96. -        all file i/o converted to GS/OS calls
  97. -        added record tyep: BEXPR
  98. -
  99. -    v0.8b    december 21, 1990                albert chin
  100. -        support for OMF v2.0 headers
  101. -        added record type: LCONST
  102. -
  103. -    v0.7b    december 19, 1990                albert chin
  104. -        added record types: GEQU, MEM, EQU
  105. -
  106. -    v0.6b    december 18, 1990                albert chin
  107. -        initial release of beta
  108. - */
  109. -
  110. -
  111. -#include "coff.h"
  112. -
  113. -asm short
  114. -key (void)
  115. -{
  116. -        sep    #0x20
  117. -        lda    >0xe0c000
  118. -        bpl    end
  119. -        cmp    #0xae            /* oa-period */
  120. -        bne    wait
  121. -        lda    >0xe0c025
  122. -        and    #0x80
  123. -        beq    wait
  124. -
  125. -        lda    >0xe0c010
  126. -        rep    #0x20
  127. -        lda    #TRUE
  128. -        rtl
  129. -
  130. -    wait:    lda    >0xe0c010
  131. -    rdkey:    lda    >0xe0c000
  132. -        bpl    rdkey
  133. -        lda    >0xe0c010
  134. -
  135. -    end:    rep    #0x20
  136. -        lda    #FALSE
  137. -        rtl
  138. -}
  139. -
  140. -void
  141. -bye (HEADER *omf)
  142. -{
  143. -    GSOSclose (omf->refNum);
  144. -    free (omf);
  145. -    ResourceShutDown ();
  146. -    MMShutDown (userID);
  147. -
  148. -    exit (1);
  149. -}
  150. -
  151. -void
  152. -read_header (HEADER *omf)
  153. -{
  154. -    unsigned char kind, lablen;
  155. -
  156. -    read_long (omf->refNum, omf->bytecnt);
  157. -    read_long (omf->refNum, omf->resspc);
  158. -    read_long (omf->refNum, omf->length);
  159. -    read_char (omf->refNum, kind);
  160. -    omf->kind = kind;
  161. -    read_char (omf->refNum, omf->lablen);
  162. -    read_char (omf->refNum, omf->numlen);
  163. -    read_char (omf->refNum, omf->version);
  164. -    omf->revision = 0;
  165. -    read_long (omf->refNum, omf->banksize);
  166. -    if (omf->version != 1)
  167. -    {
  168. -        unsigned short unused;
  169. -
  170. -        read_int (omf->refNum, omf->kind);
  171. -        read_int (omf->refNum, unused);
  172. -    }
  173. -    else
  174. -    {
  175. -        unsigned long unused;
  176. -
  177. -        read_long (omf->refNum, unused);
  178. -    }
  179. -    read_long (omf->refNum, omf->org);
  180. -    read_long (omf->refNum, omf->align);
  181. -    read_char (omf->refNum, omf->numsex);
  182. -    read_char (omf->refNum, omf->lcbank);        /* not visible in OMF 2.x */
  183. -    read_int (omf->refNum, omf->segnum);
  184. -    read_long (omf->refNum, omf->entry);
  185. -    read_int (omf->refNum, omf->dispname);
  186. -    read_int (omf->refNum, omf->dispdata);
  187. -    if (omf->version != 1)
  188. -        read_long (omf->refNum, omf->temporg);
  189. -
  190. -    GSOSset_mark (omf->refNum, omf->offset + omf->dispname);
  191. -    GSOSread (omf->refNum, omf->loadname, LOADNAME_LEN);
  192. -    omf->loadname[LOADNAME_LEN] = '\0';
  193. -    if (omf->lablen)
  194. -        lablen = omf->lablen;
  195. -    else
  196. -        read_char (omf->refNum, lablen);
  197. -
  198. -    omf->segname = malloc (lablen + 1);
  199. -    GSOSread (omf->refNum, omf->segname, lablen);
  200. -    omf->segname[lablen] = '\0';
  201. -}
  202. -
  203. -void
  204. -print_header (HEADER *omf)
  205. -{
  206. -    printf ("%s   : $%0.8lx%35lu\n", (omf->version >= 2 ? "byte count " : "block count"), omf->bytecnt, omf->bytecnt);
  207. -    printf ("reserved space: $%0.8lx%35lu\n", omf->resspc, omf->resspc);
  208. -    printf ("length        : $%0.8lx%35lu\n", omf->length, omf->length);
  209. -    printf ("label length  : $%0.2x%41u\n", (unsigned short)omf->lablen, (unsigned short)omf->lablen);
  210. -    printf ("number length : $%0.2x%41u\n", (unsigned short)omf->numlen, (unsigned short)omf->numlen);
  211. -    printf ("version       : $%0.2x%41u\n", (unsigned short)omf->version, (unsigned short)omf->version);
  212. -    if (omf->revision)
  213. -        printf ("revision      : $%0.2x%41u\n", (unsigned short)omf->revision, (unsigned short)omf->revision);
  214. -    printf ("bank size     : $%0.8lx%35lu\n", omf->banksize, omf->banksize);
  215. -    if (omf->version == 1)
  216. -        printf ("kind           : $%0.2x%41s\n", omf->kind, parse_kind_1 (omf->kind));
  217. -    else
  218. -        printf ("kind           : $%0.4x%39s\n", omf->kind, parse_kind_2 (omf->kind));
  219. -    printf ("org           : $%0.8lx%35lu\n", omf->org, omf->org);
  220. -    printf ("alignment     : $%0.8lx%35lu\n", omf->align, omf->align);
  221. -    printf ("number sex    : $%0.2x%41u\n", (unsigned short)omf->numsex, (unsigned short)omf->numsex);
  222. -    printf ("segment number: $%0.4x%39u\n", omf->segnum, omf->segnum);
  223. -    printf ("entry           : $%0.8lx%35lu\n", omf->entry, omf->entry);
  224. -    printf ("disp to names : $%0.4x%39u\n", omf->dispname, omf->dispname);
  225. -    printf ("disp to data  : $%0.4x%39u\n", omf->dispdata, omf->dispdata);
  226. -    printf ("load name     : %s\n", omf->loadname);
  227. -    printf ("segment name  : %s\n\n", omf->segname);
  228. -}
  229. -
  230. -char *
  231. -parse_kind_1 (unsigned short kind)
  232. -{
  233. -    static char kind_str[KIND_LEN];
  234. -    unsigned short i, type[] = { POSITION_INDEPENDENT, PRIVATE };
  235. -
  236. -    kind_str[0] = '\0';
  237. -
  238. -    if (kind & DYNAMIC)
  239. -        strcat (kind_str, "dynamic");
  240. -    else
  241. -        strcat (kind_str, "static");
  242. -
  243. -    for (i = 0; i < 2; ++i)
  244. -        switch ((kind << 8) & type[i])
  245. -        {
  246. -            case POSITION_INDEPENDENT:
  247. -                strcat (kind_str, " position independent");
  248. -                break;
  249. -
  250. -            case PRIVATE:
  251. -                strcat (kind_str, " private");
  252. -                break;
  253. -        }
  254. -
  255. -    if ((kind & 0x1f) == 0)
  256. -        strcat (kind_str, " code");
  257. -    if ((kind & DATA) == DATA)
  258. -        strcat (kind_str, " data");
  259. -    if ((kind & JUMP_TABLE) == JUMP_TABLE)
  260. -        strcat (kind_str, " jump-table");
  261. -    if ((kind & PATHNAME) == PATHNAME)
  262. -        strcat (kind_str, " pathname");
  263. -    if ((kind & LIBRARY_DICTIONARY) == LIBRARY_DICTIONARY)
  264. -        strcat (kind_str, " library dictionary");
  265. -    if ((kind & INITIALIZATION) == INITIALIZATION)
  266. -        strcat (kind_str, " initialization");
  267. -    if ((kind & ABSOLUTE_BANK_SEG) == ABSOLUTE_BANK_SEG)
  268. -        strcat (kind_str, " absolute_bank");
  269. -    if ((kind & DIRECT_PAGE) == DIRECT_PAGE)
  270. -        strcat (kind_str, " direct-page/stack");
  271. -
  272. -    return (kind_str);
  273. -}
  274. -
  275. -char *
  276. -parse_kind_2 (unsigned short kind)
  277. -{
  278. -    static char kind_str[KIND_LEN];
  279. -    unsigned short i, type[] = {    PRIVATE, POSITION_INDEPENDENT,
  280. -                    ABSOLUTE_BANK, RELOAD, SKIP,
  281. -                    BANK_RELATIVE };
  282. -
  283. -    kind_str[0] = '\0';
  284. -
  285. -    if (kind & DYNAMIC)
  286. -        strcat (kind_str, "dynamic");
  287. -    else
  288. -        strcat (kind_str, "static");
  289. -
  290. -    for (i = 0; i < 6; ++i)
  291. -        switch (kind & type[i])
  292. -        {
  293. -            case BANK_RELATIVE:
  294. -                strcat (kind_str, " bank-relative");
  295. -                break;
  296. -
  297. -            case SKIP:
  298. -                strcat (kind_str, " skip");
  299. -                break;
  300. -
  301. -            case RELOAD:
  302. -                strcat (kind_str, " reload");
  303. -                break;
  304. -
  305. -            case ABSOLUTE_BANK:
  306. -                strcat (kind_str, " absolute_bank");
  307. -                break;
  308. -
  309. -            case POSITION_INDEPENDENT:
  310. -                strcat (kind_str, " position independent");
  311. -                break;
  312. -
  313. -            case PRIVATE:
  314. -                strcat (kind_str, " private");
  315. -                break;
  316. -        }
  317. -
  318. -    if ((kind & 0xfffe) == CODE)
  319. -        strcat (kind_str, " code");
  320. -    if ((kind & DATA) == DATA)
  321. -        strcat (kind_str, " data");
  322. -    if ((kind & JUMP_TABLE) == JUMP_TABLE)
  323. -        strcat (kind_str, " jump-table");
  324. -    if ((kind & PATHNAME) == PATHNAME)
  325. -        strcat (kind_str, " pathname");
  326. -    if ((kind & LIBRARY_DICTIONARY) == LIBRARY_DICTIONARY)
  327. -        strcat (kind_str, " library dictionary");
  328. -    if ((kind & INITIALIZATION) == INITIALIZATION)
  329. -        strcat (kind_str, " initialization");
  330. -    if ((kind & DIRECT_PAGE) == DIRECT_PAGE)
  331. -        strcat (kind_str, " direct-page/stack");
  332. -
  333. -    return (kind_str);
  334. -}
  335. -
  336. -void
  337. -display_header_asm (HEADER *omf)
  338. -{
  339. -    switch (assembler)
  340. -    {
  341. -        case merlin:
  342. -            if (!nooffset)
  343. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  344. -            puts ("       xc");
  345. -            if (!nooffset)
  346. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  347. -            puts ("       xc");
  348. -            asm_status_bit (omf, LONGA);
  349. -            if (!nooffset)
  350. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  351. -            printf ("%-10s equ    *\n", omf->segname);
  352. -            break;
  353. -
  354. -        case orca:
  355. -            asm_status_bit (omf, LONGA);
  356. -            asm_status_bit (omf, LONGI);
  357. -            if (!nooffset)
  358. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  359. -            printf ("%-10s %s\n", omf->segname, ((omf->kind & DATA == DATA) ? "data" : "start"));
  360. -            break;
  361. -    }
  362. -}
  363. -
  364. -void
  365. -asm_status_bit (HEADER *omf, unsigned short status_bit)
  366. -{
  367. -    if (!nooffset)
  368. -        printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  369. -    printf ("        ");
  370. -
  371. -    switch (assembler)
  372. -    {
  373. -        case merlin:
  374. -            printf ("mx    %%%u%u\n", (unsigned short)shorta,
  375. -                (unsigned short)shorti);
  376. -            break;
  377. -
  378. -        case orca:
  379. -            if (status_bit == LONGA)
  380. -                printf ("longa    %s\n", (shorta ? "on" : "off"));
  381. -            else
  382. -                printf ("longi    %s\n", (shorti ? "on" : "off"));
  383. -            break;
  384. -    }
  385. -
  386. -}
  387. -
  388. -void
  389. -parse_opcode_1 (HEADER *omf, unsigned char opcode)
  390. -{
  391. -    printf ("%s    ", opcodes[opcode].syntax);
  392. -    if (opcodes[opcode].mode == ACCUMULATOR && assembler == orca)
  393. -        putchar ('a');
  394. -    else
  395. -        putchar (' ');
  396. -    print_hex_ascii (opcode, 0, 1, 8);
  397. -
  398. -    ++omf->displacement;
  399. -    ++omf->counter;
  400. -}
  401. -
  402. -unsigned long
  403. -parse_opcode_2 (HEADER *omf, LABEL *lab, unsigned long count, unsigned char opcode)
  404. -{
  405. -    unsigned short uval;
  406. -    signed short sval;
  407. -
  408. -    if ((opcodes[opcode].m && !shorta) || (opcodes[opcode].i && !shorti))
  409. -    {
  410. -        if (count >= 3)
  411. -        {
  412. -            omf->displacement += 3;
  413. -            omf->counter += 3;
  414. -            read_int (omf->refNum, sval);
  415. -            uval = sval;
  416. -            if (tool && opcode == LDX)
  417. -                count = parse_stack (omf, opcode, uval, count);
  418. -            else
  419. -                print_opcode_3 (omf, opcode, sval);
  420. -
  421. -            return (count -= 3);
  422. -        }
  423. -        else
  424. -            if ((omf->counter + 3) >= omf->length)
  425. -                print_byte (omf, count, opcode);
  426. -            else
  427. -                parse_expr_asm (omf, lab, opcode);
  428. -    }
  429. -    else
  430. -    {
  431. -        if (count >= 2)
  432. -        {
  433. -            print_opcode_2 (omf, opcode);
  434. -            return (count -= 2);
  435. -        }
  436. -        else
  437. -            if ((omf->counter + 2) >= omf->length)
  438. -                print_byte (omf, count, opcode);
  439. -            else
  440. -                parse_expr_asm (omf, lab, opcode);
  441. -    }
  442. -
  443. -    return (0);
  444. -}
  445. -
  446. -void
  447. -print_opcode_2 (HEADER *omf, unsigned char opcode)
  448. -{
  449. -    signed char sval;
  450. -    unsigned char uval;
  451. -    unsigned int tmp, num;
  452. -
  453. -    read_char (omf->refNum, sval);
  454. -    uval = sval;
  455. -    if (opcodes[opcode].mode == PC_RELATIVE)
  456. -    {
  457. -        printf (opcodes[opcode].syntax, (unsigned short)(omf->counter + sval + 2), &tmp);
  458. -        num = tmp;
  459. -        printf ("     {%c%0.2x}%n", (sval < 0 ? '-' : '+'),
  460. -            (unsigned short)(sval > 0 ? sval : -sval), &num);
  461. -        num += tmp;
  462. -    }
  463. -    else
  464. -        printf (opcodes[opcode].syntax, uval, &num);
  465. -
  466. -    print_hex_ascii (opcode, uval, 2, num);
  467. -    if (opcode == REP || opcode == SEP)
  468. -        parse_rep_sep (omf, opcode, uval);
  469. -    omf->displacement += 2;
  470. -    omf->counter += 2;
  471. -}
  472. -
  473. -unsigned long
  474. -parse_opcode_3 (HEADER *omf, LABEL *lab, unsigned long count, unsigned char opcode)
  475. -{
  476. -    unsigned long tmp;
  477. -    signed short sval;
  478. -    unsigned short uval;
  479. -
  480. -    if (count >= 3)
  481. -    {
  482. -        omf->displacement += 3;
  483. -        omf->counter += 3;
  484. -        read_int (omf->refNum, sval);
  485. -        uval = sval;
  486. -        if (tool)
  487. -        {
  488. -            if (opcode == JSR)
  489. -            {
  490. -                tmp = parse_inline_3 (omf, lab, uval, count);
  491. -                if (tmp == count)
  492. -                    print_opcode_3 (omf, opcode, sval);
  493. -                else
  494. -                    count = tmp;
  495. -            }
  496. -            else
  497. -                if (opcode == PEA)
  498. -                    count = parse_stack (omf, opcode, uval, count);
  499. -                else
  500. -                    print_opcode_3 (omf, opcode, sval);
  501. -        }
  502. -        else
  503. -            print_opcode_3 (omf, opcode, sval);
  504. -
  505. -        return (count -= 3);
  506. -    }
  507. -    else
  508. -        if ((omf->counter + 3) >= omf->length)
  509. -            print_byte (omf, count, opcode);
  510. -        else
  511. -            parse_expr_asm (omf, lab, opcode);
  512. -
  513. -    return (0);
  514. -}
  515. -
  516. -void
  517. -print_opcode_3 (HEADER *omf, unsigned char opcode, signed short sval)
  518. -{
  519. -    unsigned short uval = sval;
  520. -    unsigned int tmp, num;
  521. -    Handle name = NULL;
  522. -
  523. -    if (tool && opcodes[opcode].mode == ABSOLUTE)
  524. -    {
  525. -        name = LoadResource (rROM, (Longword)uval);
  526. -        if (name)
  527. -            printf ("%.3s     %s%n", opcodes[opcode].syntax, *name, &num);
  528. -        else
  529. -            printf (opcodes[opcode].syntax, uval, &num);
  530. -    }
  531. -    else
  532. -        if (opcodes[opcode].mode == PC_RELATIVE_LONG)
  533. -        {
  534. -            printf (opcodes[opcode].syntax, (unsigned short)(omf->counter + sval + 2), &tmp);
  535. -            num = tmp;
  536. -            printf ("   {%c%0.4x}%n", (sval < 0 ? '-' : '+'),
  537. -                (unsigned short)(sval > 0 ? sval : -sval), &num);
  538. -            num += tmp;
  539. -        }
  540. -        else
  541. -            printf (opcodes[opcode].syntax, uval, &num);
  542. -
  543. -    print_hex_ascii (opcode, uval, 3, num);
  544. -}
  545. -
  546. -unsigned long
  547. -parse_inline_3 (HEADER *omf, LABEL *lab, unsigned short toolnum, unsigned long count)
  548. -{
  549. -    Handle name = NULL;
  550. -    enum assembler tmp_asm = assembler;
  551. -    unsigned char callnum;
  552. -    unsigned short parmblock;
  553. -    unsigned long mark;
  554. -
  555. -    if (toolnum != PRODOS_MLI)
  556. -        return (count);
  557. -
  558. -    mark = GSOSget_mark (omf->refNum);
  559. -    switch (count)
  560. -    {
  561. -        case 3:
  562. -            return (count);
  563. -            break;
  564. -
  565. -        case 4:
  566. -            read_char (omf->refNum, callnum);
  567. -            name = LoadResource (rGSOS, (Longword)callnum);
  568. -            if (!name)
  569. -            {
  570. -                GSOSset_mark (omf->refNum, mark);
  571. -                return (count);
  572. -            }
  573. -            ++omf->displacement;
  574. -            ++omf->counter;
  575. -            printf ("_%s ", *name);
  576. -            assembler = merlin;
  577. -            parse_expr_asm (omf, lab, DC);
  578. -            assembler = tmp_asm;
  579. -            return (3);
  580. -            break;
  581. -
  582. -        default:
  583. -            read_char (omf->refNum, callnum);
  584. -            read_int (omf->refNum, parmblock);
  585. -            name = LoadResource (rGSOS, (Longword)callnum);
  586. -            if (!name)
  587. -            {
  588. -                GSOSset_mark (omf->refNum, mark);
  589. -                return (count);
  590. -            }
  591. -            printf ("_%s $%x\n", *name, parmblock);
  592. -            omf->displacement += 3;
  593. -            omf->counter += 3;
  594. -            return (count -= 3);
  595. -            break;
  596. -    }
  597. -}
  598. -
  599. -unsigned long
  600. -parse_stack (HEADER *omf, unsigned char opcode, unsigned short callnum, unsigned long count)
  601. -{
  602. -    unsigned long mark, toolnum = 0;
  603. -    signed short sval = callnum;
  604. -    unsigned char jsl;
  605. -
  606. -    if (count >= 7)
  607. -    {
  608. -        mark = GSOSget_mark (omf->refNum);
  609. -        read_char (omf->refNum, jsl);
  610. -        GSOSread (omf->refNum, &toolnum, 3);
  611. -        if (tool && jsl == JSL && (toolnum == GSOS_STACK || toolnum == TOOL_STACK || toolnum == TOOL_STACK_ALT))
  612. -        {
  613. -            Handle name = NULL;
  614. -
  615. -            if (toolnum == GSOS_STACK)
  616. -                name = LoadResource (rGSOS, (Longword)callnum);
  617. -            else
  618. -                name = LoadResource (rTool, (Longword)callnum);
  619. -
  620. -            if (name)
  621. -            {
  622. -                omf->displacement += 4;
  623. -                omf->counter += 4;
  624. -                printf ("_%s\n", *name);
  625. -                count -= 4;
  626. -            }
  627. -            else
  628. -            {
  629. -                GSOSset_mark (omf->refNum, mark);
  630. -                print_opcode_3 (omf, opcode, sval);
  631. -            }
  632. -        }
  633. -        else
  634. -        {
  635. -            GSOSset_mark (omf->refNum, mark);
  636. -            print_opcode_3 (omf, opcode, sval);
  637. -        }
  638. -    }
  639. -    else
  640. -        print_opcode_3 (omf, opcode, sval);
  641. -
  642. -    return (count);
  643. -}
  644. -
  645. -unsigned long
  646. -parse_opcode_4 (HEADER *omf, LABEL *lab, unsigned long count, unsigned char opcode)
  647. -{
  648. -    unsigned long val = 0, tmp;
  649. -
  650. -    if (count >= 4)
  651. -    {
  652. -        omf->displacement += 4;
  653. -        omf->counter += 4;
  654. -        GSOSread (omf->refNum, &val, 3);
  655. -        if (tool && opcode == JSL)
  656. -        {
  657. -            tmp = parse_inline_4 (omf, lab, val, count);
  658. -            if (tmp == count)
  659. -                print_opcode_4 (omf, opcode, val);
  660. -            else
  661. -                count = tmp;
  662. -        }
  663. -        else
  664. -            print_opcode_4 (omf, opcode, val);
  665. -
  666. -        return (count -= 4);
  667. -    }
  668. -    else
  669. -        if ((omf->counter + 4) >= omf->length)
  670. -            print_byte (omf, count, opcode);
  671. -        else
  672. -            parse_expr_asm (omf, lab, opcode);
  673. -
  674. -    return (0);
  675. -}
  676. -
  677. -void
  678. -print_opcode_4 (HEADER *omf, unsigned char opcode, unsigned long val)
  679. -{
  680. -    unsigned int num;
  681. -    unsigned char bank;
  682. -    unsigned short addr;
  683. -    Handle name = NULL;
  684. -
  685. -    if (tool && opcodes[opcode].mode == ABSOLUTE_LONG)
  686. -    {
  687. -        bank = (char)((val & 0xff0000) >> 16);
  688. -        addr = (unsigned short)(val & 0x00ffff);
  689. -        if (bank == 0xe0)
  690. -            name = LoadResource (rROM, (Longword)addr);
  691. -        else
  692. -            name = LoadResource (rROM, val);
  693. -        if (name)
  694. -            printf ("%.7s%s%s%n", opcodes[opcode].syntax,
  695. -                bank == 0xe0 ? "e0_" : "", *name, &num);
  696. -        else
  697. -            printf (opcodes[opcode].syntax, (assembler == merlin ? '|' : '>'), val, &num);
  698. -    }
  699. -    else
  700. -        printf (opcodes[opcode].syntax, (assembler == merlin ? '|' : '>'), val, &num);
  701. -
  702. -    print_hex_ascii (opcode, val, 4, num);
  703. -}
  704. -
  705. -unsigned long
  706. -parse_inline_4 (HEADER *omf, LABEL *lab, unsigned long toolnum, unsigned long count)
  707. -{
  708. -    Handle name = NULL;
  709. -    enum assembler tmp_asm = assembler;
  710. -    unsigned short callnum;
  711. -    unsigned long parmblock, mark;
  712. -
  713. -    if (toolnum != GSOS_INLINE)
  714. -        return (count);
  715. -
  716. -    mark = GSOSget_mark (omf->refNum);
  717. -    switch (count)
  718. -    {
  719. -        case 4:
  720. -            return (count);
  721. -            break;
  722. -
  723. -        case 6:
  724. -            read_int (omf->refNum, callnum);
  725. -            name = LoadResource (rGSOS, (Longword)callnum);
  726. -            if (!name)
  727. -            {
  728. -                GSOSset_mark (omf->refNum, mark);
  729. -                return (count);
  730. -            }
  731. -            omf->displacement += 2;
  732. -            omf->counter += 2;
  733. -            printf ("_%s ", *name);
  734. -            assembler = merlin;
  735. -            parse_expr_asm (omf, lab, DC);
  736. -            assembler = tmp_asm;
  737. -            return (4);
  738. -            break;
  739. -
  740. -        default:
  741. -            read_int (omf->refNum, callnum);
  742. -            read_long (omf->refNum, parmblock);
  743. -            name = LoadResource (rGSOS, (Longword)callnum);
  744. -            if (!name)
  745. -            {
  746. -                GSOSset_mark (omf->refNum, mark);
  747. -                return (count);
  748. -            }
  749. -            printf ("_%s $%lx\n", *name, parmblock);
  750. -            omf->displacement += 6;
  751. -            omf->counter += 6;
  752. -            return (count -= 6);
  753. -            break;
  754. -    }
  755. -}
  756. -
  757. -void
  758. -print_hex_ascii (unsigned char opcode, unsigned long val, unsigned short bytes, unsigned int num)
  759. -{
  760. -    unsigned char val1 = val;
  761. -    unsigned short val2 = val;
  762. -    unsigned long val4 = val;
  763. -
  764. -    if (!hex)
  765. -    {
  766. -        putchar ('\n');
  767. -        return;
  768. -    }
  769. -
  770. -    printf ("%*c", 33 - num, ' ');
  771. -    switch (bytes)
  772. -    {
  773. -        case 1:
  774. -            printf ("%0.2x        - ", (unsigned short)opcode);
  775. -            if (isprint (opcode))
  776. -                putchar (opcode);
  777. -            else
  778. -                putchar ('.');
  779. -            break;
  780. -
  781. -        case 2:
  782. -            printf ("%0.2x %0.2x       - ", (unsigned short)opcode,
  783. -                (unsigned short)val1);
  784. -            if (isprint (opcode))
  785. -                putchar (opcode);
  786. -            else
  787. -                putchar ('.');
  788. -            if (isprint (val1))
  789. -                putchar (val1);
  790. -            else
  791. -                putchar ('.');
  792. -            break;
  793. -
  794. -        case 3:
  795. -            printf ("%0.2x %0.2x %0.2x    - ", (unsigned short)opcode,
  796. -                val2 & 0x00ff, (val2 & 0xff00) >> 8);
  797. -            if (isprint (opcode))
  798. -                putchar (opcode);
  799. -            else
  800. -                putchar ('.');
  801. -            if (isprint ((char)(val2 & 0x00ff)))
  802. -                putchar ((char)(val2 & 0x00ff));
  803. -            else
  804. -                putchar ('.');
  805. -            if (isprint ((char)((val2 & 0xff00) >> 8)))
  806. -                putchar ((char)((val2 & 0xff00) >> 8));
  807. -            else
  808. -                putchar ('.');
  809. -            break;
  810. -
  811. -        case 4:
  812. -            printf ("%0.2x %0.2lx %0.2lx %0.2lx - ", (unsigned short)opcode,
  813. -                val4 & 0x0000ff, (val4 & 0x00ff00) >> 8, (val4 & 0xff0000) >> 16);
  814. -            if (isprint (opcode))
  815. -                putchar (opcode);
  816. -            else
  817. -                putchar ('.');
  818. -            if (isprint ((char)(val4 & 0x0000ff)))
  819. -                putchar ((char)(val4 & 0x0000ff));
  820. -            else
  821. -                putchar ('.');
  822. -            if (isprint ((char)((val4 & 0x00ff00) >> 8)))
  823. -                putchar ((char)((val4 & 0x00ff00) >> 8));
  824. -            else
  825. -                putchar ('.');
  826. -            if (isprint ((char)((val4 & 0xff0000) >> 16)))
  827. -                putchar ((char)((val4 & 0xff0000) >> 16));
  828. -            else
  829. -                putchar ('.');
  830. -            break;
  831. -    }
  832. -
  833. -    putchar ('\n');
  834. -}
  835. -
  836. -void
  837. -parse_expr_asm (HEADER *omf, LABEL *lab, unsigned short opcode)
  838. -{
  839. -    unsigned char record;
  840. -    unsigned short n;
  841. -    char *syntax, *str;
  842. -
  843. -    read_char (omf->refNum, record);
  844. -    if (recognize_record (record))
  845. -    {
  846. -        print_byte (omf, 1, opcode);
  847. -
  848. -        if (!nooffset)
  849. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  850. -        n = parse_record (omf, lab, record, FALSE, 0);
  851. -        if (n > 0)
  852. -            puts (assembler == merlin ? "" : "\'");
  853. -    }
  854. -    else
  855. -        if (opcode != DC)
  856. -        {
  857. -            enum assembler tmp = assembler;
  858. -
  859. -            switch (opcodes[opcode].mode)
  860. -            {
  861. -                case ABSOLUTE_LONG:
  862. -                case ABSOLUTE_LONG_INDEX_X:
  863. -                    syntax = opcodes[opcode].syntax;
  864. -                    str = strchr (syntax, '%');
  865. -                    printf ("%.*s %c", (int)(str - syntax - 1), syntax, assembler == merlin ? '|' : '>');
  866. -                    assembler = merlin;
  867. -                    n = parse_record (omf, lab, record, FALSE, 0);
  868. -                    str = strchr (str, 'x');
  869. -                    if (strlen (str) - 3)
  870. -                        printf ("%.*s", (int)(strlen (str) - 3), str + 1);
  871. -                    putchar ('\n');
  872. -                    break;
  873. -
  874. -                case BLOCK_MOVE:
  875. -                    assembler = merlin;
  876. -                    syntax = opcodes[opcode].syntax;
  877. -                    str = strchr (syntax, '%');
  878. -                    printf ("%.*s", (int)(str - syntax - 1), syntax);
  879. -                    n = parse_record (omf, lab, record, FALSE, 0);
  880. -                    printf (", ");
  881. -                    read_char (omf->refNum, record);
  882. -                    n = parse_record (omf, lab, record, FALSE, n + 2);
  883. -                    putchar ('\n');
  884. -                    break;
  885. -
  886. -                default:
  887. -                    assembler = merlin;
  888. -                    syntax = opcodes[opcode].syntax;
  889. -                    str = strchr (syntax, '%');
  890. -                    printf ("%.*s", (int)(str - syntax - 1), syntax);
  891. -                    parse_record (omf, lab, record, FALSE, 0);
  892. -                    str = strchr (str, 'x');
  893. -                    if (strlen (str) - 3)
  894. -                        printf ("%.*s", (int)(strlen (str) - 3), str + 1);
  895. -                    putchar ('\n');
  896. -                    break;
  897. -            }
  898. -
  899. -            assembler = tmp;
  900. -            ++omf->counter;
  901. -        }
  902. -        else
  903. -        {
  904. -            n = parse_record (omf, lab, record, FALSE, 0);
  905. -            if (n > 0)
  906. -                putchar ('\n');
  907. -        }
  908. -
  909. -    ++omf->displacement;
  910. -}
  911. -
  912. -void
  913. -print_byte (HEADER *omf, unsigned long count, unsigned char opcode)
  914. -{
  915. -    unsigned char val;
  916. -    unsigned short num = 2, i, j = count;
  917. -    char ptr[5];
  918. -
  919. -    omf->displacement += count;
  920. -    omf->counter += count;
  921. -    if (assembler == merlin)
  922. -        printf ("hex    %0.2x", (unsigned short)opcode);
  923. -    else
  924. -        printf ("dc    h'%0.2x", (unsigned short)opcode);
  925. -
  926. -    ptr[count] = opcode;
  927. -    while (--count)
  928. -    {
  929. -        read_char (omf->refNum, val);
  930. -        printf ("%0.2x", (unsigned short)val);
  931. -        ptr[count] = val;
  932. -        num += 2;
  933. -    }
  934. -
  935. -    if (assembler == orca)
  936. -        putchar ('\'');
  937. -    if (hex)
  938. -    {
  939. -        printf ("%*c", 26 - num - (assembler == merlin ? 0 : 2), ' ');
  940. -        for (i = j; i > 0; --i)
  941. -            printf ("%0.2x ", (unsigned short)ptr[i]);
  942. -        printf ("%*c- ", (int)(12 - (3 * j)), ' ');
  943. -        for (i = j; i > 0; --i)
  944. -            if (isprint (ptr[i]))
  945. -                putchar (ptr[i]);
  946. -            else
  947. -                putchar ('.');
  948. -    }
  949. -
  950. -    putchar ('\n');
  951. -}
  952. -
  953. -void
  954. -parse_rep_sep (HEADER *omf, unsigned char opcode, unsigned char val)
  955. -{
  956. -    switch (opcode)
  957. -    {
  958. -        case REP:
  959. -            if (val & LONGA)
  960. -            {
  961. -                shorta = FALSE;
  962. -                if (assembler == orca)
  963. -                    asm_status_bit (omf, LONGA);
  964. -            }
  965. -            if (val & LONGI)
  966. -            {
  967. -                shorti = FALSE;
  968. -                if (assembler == orca)
  969. -                    asm_status_bit (omf, LONGI);
  970. -            }
  971. -            if (assembler == merlin)
  972. -                asm_status_bit (omf, LONGA);
  973. -            break;
  974. -
  975. -        case SEP:
  976. -            if (val & LONGA)
  977. -            {
  978. -                shorta = TRUE;
  979. -                if (assembler == orca)
  980. -                    asm_status_bit (omf, LONGA);
  981. -            }
  982. -            if (val & LONGI)
  983. -            {
  984. -                shorti = TRUE;
  985. -                if (assembler == orca)
  986. -                    asm_status_bit (omf, LONGI);
  987. -            }
  988. -            if (assembler == merlin)
  989. -                asm_status_bit (omf, LONGI);
  990. -            break;
  991. -    }
  992. -}
  993. -
  994. -void
  995. -parse_segment_hex (HEADER *omf)
  996. -{
  997. -    unsigned long num = omf->offset;
  998. -
  999. -    if (omf->version == 1)
  1000. -        num += (512 * omf->bytecnt);
  1001. -    else
  1002. -        num += omf->bytecnt;
  1003. -
  1004. -    while (omf->displacement <= num)
  1005. -    {
  1006. -        unsigned short loop;
  1007. -        Longword tmp;
  1008. -        char ptr[20];
  1009. -
  1010. -        if (key ())
  1011. -            bye (omf);
  1012. -
  1013. -        tmp = GSOSread (omf->refNum, ptr, 15);
  1014. -        if (toolerror () || (tmp == 0))
  1015. -            break;
  1016. -
  1017. -        printf ("%0.6lx | ", omf->displacement);
  1018. -        omf->displacement += tmp;
  1019. -
  1020. -        for (loop = 0; loop < tmp; ++loop)
  1021. -            printf ("%0.2x ", (unsigned short)ptr[loop]);
  1022. -
  1023. -        printf ("%*s", (int)(3 * (15 - tmp) + 2), "- ");
  1024. -
  1025. -        for (loop = 0; loop < tmp; ++loop)
  1026. -        {
  1027. -            if (isprint (ptr[loop]))
  1028. -                putchar (ptr[loop]);
  1029. -            else
  1030. -                putchar ('.');
  1031. -        }
  1032. -        putchar ('\n');
  1033. -    }
  1034. -    putchar ('\n');
  1035. -}
  1036. -
  1037. -void
  1038. -parse_segment (HEADER *omf, LABEL *lab)
  1039. -{
  1040. -    unsigned char record;
  1041. -
  1042. -    if (assembly)
  1043. -        display_header_asm (omf);
  1044. -
  1045. -    GSOSset_mark (omf->refNum, omf->displacement);
  1046. -    do
  1047. -    {
  1048. -        if (key ())
  1049. -            bye (omf);
  1050. -
  1051. -        if (!nooffset)
  1052. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1053. -        read_char (omf->refNum, record);
  1054. -        ++omf->displacement;
  1055. -        parse_record (omf, lab, record, TRUE, 0);
  1056. -    } while (record != END);
  1057. -
  1058. -    if (assembly)
  1059. -        printf ("%14s\n\n", "end");
  1060. -    else
  1061. -        puts ("END    (00)\n");
  1062. -
  1063. -    delete_labels (lab, LOCAL);
  1064. -}
  1065. -
  1066. -unsigned short
  1067. -parse_record (HEADER *omf, LABEL *lab, unsigned char record, unsigned short space, unsigned short n)
  1068. -{
  1069. -    unsigned char truncate_size;
  1070. -
  1071. -    switch (record)
  1072. -    {
  1073. -        case END:
  1074. -            break;
  1075. -
  1076. -        case USING:
  1077. -            parse_USING (omf, record);
  1078. -            break;
  1079. -
  1080. -        case STRONG:
  1081. -            parse_STRONG (omf, lab, record);
  1082. -            break;
  1083. -
  1084. -        case GLOBAL:
  1085. -        case LOCAL:
  1086. -            parse_GLOBAL_LOCAL (omf, lab, record);
  1087. -            break;
  1088. -
  1089. -        case GEQU:
  1090. -        case EQU:
  1091. -            n = parse_GEQU_EQU (omf, lab, record, n);
  1092. -            break;
  1093. -
  1094. -        case MEM:
  1095. -            n = parse_MEM (omf, lab, record, n);
  1096. -            break;
  1097. -
  1098. -        case EXPR:
  1099. -        case BEXPR:
  1100. -        case LEXPR:
  1101. -        case RELEXPR:
  1102. -            if (record == EXPR || record == BEXPR || record == LEXPR)
  1103. -                truncate_size = parse_EXPR_BEXPR_LEXPR (omf, record);
  1104. -            else
  1105. -                truncate_size = parse_RELEXPR (omf, record);
  1106. -
  1107. -            if (assembly && space)
  1108. -            {
  1109. -                printf ("        %s", assembler == merlin ? "db     " : "dc       i");
  1110. -                if (assembler == orca)
  1111. -                    printf ("%u\'", (unsigned short)truncate_size);
  1112. -            }
  1113. -            n = parse_expr (omf, lab, n);
  1114. -            if (assembly && space && (n > 0))
  1115. -                puts (assembler == merlin ? "" : "\'");
  1116. -            omf->counter += truncate_size;
  1117. -            break;
  1118. -
  1119. -        case DS:
  1120. -            if (assembly)
  1121. -                printf ("        ");
  1122. -            parse_DS (omf, record);
  1123. -            break;
  1124. -
  1125. -        case LCONST:
  1126. -            if (assembly)
  1127. -                parse_CONST_asm (omf, lab, record);
  1128. -            else
  1129. -                parse_CONST (omf, record);
  1130. -            break;
  1131. -
  1132. -        default:
  1133. -            if (assembly)
  1134. -                parse_CONST_asm (omf, lab, record);
  1135. -            else
  1136. -                parse_CONST (omf, record);
  1137. -            break;
  1138. -    }
  1139. -
  1140. -    return (n);
  1141. -}
  1142. -
  1143. -void
  1144. -parse_CONST (HEADER *omf, unsigned char record)
  1145. -{
  1146. -    unsigned long count, outer = 0, i, j;
  1147. -    unsigned short edge;
  1148. -    char ptr[CONST_EDGE + CONST_EDGE];
  1149. -
  1150. -    if (record == LCONST)
  1151. -    {
  1152. -        printf ("LCONST   (%0.2x) | ", (unsigned short)record);
  1153. -        read_long (omf->refNum, count);
  1154. -        omf->displacement += 4;
  1155. -    }
  1156. -    else
  1157. -    {
  1158. -        printf ("CONST      (%0.2x) | ", (unsigned short)record);
  1159. -        count = record;
  1160. -    }
  1161. -
  1162. -    edge = CONST_EDGE + (nooffset == TRUE ? 5 : 0);
  1163. -    while (outer < count)
  1164. -    {
  1165. -        unsigned short tmp_num = 0, num = 0, inner = 0;
  1166. -
  1167. -        if (key ())
  1168. -            bye (omf);
  1169. -
  1170. -        j = outer + edge;
  1171. -        for (i = outer; i < j && i < count; ++i)
  1172. -        {
  1173. -            read_char (omf->refNum, ptr[inner]);
  1174. -            printf ("%0.2x %n", (unsigned short)ptr[inner++], &num);
  1175. -            tmp_num += num;
  1176. -        }
  1177. -
  1178. -        printf ("%*s", (3 * edge) + 2 - tmp_num, "- ");
  1179. -        for (i = 0; i < inner; ++i)
  1180. -            putchar (isprint (ptr[i]) ? ptr[i] : '.');
  1181. -        putchar ('\n');
  1182. -
  1183. -        outer += inner;
  1184. -        omf->counter += inner;
  1185. -        omf->displacement += inner;
  1186. -
  1187. -        if (outer < count)
  1188. -        {
  1189. -            if (!nooffset)
  1190. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1191. -            printf ("%15c ", '|');
  1192. -        }
  1193. -    }
  1194. -}
  1195. -
  1196. -void
  1197. -parse_CONST_asm (HEADER *omf, LABEL *lab, unsigned char record)
  1198. -{
  1199. -    unsigned long count;
  1200. -
  1201. -    if (record == LCONST)
  1202. -    {
  1203. -        read_long (omf->refNum, count);
  1204. -        omf->displacement += 4;
  1205. -    }
  1206. -    else
  1207. -        count = record;
  1208. -
  1209. -    while (count)
  1210. -    {
  1211. -        unsigned char opcode;
  1212. -
  1213. -        if (key ())
  1214. -            bye (omf);
  1215. -
  1216. -        read_char (omf->refNum, opcode);
  1217. -        ++omf->displacement;
  1218. -
  1219. -        printf ("        ");
  1220. -        switch (opcodes[opcode].bytes)
  1221. -        {
  1222. -            case 1:
  1223. -                parse_opcode_1 (omf, opcode);
  1224. -                --count;
  1225. -                break;
  1226. -
  1227. -            case 2:
  1228. -                count = parse_opcode_2 (omf, lab, count, opcode);
  1229. -                break;
  1230. -
  1231. -            case 3:
  1232. -                count = parse_opcode_3 (omf, lab, count, opcode);
  1233. -                break;
  1234. -
  1235. -            case 4:
  1236. -                count = parse_opcode_4 (omf, lab, count, opcode);
  1237. -                break;
  1238. -        }
  1239. -
  1240. -        if (count && !nooffset)
  1241. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1242. -    }
  1243. -}
  1244. -
  1245. -unsigned short
  1246. -recognize_record (unsigned char record)
  1247. -{
  1248. -    switch (record)
  1249. -    {
  1250. -        case USING:
  1251. -        case STRONG:
  1252. -        case GLOBAL:
  1253. -        case GEQU:
  1254. -        case MEM:
  1255. -        case LOCAL:
  1256. -        case EQU:
  1257. -        case DS:
  1258. -        case LCONST:
  1259. -            return (TRUE);
  1260. -            break;
  1261. -
  1262. -        default:
  1263. -            return (FALSE);
  1264. -            break;
  1265. -    }
  1266. -}
  1267. -
  1268. -void
  1269. -parse_USING (HEADER *omf, unsigned char record)
  1270. -{
  1271. -    unsigned char length;
  1272. -    char *name;
  1273. -
  1274. -    read_char (omf->refNum, length);
  1275. -    name = malloc (length + 1);
  1276. -    GSOSread (omf->refNum, name, length);
  1277. -    name[length] = '\0';
  1278. -
  1279. -    if (!assembly)
  1280. -        printf ("USING      (%0.2x) | %s\n", (unsigned short)record, name);
  1281. -    else
  1282. -        printf ("        using  %s\n", name);
  1283. -
  1284. -    free (name);
  1285. -    omf->displacement += length + 1;
  1286. -}
  1287. -
  1288. -void
  1289. -parse_STRONG (HEADER *omf, LABEL *lab, unsigned char record)
  1290. -{
  1291. -    unsigned char length;
  1292. -    char *name, *str;
  1293. -
  1294. -    str = malloc (strlen (omf->segname) + (sizeof (long) * 2) + 5);
  1295. -    sprintf (str, "(%s+$%lx)", omf->segname, omf->counter);
  1296. -    if (!match_label (lab, str) && assembly)
  1297. -        printf ("%11c", ' ');
  1298. -
  1299. -    read_char (omf->refNum, length);
  1300. -    name = malloc (length + 1);
  1301. -    GSOSread (omf->refNum, name, length);
  1302. -    name[length] = '\0';
  1303. -
  1304. -    if (!assembly)
  1305. -        printf ("STRONG   (%0.2x) | %s\n", (unsigned short)record, name);
  1306. -    else
  1307. -        printf ("dc    r'%s'\n", name);
  1308. -
  1309. -    free (str);
  1310. -    free (name);
  1311. -    omf->displacement += length;
  1312. -}
  1313. -
  1314. -void
  1315. -parse_GLOBAL_LOCAL (HEADER *omf, LABEL *lab, unsigned char record)
  1316. -{
  1317. -    unsigned char length, type, private;
  1318. -    char *name;
  1319. -
  1320. -    read_char (omf->refNum, length);
  1321. -    name = malloc (length + 1);
  1322. -    GSOSread (omf->refNum, name, length);
  1323. -    name[length] = '\0';
  1324. -
  1325. -    if (label)
  1326. -    {
  1327. -        char *expr;
  1328. -
  1329. -        expr = malloc (strlen (omf->segname) + (sizeof (long) * 2) + 5);
  1330. -        sprintf (expr, "(%s+$%lx)", omf->segname, omf->counter);
  1331. -        add_label (lab, name, expr, record);
  1332. -    }
  1333. -    read_char (omf->refNum, length);
  1334. -    read_char (omf->refNum, type);
  1335. -    read_char (omf->refNum, private);
  1336. -
  1337. -    if (!assembly)
  1338. -    {
  1339. -        printf ("%s   (%0.2x) | %s\n", record == GLOBAL ? "GLOBAL" : "LOCAL ", (unsigned short)record, name);
  1340. -        if (!nooffset)
  1341. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1342. -        printf ("%15c len: %0.2x, type: %c", '|', (unsigned short)length, type);
  1343. -        if (private)
  1344. -            printf (", private");
  1345. -        putchar ('\n');
  1346. -    }
  1347. -    else
  1348. -        parse_type_attribute (omf, lab, type, name, length);
  1349. -
  1350. -    if (!label)
  1351. -        free (name);
  1352. -    omf->displacement += length + 4;
  1353. -}
  1354. -
  1355. -void
  1356. -parse_type_attribute (HEADER *omf, LABEL *lab, unsigned char type, char *name, unsigned char length)
  1357. -{
  1358. -    switch (type)
  1359. -    {
  1360. -        case 'A':
  1361. -            parse_GLOBAL_type_A (omf, lab, name, length);
  1362. -            break;
  1363. -
  1364. -        case 'C':
  1365. -            parse_GLOBAL_type_C (omf, lab, name);
  1366. -            break;
  1367. -
  1368. -        case 'D':
  1369. -            parse_GLOBAL_type_D (omf, lab, name);
  1370. -            break;
  1371. -
  1372. -        case 'F':
  1373. -            parse_GLOBAL_type_F (omf, lab, name);
  1374. -            break;
  1375. -
  1376. -        case 'H':
  1377. -            parse_GLOBAL_type_H (omf, lab, name);
  1378. -            break;
  1379. -
  1380. -        case 'I':
  1381. -            parse_GLOBAL_type_I (omf, lab, name, length);
  1382. -            break;
  1383. -
  1384. -        case 'K':
  1385. -            parse_GLOBAL_type_K (omf, lab, name);
  1386. -            break;
  1387. -
  1388. -        case 'L':
  1389. -            parse_GLOBAL_type_L (omf, lab, name, length);
  1390. -            break;
  1391. -
  1392. -        case 'N':
  1393. -            parse_GLOBAL_type_N (omf, lab, name);
  1394. -            break;
  1395. -
  1396. -        case 'S':
  1397. -            parse_GLOBAL_type_S (omf, name);
  1398. -            break;
  1399. -    }
  1400. -}
  1401. -
  1402. -void
  1403. -parse_GLOBAL_type_A (HEADER *omf, LABEL *lab, char *name, unsigned char length)
  1404. -{
  1405. -    unsigned char record;
  1406. -
  1407. -    printf ("%-11s", name);
  1408. -    if (strlen (name) >= 11)
  1409. -        putchar (' ');
  1410. -    printf ("%s", assembler == merlin ? "db     " : "dc    a");
  1411. -    read_char (omf->refNum, record);
  1412. -    if (assembler == orca)
  1413. -        if (record >= 0x01 && record <= 0xdf)
  1414. -            putchar ('\'');
  1415. -        else
  1416. -            printf ("%u\'", (unsigned short)length);
  1417. -
  1418. -    parse_GLOBAL_type (omf, lab, record);
  1419. -}
  1420. -
  1421. -void
  1422. -parse_GLOBAL_type_C (HEADER *omf, LABEL *lab, char *name)
  1423. -{
  1424. -    unsigned char record;
  1425. -
  1426. -    printf ("%-11s", name);
  1427. -    if (strlen (name) >= 11)
  1428. -        putchar (' ');
  1429. -    read_char (omf->refNum, record);
  1430. -    if (record != DS)
  1431. -        printf ("%s", assembler == merlin ? "asc    \'" : "dc      c\'");
  1432. -
  1433. -    if (!parse_GLOBAL_type (omf, lab, record))
  1434. -    {
  1435. -        unsigned char i, j, num, outer = 0;
  1436. -        unsigned short edge;
  1437. -
  1438. -        edge = CHAR_EDGE + (nooffset == TRUE ? 16 : 0);
  1439. -        while (outer < record)
  1440. -        {
  1441. -            j = outer + edge;
  1442. -            for (i = outer; i < j && i < record; ++i)
  1443. -            {
  1444. -                read_char (omf->refNum, num);
  1445. -                putchar (num);
  1446. -            }
  1447. -
  1448. -            puts ("\'");
  1449. -            omf->displacement += i - outer;
  1450. -            omf->counter += i - outer;
  1451. -            outer = i;
  1452. -            if (outer < record)
  1453. -            {
  1454. -                if (!nooffset)
  1455. -                    printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1456. -                printf ("        %s", assembler == merlin ? "asc    \'" : "dc     c\'");
  1457. -            }
  1458. -        }
  1459. -    }
  1460. -}
  1461. -
  1462. -void
  1463. -parse_GLOBAL_type_D (HEADER *omf, LABEL *lab, char *name)
  1464. -{
  1465. -    unsigned char record;
  1466. -    enum assembler tmp_asm;
  1467. -
  1468. -    tmp_asm = assembler;
  1469. -    assembler = orca;
  1470. -    printf ("%-11s", name);
  1471. -    if (strlen (name) >= 11)
  1472. -        putchar (' ');
  1473. -    printf ("dc    d\'");
  1474. -
  1475. -    read_char (omf->refNum, record);
  1476. -    if (!parse_GLOBAL_type (omf, lab, record))
  1477. -    {
  1478. -        unsigned short num_char = 0, edge;
  1479. -        unsigned int tmp;
  1480. -        unsigned char outer = 0;
  1481. -        double num;
  1482. -
  1483. -        edge = DOUBLE_EDGE + (nooffset == TRUE ? 16 : 0);
  1484. -        record /= sizeof (double);
  1485. -        while (outer++ < record)
  1486. -        {
  1487. -            GSOSread (omf->refNum, &num, sizeof (double));
  1488. -            printf ("%g%n", num, &tmp);
  1489. -            num_char += tmp;
  1490. -
  1491. -            omf->displacement += sizeof (double);
  1492. -            omf->counter += sizeof (double);
  1493. -            if (num_char > edge)
  1494. -            {
  1495. -                puts ("\'");
  1496. -                num_char = 0;
  1497. -                if (outer < record)
  1498. -                {
  1499. -                    if (!nooffset)
  1500. -                        printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1501. -                    printf ("        dc       d\'");
  1502. -                }
  1503. -            }
  1504. -            else
  1505. -                if (outer < record)
  1506. -                    putchar (',');
  1507. -        }
  1508. -        if (num_char)
  1509. -            puts ("\'");
  1510. -    }
  1511. -
  1512. -    assembler = tmp_asm;
  1513. -}
  1514. -
  1515. -void
  1516. -parse_GLOBAL_type_F (HEADER *omf, LABEL *lab, char *name)
  1517. -{
  1518. -    unsigned char record;
  1519. -    enum assembler tmp_asm;
  1520. -
  1521. -    tmp_asm = assembler;
  1522. -    assembler = orca;
  1523. -    printf ("%-11s", name);
  1524. -    if (strlen (name) >= 11)
  1525. -        putchar (' ');
  1526. -    printf ("dc    f\'");
  1527. -
  1528. -    read_char (omf->refNum, record);
  1529. -    if (!parse_GLOBAL_type (omf, lab, record))
  1530. -    {
  1531. -        unsigned short num_char = 0, edge;
  1532. -        unsigned int tmp;
  1533. -        unsigned char outer = 0;
  1534. -        float num;
  1535. -
  1536. -        edge = FLOAT_EDGE + (nooffset == TRUE ? 16 : 0);
  1537. -        record /= sizeof (float);
  1538. -        while (outer++ < record)
  1539. -        {
  1540. -            GSOSread (omf->refNum, &num, sizeof (float));
  1541. -            printf ("%g%n", num, &tmp);
  1542. -            num_char += tmp;
  1543. -
  1544. -            omf->displacement += sizeof (float);
  1545. -            omf->counter += sizeof (float);
  1546. -            if (num_char > edge)
  1547. -            {
  1548. -                puts ("\'");
  1549. -                num_char = 0;
  1550. -                if (outer < record)
  1551. -                {
  1552. -                    if (!nooffset)
  1553. -                        printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1554. -                    printf ("        dc       f\'");
  1555. -                }
  1556. -            }
  1557. -            else
  1558. -                if (outer < record)
  1559. -                    putchar (',');
  1560. -        }
  1561. -        if (num_char)
  1562. -            puts ("\'");
  1563. -    }
  1564. -
  1565. -    assembler = tmp_asm;
  1566. -}
  1567. -
  1568. -void
  1569. -parse_GLOBAL_type_H (HEADER *omf, LABEL *lab, char *name)
  1570. -{
  1571. -    unsigned char record;
  1572. -
  1573. -    printf ("%-11s", name);
  1574. -    if (strlen (name) >= 11)
  1575. -        putchar (' ');
  1576. -    printf ("%s", assembler == merlin ? "hex    " : "dc    h\'");
  1577. -
  1578. -    read_char (omf->refNum, record);
  1579. -    if (!parse_GLOBAL_type (omf, lab, record))
  1580. -    {
  1581. -        unsigned char i, j, num, outer = 0;
  1582. -        unsigned short edge;
  1583. -
  1584. -        edge = HEX_EDGE + (nooffset == TRUE ? 16 : 0);
  1585. -        while (outer < record)
  1586. -        {
  1587. -            j = outer + edge;
  1588. -            for (i = outer; i < j && i < record; ++i)
  1589. -            {
  1590. -                read_char (omf->refNum, num);
  1591. -                printf ("%0.2x", (unsigned short)num);
  1592. -            }
  1593. -
  1594. -            puts (assembler == merlin ? "" : "\'");
  1595. -            omf->displacement += i - outer;
  1596. -            omf->counter += i - outer;
  1597. -            outer = i;
  1598. -            if (outer < record)
  1599. -            {
  1600. -                if (!nooffset)
  1601. -                    printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1602. -                printf ("        %s", assembler == merlin ? "hex    " : "dc       h\'");
  1603. -            }
  1604. -        }
  1605. -    }
  1606. -}
  1607. -
  1608. -void
  1609. -parse_GLOBAL_type_I (HEADER *omf, LABEL *lab, char *name, unsigned char length)
  1610. -{
  1611. -    unsigned char record;
  1612. -
  1613. -    printf ("%-11s", name);
  1614. -    if (strlen (name) >= 11)
  1615. -        putchar (' ');
  1616. -    printf ("%s", assembler == merlin ? "db     " : "dc    i");
  1617. -    read_char (omf->refNum, record);
  1618. -    if (assembler == orca)
  1619. -        if (record >= 0x01 && record <= 0xdf)
  1620. -            putchar ('\'');
  1621. -        else
  1622. -            printf ("%u\'", (unsigned short)length);
  1623. -
  1624. -    if (!parse_GLOBAL_type (omf, lab, record))
  1625. -    {
  1626. -        unsigned short num_char = 0, edge;
  1627. -        unsigned int tmp;
  1628. -        unsigned char outer = 0;
  1629. -        signed char num;
  1630. -
  1631. -        edge = INT_EDGE + (nooffset == TRUE ? 16 : 0);
  1632. -        while (outer++ < record)
  1633. -        {
  1634. -            read_char (omf->refNum, num);
  1635. -            printf ("%d%n", (short)num, &tmp);
  1636. -            num_char += tmp;
  1637. -
  1638. -            ++omf->displacement;
  1639. -            ++omf->counter;
  1640. -            if (num_char > edge)
  1641. -            {
  1642. -                puts (assembler == merlin ? "" : "\'");
  1643. -                num_char = 0;
  1644. -                if (outer < record)
  1645. -                {
  1646. -                    if (!nooffset)
  1647. -                        printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1648. -                    printf ("        %s", assembler == merlin ? "db     " : "dc       i\'");
  1649. -                }
  1650. -            }
  1651. -            else
  1652. -                if (outer < record)
  1653. -                    putchar (',');
  1654. -        }
  1655. -        if (num_char)
  1656. -            puts (assembler == merlin ? "" : "\'");
  1657. -    }
  1658. -}
  1659. -
  1660. -void
  1661. -parse_GLOBAL_type_K (HEADER *omf, LABEL *lab, char *name)
  1662. -{
  1663. -    unsigned char record;
  1664. -
  1665. -    printf ("%-11s", name);
  1666. -    if (strlen (name) >= 11)
  1667. -        putchar (' ');
  1668. -    read_char (omf->refNum, record);
  1669. -    parse_STRONG (omf, lab, record);
  1670. -}
  1671. -
  1672. -void
  1673. -parse_GLOBAL_type_L (HEADER *omf, LABEL *lab, char *name, unsigned char length)
  1674. -{
  1675. -    unsigned char record;
  1676. -    enum assembler tmp_asm;
  1677. -
  1678. -    printf ("%-11s", name);
  1679. -    if (strlen (name) >= 11)
  1680. -        putchar (' ');
  1681. -    printf ("dc    s");
  1682. -    read_char (omf->refNum, record);
  1683. -    if (record >= 0x01 && record <= 0xdf)
  1684. -        putchar ('\'');
  1685. -    else
  1686. -        printf ("%u\'", (unsigned short)length);
  1687. -
  1688. -    tmp_asm = assembler;
  1689. -    assembler = orca;
  1690. -    parse_GLOBAL_type (omf, lab, record);
  1691. -    assembler == tmp_asm;
  1692. -}
  1693. -
  1694. -void
  1695. -parse_GLOBAL_type_N (HEADER *omf, LABEL *lab, char *name)
  1696. -{
  1697. -    printf ("%-11s", name);
  1698. -    if (strlen (name) >= 11)
  1699. -        putchar (' ');
  1700. -    printf ("%s\n", assembler == merlin ? "equ    *" : "entry");
  1701. -    if (label)
  1702. -    {
  1703. -        char *expr;
  1704. -
  1705. -        expr = malloc (strlen (omf->segname) + (sizeof (long) * 2) + 5);
  1706. -        sprintf (expr, "(%s+$%lx)", omf->segname, omf->counter);
  1707. -        add_label (lab, name, expr, GLOBAL);
  1708. -    }
  1709. -}
  1710. -
  1711. -void
  1712. -parse_GLOBAL_type_S (HEADER *omf, char *name)
  1713. -{
  1714. -    unsigned long num;
  1715. -    unsigned char val;
  1716. -
  1717. -    printf ("%-11s", name);
  1718. -    if (strlen (name) >= 11)
  1719. -        putchar (' ');
  1720. -    read_char (omf->refNum, val);
  1721. -    read_long (omf->refNum, num);
  1722. -    printf ("ds    %lu\n", num);
  1723. -    omf->displacement += num;
  1724. -    omf->counter += num;
  1725. -}
  1726. -
  1727. -unsigned short
  1728. -parse_GLOBAL_type (HEADER *omf, LABEL *lab, unsigned char record)
  1729. -{
  1730. -    unsigned short n;
  1731. -
  1732. -    switch (record)
  1733. -    {
  1734. -        case EXPR:
  1735. -        case BEXPR:
  1736. -        case RELEXPR:
  1737. -        case LEXPR:
  1738. -            n = parse_record (omf, lab, record, FALSE, 0);
  1739. -            if (assembler == orca)
  1740. -                putchar ('\'');
  1741. -            if (assembly && (n > 0))
  1742. -                putchar ('\n');
  1743. -            break;
  1744. -
  1745. -        case DS:
  1746. -            parse_DS (omf, record);
  1747. -            break;
  1748. -
  1749. -        default:
  1750. -            return (FALSE);
  1751. -            break;
  1752. -    }
  1753. -
  1754. -    return (TRUE);
  1755. -}
  1756. -
  1757. -unsigned short
  1758. -parse_GEQU_EQU (HEADER *omf, LABEL *lab, unsigned char record, unsigned short n)
  1759. -{
  1760. -    unsigned char length, type, private;
  1761. -    enum assembler tmp_asm = assembler;
  1762. -    char *name;
  1763. -
  1764. -    read_char (omf->refNum, length);
  1765. -    name = malloc (length + 1);
  1766. -    GSOSread (omf->refNum, name, length);
  1767. -    name[length] = '\0';
  1768. -    read_char (omf->refNum, length);
  1769. -    read_char (omf->refNum, type);
  1770. -    read_char (omf->refNum, private);
  1771. -
  1772. -    if (!assembly)
  1773. -    {
  1774. -        printf ("%s    (%0.2x) | %s\n", record == GEQU ? "GEQU" : "EQU ", (unsigned short)record, name);
  1775. -        if (!nooffset)
  1776. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1777. -        printf ("%15c len: %0.2x, type: %c", '|', (unsigned short)length, type);
  1778. -        if (private)
  1779. -            printf (", private");
  1780. -        putchar ('\n');
  1781. -        parse_expr (omf, lab, n);
  1782. -    }
  1783. -    else
  1784. -    {
  1785. -        printf ("%-11s%s   ", name, record == GLOBAL ? "gequ" : "equ ");
  1786. -        ++omf->displacement;
  1787. -        assembler = merlin;
  1788. -        n = parse_expr (omf, lab, n);
  1789. -        if (n > 0)
  1790. -            putchar ('\n');
  1791. -        assembler = tmp_asm;
  1792. -    }
  1793. -
  1794. -    free (name);
  1795. -    omf->displacement += length + 4;
  1796. -    return (n);
  1797. -}
  1798. -
  1799. -unsigned short
  1800. -parse_MEM (HEADER *omf, LABEL *lab, unsigned char record, unsigned short n)
  1801. -{
  1802. -    unsigned long adr1, adr2;
  1803. -
  1804. -    read_long (omf->refNum, adr1);
  1805. -    read_long (omf->refNum, adr2);
  1806. -
  1807. -    if (!assembly)
  1808. -    {
  1809. -        printf ("MEM      (%0.2x) | reserve: ", (unsigned short)record);
  1810. -        printf ("$%0.2x/%0.4x - ",
  1811. -            (unsigned short)((adr1 & 0xff0000) >> 16),
  1812. -            (unsigned short)(adr1 & 0xffff));
  1813. -        printf ("$%0.2x/%0.4x\n",
  1814. -            (unsigned short)((adr2 & 0xff0000) >> 16),
  1815. -            (unsigned short)(adr2 & 0xffff));
  1816. -        n = parse_expr (omf, lab, n);
  1817. -    }
  1818. -    else
  1819. -        printf ("%14s     $%lx,$%lx\n", "mem", adr1, adr2);
  1820. -
  1821. -    omf->displacement += 8;
  1822. -    return (n);
  1823. -}
  1824. -
  1825. -unsigned char
  1826. -parse_EXPR_BEXPR_LEXPR (HEADER *omf, unsigned char record)
  1827. -{
  1828. -    unsigned char truncate_size;
  1829. -
  1830. -    read_char (omf->refNum, truncate_size);
  1831. -    if (!assembly)
  1832. -    {
  1833. -        switch (record)
  1834. -        {
  1835. -            case EXPR:
  1836. -                printf ("EXPR ");
  1837. -                break;
  1838. -
  1839. -            case BEXPR:
  1840. -                printf ("BEXPR");
  1841. -                break;
  1842. -
  1843. -            case LEXPR:
  1844. -                printf ("LEXPR");
  1845. -                break;
  1846. -        }
  1847. -        printf ("    (%0.2x) | truncate result to %u %s\n",
  1848. -            (unsigned short)record, (unsigned short)truncate_size,
  1849. -            (truncate_size == 1 ? "byte" : "bytes"));
  1850. -    }
  1851. -
  1852. -    ++omf->displacement;
  1853. -    return (truncate_size);
  1854. -}
  1855. -
  1856. -unsigned char
  1857. -parse_RELEXPR (HEADER *omf, unsigned char record)
  1858. -{
  1859. -    unsigned char truncate_size;
  1860. -    long offset;
  1861. -
  1862. -    read_char (omf->refNum, truncate_size);
  1863. -    if (!assembly)
  1864. -        printf ("RELEXPR  (%0.2x) | truncate result to %u %s\n",
  1865. -            (unsigned short)record, (unsigned short)truncate_size,
  1866. -            (truncate_size == 1 ? "byte" : "bytes"));
  1867. -
  1868. -    read_long (omf->refNum, offset);
  1869. -    omf->displacement += 5;
  1870. -    if (!assembly)
  1871. -    {
  1872. -        if (!nooffset)
  1873. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  1874. -        printf ("%15c offset: $%0.8x\n", '|', offset);
  1875. -    }
  1876. -
  1877. -    return (truncate_size);
  1878. -}
  1879. -
  1880. -void
  1881. -parse_DS (HEADER *omf, unsigned char record)
  1882. -{
  1883. -    unsigned long num_zeros;
  1884. -
  1885. -    read_long (omf->refNum, num_zeros);
  1886. -    if (!assembly)
  1887. -        printf ("DS      (%0.2x) | insert %lu %s\n",
  1888. -            (unsigned short)record, num_zeros,
  1889. -            (num_zeros > 1 ? "zeros" : "zero"));
  1890. -    else
  1891. -        printf ("ds    %lu\n", num_zeros);
  1892. -
  1893. -    omf->displacement += 5;
  1894. -    omf->counter += num_zeros;
  1895. -}
  1896. -
  1897. -unsigned short
  1898. -parse_expr (HEADER *omf, LABEL *lab, unsigned short n)
  1899. -{
  1900. -    LIST list = { 0, NULL, NULL };
  1901. -    unsigned char expr;
  1902. -    unsigned long num;
  1903. -
  1904. -    do
  1905. -    {
  1906. -        read_char (omf->refNum, expr);
  1907. -        ++omf->displacement;
  1908. -
  1909. -        switch (expr)
  1910. -        {
  1911. -            case LABEL_WEAK:
  1912. -                parse_expr_weak_reference (omf, &list);
  1913. -                break;
  1914. -
  1915. -            case LABEL_VALUE:
  1916. -                parse_expr_label_value (omf, &list);
  1917. -                break;
  1918. -
  1919. -            case RELATIVE_OFFSET:
  1920. -                num = parse_expr_relative_offset (omf, &list);
  1921. -                break;
  1922. -
  1923. -            case CONSTANT_OPERAND:
  1924. -                num = parse_expr_constant_operand (omf, &list);
  1925. -                break;
  1926. -
  1927. -            case ADD:
  1928. -            case SUB:
  1929. -            case MUL:
  1930. -            case DIV:
  1931. -            case MOD:
  1932. -            case NEGATION:
  1933. -            case BIT_SHIFT:
  1934. -            case AND:
  1935. -            case OR:
  1936. -            case EOR:
  1937. -            case NOT:
  1938. -            case LESS_EQUAL:
  1939. -            case GREATER_EQUAL:
  1940. -            case NOT_EQUAL:
  1941. -            case LESS:
  1942. -            case GREATER:
  1943. -            case EQUAL:
  1944. -            case LOGICAL_AND:
  1945. -            case INCLUSIVE_OR:
  1946. -            case EXCLUSIVE_OR:
  1947. -            case COMPLEMENT:
  1948. -                push (&list, NULL, expr);
  1949. -                break;
  1950. -        }
  1951. -    } while (expr != END);
  1952. -
  1953. -    if (infix)
  1954. -        n = print_stack_infix (omf, &list, lab, n);
  1955. -    else
  1956. -        n = print_stack_postfix (omf, list.stack, lab, n);
  1957. -    delete_stack (list.stack);
  1958. -    return (n);
  1959. -}
  1960. -
  1961. -void
  1962. -parse_expr_weak_reference (HEADER *omf, LIST *list)
  1963. -{
  1964. -    char *ptr;
  1965. -    unsigned char num;
  1966. -
  1967. -    read_char (omf->refNum, num);
  1968. -    omf->displacement += num;
  1969. -    ptr = malloc (num + 1);
  1970. -    GSOSread (omf->refNum, ptr, num);
  1971. -    ptr[num] = '\0';
  1972. -
  1973. -    if (assembly)
  1974. -        push (list, ptr, 0);
  1975. -    else
  1976. -    {
  1977. -        char *str;
  1978. -
  1979. -        str = malloc (strlen (ptr) + 8);
  1980. -        strcpy (str, "weak (");
  1981. -        strcat (str, ptr);
  1982. -        strcat (str, ")");
  1983. -        push (list, str, 0);
  1984. -        free (str);
  1985. -    }
  1986. -
  1987. -    free (ptr);
  1988. -}
  1989. -
  1990. -void
  1991. -parse_expr_label_value (HEADER *omf, LIST *list)
  1992. -{
  1993. -    char *ptr;
  1994. -    unsigned char num;
  1995. -
  1996. -    read_char (omf->refNum, num);
  1997. -    omf->displacement += num;
  1998. -    ptr = malloc (num + 1);
  1999. -    GSOSread (omf->refNum, ptr, num);
  2000. -    ptr[num] = '\0';
  2001. -    push (list, ptr, 0);
  2002. -    free (ptr);
  2003. -}
  2004. -
  2005. -unsigned long
  2006. -parse_expr_relative_offset (HEADER *omf, LIST *list)
  2007. -{
  2008. -    unsigned long num;
  2009. -    char *str;
  2010. -
  2011. -    str = malloc (strlen (omf->segname) + (sizeof (long) * 2) + 5);
  2012. -    read_long (omf->refNum, num);
  2013. -    sprintf (str, "(%s+$%lx)", omf->segname, num);
  2014. -    push (list, str, 0);
  2015. -    free (str);
  2016. -    omf->displacement += omf->numlen;
  2017. -    return (num);
  2018. -}
  2019. -
  2020. -unsigned long
  2021. -parse_expr_constant_operand (HEADER *omf, LIST *list)
  2022. -{
  2023. -    unsigned long num;
  2024. -    char str[10];
  2025. -
  2026. -    read_long (omf->refNum, num);
  2027. -    sprintf (str, "$%lx", num);
  2028. -    push (list, str, 0);
  2029. -    omf->displacement += omf->numlen;
  2030. -    return (num);
  2031. -}
  2032. -
  2033. -/*
  2034. -    stack routines
  2035. - */
  2036. -
  2037. -void
  2038. -push (LIST *list, char *str, unsigned char oper)
  2039. -{
  2040. -    STACK *s;
  2041. -
  2042. -    s = malloc (sizeof (STACK));
  2043. -    if (str)
  2044. -    {
  2045. -        s->str = malloc (strlen (str) + 1);
  2046. -        s->oper = 0;
  2047. -        strcpy (s->str, str);
  2048. -    }
  2049. -    else
  2050. -    {
  2051. -        s->str = NULL;
  2052. -        s->oper = oper;
  2053. -    }
  2054. -    s->next = NULL;
  2055. -
  2056. -    if (list->last)
  2057. -    {
  2058. -        list->last->next = s;
  2059. -        ++list->size;
  2060. -    }
  2061. -    else
  2062. -        list->stack = s;
  2063. -    list->last = s;
  2064. -}
  2065. -
  2066. -void
  2067. -delete_stack (STACK *s)
  2068. -{
  2069. -    while (s)
  2070. -    {
  2071. -        STACK *tmp_s;
  2072. -
  2073. -        tmp_s = s->next;
  2074. -        free (s->str);
  2075. -        free (s);
  2076. -        s = tmp_s;
  2077. -    }
  2078. -}
  2079. -
  2080. -void
  2081. -add_label (LABEL *lab, char *name, char *expr, unsigned char type)
  2082. -{
  2083. -    LABEL *l;
  2084. -
  2085. -    while (lab->next)
  2086. -        lab = lab->next;
  2087. -
  2088. -    l = malloc (sizeof (LABEL));
  2089. -    l->label = name;
  2090. -    l->expr = expr;
  2091. -    l->type = type;
  2092. -    l->next = NULL;
  2093. -    l->prev = lab;
  2094. -    lab->next = l;
  2095. -}
  2096. -
  2097. -void
  2098. -delete_labels (LABEL *lab, unsigned short type)
  2099. -{
  2100. -    while (lab = lab->next)
  2101. -        if (lab->type == type)
  2102. -        {
  2103. -            lab->next->prev = lab->prev;
  2104. -            lab->prev->next = lab->next;
  2105. -            free (lab->label);
  2106. -            free (lab->expr);
  2107. -            free (lab);
  2108. -        }
  2109. -}
  2110. -
  2111. -char *
  2112. -match_label (LABEL *lab, char *expr)
  2113. -{
  2114. -    while (lab = lab->next)
  2115. -        if (!strcmp (lab->expr, expr))
  2116. -            return (lab->label);
  2117. -
  2118. -    return (NULL);
  2119. -}
  2120. -
  2121. -unsigned short
  2122. -print_stack_postfix (HEADER *omf, STACK *stack, LABEL *lab, unsigned short n)
  2123. -{
  2124. -    unsigned short edge;
  2125. -
  2126. -    edge = POSTFIX_EDGE + (nooffset == TRUE ? 16 : 0);
  2127. -    if (!assembly)
  2128. -    {
  2129. -        if (!nooffset)
  2130. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  2131. -        printf ("%15c ", '|');
  2132. -    }
  2133. -
  2134. -    while (stack)
  2135. -    {
  2136. -        do
  2137. -        {
  2138. -            char *expr;
  2139. -
  2140. -            if (stack->str)
  2141. -            {
  2142. -                if (!(label && (expr = match_label (lab, stack->str))))
  2143. -                    expr = stack->str;
  2144. -            }
  2145. -            else
  2146. -                expr = find_operator (stack->oper);
  2147. -
  2148. -            n += strlen (expr);
  2149. -            printf ("%s", expr);
  2150. -
  2151. -            if ((stack = stack->next) && !(n > edge && assembly))
  2152. -            {
  2153. -                putchar (' ');
  2154. -                ++n;
  2155. -            }
  2156. -        } while (stack && (n <= edge));
  2157. -
  2158. -        if (stack && (n > edge))
  2159. -        {
  2160. -            putchar ('\n');
  2161. -            if (!nooffset)
  2162. -                printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  2163. -            if (assembly)
  2164. -                printf ("%20c", ' ');
  2165. -            else
  2166. -                printf ("%15c ", '|');
  2167. -            n = 0;
  2168. -        }
  2169. -    }
  2170. -
  2171. -    if (!assembly)
  2172. -        putchar ('\n');
  2173. -    return (n);
  2174. -}
  2175. -
  2176. -unsigned short
  2177. -print_stack_infix (HEADER *omf, LIST *list, LABEL *lab, unsigned short n)
  2178. -{
  2179. -    BTREE **t;
  2180. -    STACK *stack;
  2181. -    unsigned short size = 0;
  2182. -
  2183. -    t = malloc (sizeof (BTREE *) * list->size);
  2184. -    stack = list->stack;
  2185. -    while (stack)
  2186. -    {
  2187. -        BTREE *tmp;
  2188. -
  2189. -        tmp = malloc (sizeof (BTREE));
  2190. -        tmp->str = stack->str;
  2191. -        tmp->oper = stack->oper;
  2192. -        if (!stack->str)
  2193. -        {
  2194. -            tmp->right = t[--size];
  2195. -            tmp->left = t[--size];
  2196. -        }
  2197. -        else
  2198. -        {
  2199. -            tmp->right = NULL;
  2200. -            tmp->left = NULL;
  2201. -        }
  2202. -
  2203. -        t[size++] = tmp;
  2204. -        stack = stack->next;
  2205. -    }
  2206. -
  2207. -    if (!assembly)
  2208. -    {
  2209. -        if (!nooffset)
  2210. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  2211. -        printf ("%15c ", '|');
  2212. -    }
  2213. -
  2214. -    n = print_inorder (omf, t[0], lab, n, operator[t[0]->oper - 1].prec + 1);
  2215. -    if (n > 0 && !assembly)
  2216. -        putchar ('\n');
  2217. -
  2218. -    delete_btree (t[0]);
  2219. -    free (t);
  2220. -    return (n);
  2221. -}
  2222. -
  2223. -unsigned short
  2224. -newline (HEADER *omf, unsigned short n)
  2225. -{
  2226. -    unsigned short edge;
  2227. -
  2228. -    edge = INFIX_EDGE + (nooffset == TRUE ? 16 : 0);
  2229. -    if (n > edge)
  2230. -    {
  2231. -        n = 0;
  2232. -        putchar ('\n');
  2233. -
  2234. -        if (!nooffset)
  2235. -            printf ("%0.6lx %0.6lx | ", omf->displacement, omf->counter);
  2236. -        if (assembly)
  2237. -            printf ("%20c", ' ');
  2238. -        else
  2239. -            printf ("%15c ", '|');
  2240. -    }
  2241. -
  2242. -        return (n);
  2243. -}
  2244. -
  2245. -unsigned short
  2246. -print_inorder (HEADER *omf, BTREE *t, LABEL *lab, unsigned short n, unsigned short prec)
  2247. -{
  2248. -    unsigned char oper;
  2249. -    char *oper_str;
  2250. -
  2251. -    if (t != NULL)
  2252. -    {
  2253. -        if (t->str == NULL)
  2254. -        {
  2255. -            oper = t->oper;
  2256. -            if ((operator[oper - 1].prec > prec) || ((operator[oper - 1].prec == prec) && (operator[oper - 1].assoc == LEFT)))
  2257. -            {
  2258. -                putchar ('(');
  2259. -                ++n;
  2260. -            }
  2261. -            n = print_inorder (omf, t->left, lab, n, operator[oper - 1].prec);
  2262. -            oper_str = find_operator (oper);
  2263. -            n += 2 + strlen (oper_str);
  2264. -            n = newline (omf, n);
  2265. -            printf (" %s ", oper_str);
  2266. -            if (n == 0)
  2267. -                n = strlen (oper_str);
  2268. -            n = print_inorder (omf, t->right, lab, n, operator[oper - 1].prec);
  2269. -            if ((operator[oper - 1].prec > prec) || ((operator[oper - 1].prec == prec) && (operator[oper - 1].assoc == LEFT)))
  2270. -            {
  2271. -                putchar (')');
  2272. -                ++n;
  2273. -            }
  2274. -        }
  2275. -        else
  2276. -        {
  2277. -            char *expr;
  2278. -
  2279. -            if (!(label && (expr = match_label (lab, t->str))))
  2280. -                expr = t->str;
  2281. -            n += strlen (expr);
  2282. -            n = newline (omf, n);
  2283. -            printf ("%s", expr);
  2284. -            if (n == 0)
  2285. -                n = strlen (expr);
  2286. -        }
  2287. -    }
  2288. -
  2289. -    return (n);
  2290. -}
  2291. -
  2292. -char *
  2293. -find_operator (unsigned char operator)
  2294. -{
  2295. -    switch (operator)
  2296. -    {
  2297. -        case ADD:
  2298. -            return ("+");
  2299. -            break;
  2300. -
  2301. -        case SUB:
  2302. -            return ("-");
  2303. -            break;
  2304. -
  2305. -        case MUL:
  2306. -            return ("*");
  2307. -            break;
  2308. -
  2309. -        case DIV:
  2310. -            return ("/");
  2311. -            break;
  2312. -
  2313. -        case MOD:
  2314. -            return ("%%");
  2315. -            break;
  2316. -
  2317. -        case NEGATION:
  2318. -            return ("~");
  2319. -            break;
  2320. -
  2321. -        case BIT_SHIFT:
  2322. -            return ("<<");
  2323. -            break;
  2324. -
  2325. -        case AND:
  2326. -            return ("&&");
  2327. -            break;
  2328. -
  2329. -        case OR:
  2330. -            return ("||");
  2331. -            break;
  2332. -
  2333. -        case EOR:
  2334. -            return (".eor.");
  2335. -            break;
  2336. -
  2337. -        case NOT:
  2338. -            return ("!");
  2339. -            break;
  2340. -
  2341. -        case LESS_EQUAL:
  2342. -            return ("<=");
  2343. -            break;
  2344. -
  2345. -        case GREATER_EQUAL:
  2346. -            return (">=");
  2347. -            break;
  2348. -
  2349. -        case NOT_EQUAL:
  2350. -            return ("<>");
  2351. -            break;
  2352. -
  2353. -        case LESS:
  2354. -            return ("<");
  2355. -            break;
  2356. -
  2357. -        case GREATER:
  2358. -            return (">");
  2359. -            break;
  2360. -
  2361. -        case EQUAL:
  2362. -            return ("=");
  2363. -            break;
  2364. -
  2365. -        case LOGICAL_AND:
  2366. -            return ("&");
  2367. -            break;
  2368. -
  2369. -        case INCLUSIVE_OR:
  2370. -            return ("|");
  2371. -            break;
  2372. -
  2373. -        case EXCLUSIVE_OR:
  2374. -            return (".beor.");
  2375. -            break;
  2376. -
  2377. -        case COMPLEMENT:
  2378. -            return (".bnot.");
  2379. -            break;
  2380. -    }
  2381. -}
  2382. -
  2383. -void
  2384. -delete_btree (BTREE *t)
  2385. -{
  2386. -    if (t != NULL)
  2387. -    {
  2388. -        delete_btree (t->left);
  2389. -        delete_btree (t->right);
  2390. -        free (t);
  2391. -    }
  2392. -}
  2393. -
  2394. -int
  2395. -decode_switches (int argc, char **argv)
  2396. -{
  2397. -    int c, longind;
  2398. -
  2399. -    while ((c = getopt_long (argc, argv, "vDdTxltpmoaisnfh", long_options, &longind)) != EOF)
  2400. -    {
  2401. -        if (c == 0)
  2402. -            c = long_options[longind].val;
  2403. -
  2404. -        switch (c)
  2405. -        {
  2406. -            case 'D':
  2407. -                read_default (argv[0]);
  2408. -                break;
  2409. -
  2410. -            default:
  2411. -                set_option (c, argv[0]);
  2412. -                break;
  2413. -        }
  2414. -    }
  2415. -
  2416. -    return (optind);
  2417. -}
  2418. -
  2419. -void
  2420. -read_default (char *progname)
  2421. -{
  2422. -    Handle name;
  2423. -    Longword size;
  2424. -
  2425. -    name = LoadResource (rText, (Longword)DEFAULT);
  2426. -    size = GetResourceSize (rText, (Longword)DEFAULT);
  2427. -    HLock (name);
  2428. -    while (size)
  2429. -    {
  2430. -        int opt;
  2431. -
  2432. -        opt = get_option (*name);
  2433. -        if (opt != ERROR)
  2434. -            set_option (opt, progname);
  2435. -        size -= strlen (*name) + 1;
  2436. -        *name += strlen (*name) + 1;
  2437. -    }
  2438. -    HUnlock (name);
  2439. -}
  2440. -
  2441. -int
  2442. -get_option (char *arg)
  2443. -{
  2444. -    int i = 0;
  2445. -
  2446. -    while (long_options[i].val)
  2447. -    {
  2448. -        if ((*arg == '-') && (long_options[i].val == *(arg + 1)))
  2449. -                return (long_options[i].val);
  2450. -        else
  2451. -            if (!strcmp (long_options[i].name, arg + 1))
  2452. -                return (long_options[i].val);
  2453. -        ++i;
  2454. -    }
  2455. -
  2456. -    return (ERROR);
  2457. -}
  2458. -
  2459. -void
  2460. -set_option (int opt, char *progname)
  2461. -{
  2462. -    Handle h;
  2463. -
  2464. -    switch (opt)
  2465. -    {
  2466. -        case 'v':
  2467. -            h = LoadResource (rText, VERSION);
  2468. -            fprintf (stderr, *h, progname);
  2469. -            break;
  2470. -
  2471. -        case 'd':
  2472. -            assembly = TRUE;
  2473. -            assembler = merlin;
  2474. -            infix = TRUE;
  2475. -            label = TRUE;
  2476. -            break;
  2477. -
  2478. -        case 'T':
  2479. -            tool = TRUE;
  2480. -            break;
  2481. -
  2482. -        case 'x':
  2483. -            hex = TRUE;
  2484. -            break;
  2485. -
  2486. -        case 'l':
  2487. -            label = TRUE;
  2488. -            break;
  2489. -
  2490. -        case 't':
  2491. -            infix = TRUE;
  2492. -            postfix = FALSE;
  2493. -            break;
  2494. -
  2495. -        case 'p':
  2496. -            postfix = TRUE;
  2497. -            infix = FALSE;
  2498. -            break;
  2499. -
  2500. -        case 'm':
  2501. -            assembler = merlin;
  2502. -            assembly = TRUE;
  2503. -            infix = TRUE;
  2504. -            label = TRUE;
  2505. -            break;
  2506. -
  2507. -        case 'o':
  2508. -            assembler = orca;
  2509. -            assembly = TRUE;
  2510. -            infix = TRUE;
  2511. -            label = TRUE;
  2512. -            break;
  2513. -
  2514. -        case 'a':
  2515. -            shorta = TRUE;
  2516. -            break;
  2517. -
  2518. -        case 'i':
  2519. -            shorti = TRUE;
  2520. -            break;
  2521. -
  2522. -        case 's':
  2523. -            header = TRUE;
  2524. -            break;
  2525. -
  2526. -        case 'n':
  2527. -            noheader = TRUE;
  2528. -            break;
  2529. -
  2530. -        case 'f':
  2531. -            nooffset = TRUE;
  2532. -            break;
  2533. -
  2534. -        case 'h':
  2535. -            usage_verbose (progname);
  2536. -            break;
  2537. -
  2538. -        default:
  2539. -            usage (progname);
  2540. -            break;
  2541. -    }
  2542. -}
  2543. -
  2544. -void
  2545. -usage (char *progname)
  2546. -{
  2547. -    Handle h;
  2548. -
  2549. -    h = LoadResource (rText, (Longword)USAGE);
  2550. -    fprintf (stderr, *h, progname);
  2551. -
  2552. -    ResourceShutDown ();
  2553. -    MMShutDown (userID);
  2554. -    exit (1);
  2555. -}
  2556. -
  2557. -void
  2558. -usage_verbose (char *progname)
  2559. -{
  2560. -    Handle h;
  2561. -
  2562. -    h = LoadResource (rText, (Longword)USAGE_VERBOSE);
  2563. -    fprintf (stderr, *h, progname, progname);
  2564. -
  2565. -    ResourceShutDown ();
  2566. -    MMShutDown (userID);
  2567. -    exit (0);
  2568. -}
  2569. -
  2570. -void
  2571. -GSOSset_mark (Word refNum, Longword displacement)
  2572. -{
  2573. -    SetPositionRecGS info = { 3 };
  2574. -
  2575. -    info.refNum = refNum;
  2576. -    info.base = startPlus;
  2577. -    info.displacement = displacement;
  2578. -    SetMark (&info);
  2579. -}
  2580. -
  2581. -Longword
  2582. -GSOSget_mark (Word refNum)
  2583. -{
  2584. -    PositionRecGS info = { 2 };
  2585. -
  2586. -    info.refNum = refNum;
  2587. -    GetMark (&info);
  2588. -    return (info.position);
  2589. -}
  2590. -
  2591. -Longword
  2592. -GSOSread (Word refNum, void *dataBuffer, Longword requestCount)
  2593. -{
  2594. -    IORecGS info = { 5 };
  2595. -
  2596. -    info.refNum = refNum;
  2597. -    info.dataBuffer = (char *)dataBuffer;
  2598. -    info.requestCount = requestCount;
  2599. -    info.cachePriority = cacheOff;
  2600. -    Read (&info);
  2601. -
  2602. -    return (info.transferCount);
  2603. -}
  2604. -
  2605. -Word
  2606. -GSOSopen (char *filename)
  2607. -{
  2608. -    OpenRecGS info = { 12 };
  2609. -    GSString255 name;
  2610. -
  2611. -    info.optionList = NULL;
  2612. -    name.length = strlen (filename);
  2613. -    strcpy (name.text, filename);
  2614. -    info.pathname = &name;
  2615. -    info.requestAccess = readEnable;
  2616. -    info.resourceNumber = 0;
  2617. -    Open (&info);
  2618. -
  2619. -    return (info.refNum);
  2620. -}
  2621. -
  2622. -void
  2623. -GSOSclose (Word refNum)
  2624. -{
  2625. -    IORecGS info = { 1 };
  2626. -
  2627. -    info.refNum = refNum;
  2628. -    Close (&info);
  2629. -}
  2630. -
  2631. -Longword
  2632. -GSOSget_eof (Word refNum)
  2633. -{
  2634. -    EOFRecGS info = { 2 };
  2635. -
  2636. -    info.refNum = refNum;
  2637. -    GetEOF (&info);
  2638. -    return (info.eof);
  2639. -}
  2640. -
  2641. -HEADER *
  2642. -init_globals (void)
  2643. -{
  2644. -    HEADER *omf;
  2645. -
  2646. -    version = FALSE;
  2647. -    tool = FALSE;
  2648. -    assembly = FALSE;
  2649. -    label = FALSE;
  2650. -    infix = FALSE;
  2651. -    postfix = TRUE;
  2652. -    hex = FALSE;
  2653. -    header = FALSE;
  2654. -    noheader = FALSE;
  2655. -    nooffset = FALSE;
  2656. -    help = FALSE;
  2657. -    shorta = FALSE;
  2658. -    shorti = FALSE;
  2659. -
  2660. -    omf = malloc (sizeof (HEADER));
  2661. -    omf->offset = 0;
  2662. -    return (omf);
  2663. -}
  2664. -
  2665. -int
  2666. -main (int argc, char **argv)
  2667. -{
  2668. -    HEADER *omf;
  2669. -    LABEL lab = { NULL, NULL, 0, NULL, NULL };
  2670. -    int i, names;
  2671. -    LongWord file_len;
  2672. -    GSString255 *prog;
  2673. -
  2674. -    userID = MMStartUp ();
  2675. -    prog = (GSString255 *)LGetPathname2 (userID, (Word)1);
  2676. -    ResourceStartUp (userID);
  2677. -    OpenResourceFile (readEnable, NULL, prog);
  2678. -    omf = init_globals ();
  2679. -    i = decode_switches (argc, argv);
  2680. -
  2681. -    omf->refNum = GSOSopen (argv[i]);
  2682. -    if (toolerror ())
  2683. -    {
  2684. -        if (i == argc)
  2685. -            puts ("object filename not specified");
  2686. -        else
  2687. -            perror (argv[0]);
  2688. -        usage (argv[0]);
  2689. -    }
  2690. -
  2691. -    file_len = GSOSget_eof (omf->refNum);
  2692. -    names = (++i < argc ? TRUE : FALSE);
  2693. -
  2694. -    do
  2695. -    {
  2696. -        GSOSset_mark (omf->refNum, omf->offset);
  2697. -        if (toolerror () || (names && (i == argc)))
  2698. -            break;
  2699. -
  2700. -        read_header (omf);
  2701. -        omf->displacement = omf->offset + omf->dispdata;
  2702. -        omf->counter = 0;
  2703. -
  2704. -        if (names)
  2705. -        {
  2706. -            char j, flag = FALSE;
  2707. -
  2708. -            for (j = i; j < argc; ++j)
  2709. -                if (!strncmp (omf->loadname, argv[j], (int)strlen (argv[j])) ||
  2710. -                    !strncmp (omf->segname, argv[j], (int)strlen (argv[j])))
  2711. -                {
  2712. -                    flag = TRUE;
  2713. -                    break;
  2714. -                }
  2715. -
  2716. -            if (flag)
  2717. -            {
  2718. -                if (!noheader)
  2719. -                    print_header (omf);
  2720. -                if (!header)
  2721. -                    if (hex && !assembly)
  2722. -                        parse_segment_hex (omf);
  2723. -                    else
  2724. -                        parse_segment (omf, &lab);
  2725. -
  2726. -                if (j != i)
  2727. -                    argv[j] = argv[i];
  2728. -                ++i;
  2729. -            }
  2730. -        }
  2731. -        else
  2732. -        {
  2733. -            if (!noheader)
  2734. -                print_header (omf);
  2735. -            if (!header)
  2736. -                if (hex && !assembly)
  2737. -                    parse_segment_hex (omf);
  2738. -                else
  2739. -                    parse_segment (omf, &lab);
  2740. -        }
  2741. -
  2742. -        free (omf->segname);
  2743. -        if (omf->version == 1)
  2744. -            omf->offset += (omf->bytecnt * 512);
  2745. -        else
  2746. -            omf->offset += omf->bytecnt;
  2747. -    } while (file_len > omf->offset);
  2748. -
  2749. -    delete_labels (&lab, GLOBAL);
  2750. -    bye (omf);
  2751. -}
  2752. + END OF ARCHIVE
  2753.