From:	CSBVAX::CSBVAX::MRGATE::"SMTP::VAXMFG.TECH.NWU.EDU::CHOJNACKI"  2-MAR-1989 21:58
To:	MRGATE::"ARISIA::EVERHART"
Subj:	March 2 UNMACRO source 5/8


Received: from vaxmfg.tech.nwu.edu by accuvax.nwu.edu id ab12379;
          2 Mar 89 11:38 CST
Date: Thu, 2 Mar 89 11:51 CST
From: Bob Chojnacki <CHOJNACKI@vaxmfg.tech.nwu.edu>
Subject: March 2 UNMACRO source 5/8
To: EVERHART%ARISIA.decnet@ge-crd.arpa
X-VMS-To: IN%"EVERHART%ARISIA.decnet@ge-crd.arpa"
Message-ID:  <8903021138.ab12379@accuvax.nwu.edu>

+-+-+-+ Beginning of part 5 +-+-+-+
X  "RMS$READ",
X  "RMS$RELEASE",
X  "RMS$UPDATE",
X  "RMS$WAIT",
X  "RMS$WRITE",
X  "RMS$CLOSE",
X  "RMS$CONNECT",
X  "RMS$CREATE",
X  "RMS$DISCONNECT",
X  "RMS$DISPLAY",
X  "RMS$ERASE",
X  "RMS$EXTEND",
X  "RMS$FLUSH",
X  "RMS$MODIFY",
X  "RMS$NXTVOL",`009`009`009/* 80 */
X  "RMS$OPEN",
X  "RMS$REWIND",
X  "RMS$SPACE",
X  "RMS$TRUNCATE",
X  "RMS$ENTER",
X  "RMS$PARSE",
X  "RMS$REMOVE",
X  "RMS$RENAME",
X  "RMS$SEARCH",
X  "RMS$SETDDIR",
X  "RMS$SETDFPROT",
X  "RMS$SSVEXC",
X  "RMS$RMSRUNDWN",
X  "RMS$SPARE_VECTOR_1",
X  "RMS$FILESCAN",`009`009/* 8F */
X  "SYS$ENQ",`009`009`009/* F8 */
X  "SYS$DEQ",
X  "SYS$ENQW",
X  "SYS$ENQW_2",
X  "SYS$ENQW_3",
X  "SYS$SETSSF",
X  "SYS$SETSTK",
X  "SYS$GETSYI",
X  "SYS$IMGFIX",`009`009`009/* 100 */
X  "SYS$IMGFIX_2",
X  "SYS$GETDVI",
X  "SYS$GETDVIW",
X  "SYS$GETJPI",
X  "SYS$GETJPIW",
X  "SYS$GETSYIW",
X  "SYS$SNDJBCW",
X  "SYS$SYNCH",`009`009`009/* 108 */
X  "SYS$ERAPAT",`009`009`009/* 10E */
X  "SYS$CRELNT",
X  "SYS$CRELNM",`009`009`009/* 110 */
X  "SYS$DELLNM",
X  "SYS$TRNLNM",
X  "SYS$GETKLI",
X  "SYS$GETLKIW",
X  "SYS$GETLKIW_2",
X  "SYS$ASCTOID",
X  "SYS$FINISH_RDB",
X  "SYS$IDTOASC",
X  "SYS$BRKTHRU",
X  "SYS$GRANTID",
X  "SYS$REVOKID",
X  "SYS$CHKPRO",
X  "SYS$BRKTHRUW",
X  "SYS$BRKTHRUW_2",
X  "SYS$GETQUI",
X  "SYS$GETQUIW",`009`009/* 120 */
X  "SYS$GETQUIW_2",
X  "SYS$SS_VECTOR_SPARE",
X  "SYS$START_RU",
X  "SYS$PREPARE_RU",
X  "SYS$COMMIT_RU",
X  "SYS$ABORT_RU",
X  "SYS$DCLRUH",
X  "SYS$CANRUH",
X  "SYS$JOIN_RU",
X  "SYS$UNJOIN_RU",
X  "SYS$RUNDOWN_RU",
X  "SYS$GET_RUID",
X  "SYS$END_RU",
X  "SYS$END_RU2",
X  "SYS$MTACCESS",
X  "SYS$GETLUI",
X  "SYS$GRANT_LICENCE",
X  "SYS$RELEASE_LICENCE",
X  "SYS$SIGPRC",
X  "SYS$RESCHED",
X  "SYS$GETSECI",
X  "SYS$LOOKUP_LICENCE"
X  `125;
X/*
X  symbol values
X*/
Xint sym_value[MAXSYM] = `123
X  0x7ffede00,`009`009`009/* 0 */
X  0x7ffede08,
X  0x7ffede10,
X  0x7ffede18,
X  0x7ffede20,
X  0x7ffede28,
X  0x7ffede30,
X  0x7ffede38,
X  0x7ffede40,
X  0x7ffede48,
X  0x7ffede50,
X  0x7ffede58,
X  0x7ffede60,
X  0x7ffede68,
X  0x7ffede70,
X  0x7ffede78,
X  0x7ffede80,`009`009`009/* 10 */
X  0x7ffede88,
X  0x7ffede90,
X  0x7ffede98,
X  0x7ffedea0,
X  0x7ffedea8,
X  0x7ffedeb0,
X  0x7ffedeb8,
X  0x7ffedec0,
X  0x7ffedec8,
X  0x7ffeded0,
X  0x7ffeded8,
X  0x7ffedee0,
X  0x7ffedee8,
X  0x7ffedef0,
X  0x7ffedef8,
X  0x7ffedf00,`009`009`009/* 20 */
X  0x7ffedf08,
X  0x7ffedf10,
X  0x7ffedf18,
X  0x7ffedf20,
X  0x7ffedf28,
X  0x7ffedf30,
X  0x7ffedf38,
X  0x7ffedf40,
X  0x7ffedf48,
X  0x7ffedf50,
X  0x7ffedf58,
X  0x7ffedf60,
X  0x7ffedf68,
X  0x7ffedf70,
X  0x7ffedf78,
X  0x7ffedf80,`009`009`009/* 30 */
X  0x7ffedf88,
X  0x7ffedf90,
X  0x7ffedf98,
X  0x7ffedfa0,
X  0x7ffedfa8,
X  0x7ffedfb0,
X  0x7ffedfb8,
X  0x7ffedfc0,
X  0x7ffedfc8,
X  0x7ffedfd0,
X  0x7ffedfd8,
X  0x7ffedfe0,
X  0x7ffedfe8,
X  0x7ffedff0,
X  0x7ffedff8,
X  0x7ffee000,`009`009`009/* 40 */
X  0x7ffee008,
X  0x7ffee010,
X  0x7ffee018,
X  0x7ffee020,
X  0x7ffee028,
X  0x7ffee030,
X  0x7ffee038,
X  0x7ffee040,
X  0x7ffee048,
X  0x7ffee050,
X  0x7ffee058,
X  0x7ffee060,
X  0x7ffee068,
X  0x7ffee070,
X  0x7ffee078,
X  0x7ffee080,`009`009`009/* 50 */
X  0x7ffee088,
X  0x7ffee090,
X  0x7ffee098,
X  0x7ffee0a0,
X  0x7ffee0a8,
X  0x7ffee0b0,
X  0x7ffee0b8,
X  0x7ffee0c0,
X  0x7ffee0c8,
X  0x7ffee0d0,
X  0x7ffee0d8,
X  0x7ffee0e0,
X  0x7ffee0e8,
X  0x7ffee0f0,
X  0x7ffee0f8,
X  0x7ffee100,`009`009`009/* 60 */
X  0x7ffee108,
X  0x7ffee110,
X  0x7ffee114,
X  0x7ffee118,
X  0x7ffee120,`009`009`009/* 64 */
X  0x7ffee168,`009`009`009/* 6D */
X  0x7ffee170,
X  0x7ffee178,
X  0x7ffee180,`009`009`009/* 70 */
X  0x7ffee188,
X  0x7ffee190,
X  0x7ffee198,
X  0x7ffee1a0,
X  0x7ffee1a8,
X  0x7ffee1b0,
X  0x7ffee1b8,
X  0x7ffee1c0,
X  0x7ffee1c8,
X  0x7ffee1d0,
X  0x7ffee1d8,
X  0x7ffee1e0,
X  0x7ffee1e8,
X  0x7ffee1f0,
X  0x7ffee1f8,
X  0x7ffee200,`009`009`009/* 80 */
X  0x7ffee208,
X  0x7ffee210,
X  0x7ffee218,
X  0x7ffee220,
X  0x7ffee228,
X  0x7ffee230,
X  0x7ffee238,
X  0x7ffee240,
X  0x7ffee248,
X  0x7ffee250,
X  0x7ffee258,
X  0x7ffee260,
X  0x7ffee268,
X  0x7ffee270,
X  0x7ffee278,`009`009`009/* 8F */
X  0x7ffee3c0,`009`009`009/* F8 */
X  0x7ffee3c8,
X  0x7ffee3d0,
X  0x7ffee3d8,
X  0x7ffee3e0,
X  0x7ffee3e8,
X  0x7ffee3f0,
X  0x7ffee3f8,
X  0x7ffee400,`009`009`009/* 100 */
X  0x7ffee408,
X  0x7ffee410,
X  0x7ffee418,
X  0x7ffee420,
X  0x7ffee428,
X  0x7ffee430,
X  0x7ffee438,
X  0x7ffee440,`009`009`009/* 108 */
X  0x7ffee470,`009`009`009/* 10E */
X  0x7ffee478,
X  0x7ffee480,`009`009`009/* 110 */
X  0x7ffee488,
X  0x7ffee490,
X  0x7ffee498,
X  0x7ffee4a0,
X  0x7ffee4a8,
X  0x7ffee4b0,
X  0x7ffee4b8,
X  0x7ffee4c0,
X  0x7ffee4c8,
X  0x7ffee4d0,
X  0x7ffee4d8,
X  0x7ffee4e0,
X  0x7ffee4e8,
X  0x7ffee4f0,
X  0x7ffee4f8,
X  0x7ffee500,`009`009`009/* 120 */
X  0x7ffee508,
X  0x7ffee510,`009`009`009/* 122 */
X  0x7ffee628,
X  0x7ffee630,
X  0x7ffee638,
X  0x7ffee640,
X  0x7ffee648,
X  0x7ffee650,
X  0x7ffee658,
X  0x7ffee660,
X  0x7ffee668,
X  0x7ffee670,
X  0x7ffee678,
X  0x7ffee680,
X  0x7ffee688,
X  0x7ffee690,
X  0x7ffee698,
X  0x7ffee6a0,
X  0x7ffee6a8,
X  0x7ffee6b0,
X  0x7ffee6b8,
X  0x7ffee6c0
X  `125;
X/*
X  number of entries in symbol table
X*/
Xint sym_count = 195;
X#else
Xextern char *sym_name[];
Xextern int sym_value[];
Xextern int sym_count;
X#endif
$ GOSUB UNPACK_FILE
$ FILE_IS = "UNDATA.C"
$ CHECKSUM_IS = 993471108
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*
X  disassemble a data line
X
X  Copyright (c) 1988 By Robert Thomas Chojnacki, All rights reserved.
X*/
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include "unmacro.h"
X#include "commands.h"
X#include "posneg.h"
X#include "getdata.h"
X#include "debug.h"
Xundata()
X`123
X  char arg_line[64];
X  int aleng=0, count;
X
X  debmsg("<undata>");
X  switch (pos(bytetype[pc-base])) `123
X   case C0_BYTE:
X    printf("\t.byte\t");
X    printval(1,1);
X    break;
X   case C0_WORD:
X    printf("\t.word\t");
X    printval(2,1);
X    break;
X   case C0_LONG:
X    printf("\t.long\t");
X    printval(4,1);
X    break;
X   case C0_QUAD:
X    printf("\t.quad\t");
X    printval(8,1);
X    break;
X   case C0_OCTA:
X    printf("\t.octa\t");
X    printval(16,1);
X    break;
X   case C0_F_FLOATING:
X    printf("\t.f_float\t%f\n", (float) getlong());
X    break;
X   case C0_D_FLOATING:
X    break;
X   case C0_G_FLOATING:
X    break;
X   case C0_H_FLOATING:
X    break;
X   case C0_ASCII:
X    printf("\t.ascii\t/");
X    while (pos(bytetype[pc-base]) == C0_ASCII) `123
X      if (aleng > 60) `123
X`009aleng = 0;
X`009printf("/\n\t.ascii\t/");
X      `125
X      aleng++;
X      putchar(getbyte());
X    `125
X    if (aleng)
X      printf("/\n");
X    break;
X   case C0_ASCIC:
X    printf("\t.ascic\t/");
X    aleng = getbyte() & 0xff;
X    for (count = 0; count < aleng; count++)
X      putchar(getbyte());
X    printf("/\n");
X    break;
X   case C0_ASCID:
X    aleng = getlong() & 0xffff;
X    pc = getlong();
X    if ((pc >= base) && (pc <= top)) `123
X      printf("\t.ascid\t/");
X      for (count = 0; count < aleng; count++)
X`009putchar(getbyte());
X      printf("/\n");
X    `125 else `123
X      printf(";Address in .ASCID descriptor is out of range.\n");
X    `125
X    break;
X   case C0_ASCIZ:
X    printf("\t.ascii\t/");
X    while (image[pc-base]) `123
X      if (aleng > 60) `123
X`009aleng = 0;
X`009printf("/\n\t.ascii\t/");
X      `125
X      aleng++;
X      putchar(getbyte());
X    `125
X    if (aleng)
X      printf("/\n");
X    getbyte();
X    printf("\t.byte\t0\n");
X    break;
X   case C0_BLKB:
X    printf("\t.blkb\t");
X    aleng = 0;
X    while ((pos(bytetype[pc-base]) == C0_BLKB) && !image[pc-base]) `123
X      pc++;
X      aleng++;
X    `125
X    if (pos(bytetype[pc-base]) == C0_BLKB) `123
X      bytetype[pc-base] == C0_BYTE;
X    `125
X    printf("%d\n", aleng);
X    break;
X   case C0_BLKW:
X    printf("\t.blkw\t");
X    aleng = 0;
X    while ((pos(bytetype[pc-base]) == C0_BLKW) && !image[pc-base]) `123
X      pc++;
X      aleng++;
X    `125`032
X    if (pos(bytetype[pc-base]) == C0_BLKW) `123
X      bytetype[pc-base] == C0_BYTE;
X    `125
X    printf("%d\n", aleng/2);
X    break;
X   case C0_BLKL:
X    printf("\t.blkl\t");
X    aleng = 0;
X    while ((pos(bytetype[pc-base]) == C0_BLKL) && !image[pc-base]) `123
X      pc++;
X      aleng++;
X    `125`032
X    if (pos(bytetype[pc-base]) == C0_BLKL) `123
X      bytetype[pc-base] == C0_BYTE;
X    `125
X    printf("%d\n", aleng/4);
X    break;
X   case C0_BLKQ:
X    printf("\t.blkq\t");
X    aleng = 0;
X    while ((pos(bytetype[pc-base]) == C0_BLKQ) && !image[pc-base]) `123
X      pc++;
X      aleng++;
X    `125`032
X    if (pos(bytetype[pc-base]) == C0_BLKQ) `123
X      bytetype[pc-base] == C0_BYTE;
X    `125
X    printf("%d\n", aleng/8);
X    break;
X   case C0_BLKO:
X    printf("\t.blko\t");
X    aleng = 0;
X    while ((pos(bytetype[pc-base]) == C0_BLKO) && !image[pc-base]) `123
X      pc++;
X      aleng++;
X    `125`032
X    if (pos(bytetype[pc-base]) == C0_BLKO) `123
X      bytetype[pc-base] == C0_BYTE;
X    `125
X    printf("%d\n", aleng/16);
X    break;
X   case C0_ADDRESS:
X    printf("\t.address\tx`094%8X\n", getlong());
X    break;
X   case C0_MASK:
X    masks(getbyte(), arg_line);
X    printf("\t.mask\t%s\n", arg_line);
X    break;
X   case C0_ENTRY:
X    masks(getbyte(), arg_line);
X    printf("\t.entry\tL%X,%s\n", pc-2, arg_line);
X    break;
X  `125
X`125
Xforce_undata(btype)
Xchar btype;
X`123
X  char arg_line[64];
X  int aleng=0, count;
X
X  debmsg("<force_undata>");
X  switch (btype) `123
X   case C0_BYTE:
X    printf("\t.byte\t");
X    printval(1,1);
X    break;
X   case C0_WORD:
X    printf("\t.word\t");
X    printval(2,1);
X    break;
X   case C0_LONG:
X    printf("\t.long\t");
X    printval(4,1);
X    break;
X   case C0_QUAD:
X    printf("\t.quad\t");
X    printval(8,1);
X    break;
X   case C0_OCTA:
X    printf("\t.octa\t");
X    printval(16,1);
X    break;
X   case C0_F_FLOATING:
X    printf("\t.f_float\t%f\n", (float) getlong());
X    break;
X   case C0_D_FLOATING:
X    break;
X   case C0_G_FLOATING:
X    break;
X   case C0_H_FLOATING:
X    break;
X   case C0_ASCII:
X    printf("\t.ascii\t/");
X    while (aleng < 16) `123
X      aleng++;
X      putchar(getbyte());
X    `125
X    printf("/\n");
X    break;
X   case C0_ASCIC:
X    printf("\t.ascic\t/");
X    aleng = getbyte() & 0xff;
X    for (count = 0; count < aleng; count++)
X      putchar(getbyte());
X    printf("/\n");
X    break;
X   case C0_ASCID:
X    aleng = getlong() & 0xffff;
X    pc = getlong();
X    if ((pc >= base) && (pc <= top)) `123
X      printf("\t.ascid\t/");
X      for (count = 0; count < aleng; count++)
X`009putchar(getbyte());
X      printf("/\n");
X    `125 else `123
X      printf(";Address in .ASCID descriptor is out of range.\n");
X    `125
X    break;
X   case C0_ASCIZ:
X    printf("\t.ascii\t/");
X    while (image[pc-base]) `123
X      if (aleng > 60) `123
X`009aleng = 0;
X`009printf("/\n\t.ascii\t/");
X      `125
X      aleng++;
X      putchar(getbyte());
X    `125
X    if (aleng)
X      printf("/\n");
X    getbyte();
X    printf("\t.byte\t0\n");
X    break;
X   case C0_BLKB:
X    printf("\t.blkb\t");
X    aleng = 0;
X    while (!getbyte()) `123
X      aleng++;
X    `125`032
X    --pc;
X    printf("%d\n", aleng);
X    break;
X   case C0_BLKW:
X    printf("\t.blkw\t");
X    aleng = 0;
X    while (!getbyte()) `123
X      aleng++;
X    `125`032
X    --pc;
X    printf("%d\n", aleng/2);
X    break;
X   case C0_BLKL:
X    printf("\t.blkl\t");
X    aleng = 0;
X    while (!getbyte()) `123
X      aleng++;
X    `125`032
X    --pc;
X    printf("%d\n", aleng/4);
X    break;
X   case C0_BLKQ:
X    printf("\t.blkq\t");
X    aleng = 0;
X    while (!getbyte()) `123
X      aleng++;
X    `125`032
X    --pc;
X    printf("%d\n", aleng/8);
X    break;
X   case C0_BLKO:
X    printf("\t.blko\t");
X    aleng = 0;
X    while (!getbyte()) `123
X      aleng++;
X    `125`032
X    --pc;
X    printf("%d\n", aleng/16);
X    break;
X   case C0_ADDRESS:
X    printf("\t.address\tx`094%8X\n", getlong());
X    break;
X   case C0_MASK:
X    masks(getbyte(), arg_line);
X    printf("\t.mask\t%s\n", arg_line);
X    break;
X   case C0_ENTRY:
X    masks(getbyte(), arg_line);
X    printf("\t.entry\tL%X,%s\n", pc-2, arg_line);
X    break;
X  `125
X`125
X/*
X  Display a value in the current mode
X*/
Xprintval(size, eoln)
Xint size, eoln;
X`123         /* do everything in hex for now */
X  int l2, l1, l0;
X
X  switch (size) `123
X   case 1:
X    printf("`094x%02X", getbyte() & 0xff);
X    break;
X   case 2:
X    printf("`094x%04X", getword() & 0xffff);
X    break;
X   case 4:
X    printf("`094x%08X", getlong());
X    break;
X   case 8:
X    l0 = getlong();
X    printf("`094x%08X", getlong());
X    printf("%08X", l0);
X    break;
X   case 16:
X    l0 = getlong();
X    l1 = getlong();
X    l2 = getlong();
X    printf("`094x%08X", getlong());
X    printf("%08X", l2);
X    printf("%08X", l1);
X    printf("%08X", l0);
X    break;
X  `125
X  if (eoln)
X    printf("\n");
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "UNMACRO.C"
$ CHECKSUM_IS = 893532811
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*
X  UNMACRO - disassemble a VAX image file.  This is biased twords VMS images
X  although it could be used to disassemble other images, etcetera.
X
X  Copyright (c) 1988 By Robert Thomas Chojnacki, All rights reserved.
X*/
Xstatic char
X note[]="Copyright (c) 1988 By Robert Thomas Chojnacki, All rights reserved.";
X
Xstatic char helpbuf[]="HELP/LIBRARY=UNMACRO_DIR:UNMACRO UNMACRO";
Xstatic struct `123
X  int length;
X  char *address;
X`125 help;
X
X#define`009mainfile
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <signal.h>
X#include <ctype.h>
X#include "unmacro.h"
X#include "commands.h"
X#include "posneg.h"
X#include "symtab.h"
X#include "header.h"
X#include "debug.h"
XFILE *sfp;
X
Xint ctlc(), ctlc_int;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X`123
X  char sstring[8], in_file_exe[256], helptmp[256];
X  char block[512], arg_line[64], savefile[48];
X  char tmpsym[SYMNAMALLO], tmpline[132];
X  int command[8];
X  int i, j, nblocks, pre_pc;
X  int tot_blocks;
X  int ssize;
X  int current_arg;
X/*
X  init stuff
X*/
X  signal(SIGINT, ctlc);
X  arg1[0] = 0; arg2[0] = 0; arg3[0] = 0; arg4[0] = 0;
X  help.address = &helptmp;
X  current_arg = 1;
X  image_header = 'y';
X/*
X  Check command line for options
X
X    -h means no header
X*/
X  if (argc > 1) `123
X    if (argv[current_arg][0] == '-') `123
X      i = 1;
X      while (argv[current_arg][i]) `123
X`009if (argv[current_arg][i] == 'h') `123
X`009  image_header = 'n';
X`009`125 else if (argv[current_arg][i] == '?') `123
X`009  shorthelp();
X`009  exit(0);
X`009`125
X`009i++;
X      `125
-+-+-+-+-+ End of part 5 +-+-+-+-+-
