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


Received: from vaxmfg.tech.nwu.edu by accuvax.nwu.edu id ab13177;
          2 Mar 89 12:28 CST
Date: Thu, 2 Mar 89 12:39 CST
From: Bob Chojnacki <CHOJNACKI@vaxmfg.tech.nwu.edu>
Subject: March 2 UNMACRO source 7/8
To: EVERHART%ARISIA.decnet@ge-crd.arpa
X-VMS-To: IN%"EVERHART%ARISIA.decnet@ge-crd.arpa"
Message-ID:  <8903021228.ab13177@accuvax.nwu.edu>

+-+-+-+ Beginning of part 7 +-+-+-+
X*/
Xctlc()
X`123
X  ctlc_int = 1;
X  signal(SIGINT, ctlc);
X`125
X
X/*
X  Short help
X*/
Xshorthelp()
X`123
X  fprintf(stderr, "unmacro [-options] image-file[.exe]\n");
X  fprintf(stderr, "unmacro -- disassemble VMS executeable files\n");
X  fprintf(stderr, "options:\n");
X  fprintf(stderr, "        h - ignore image header\n");
X  fprintf(stderr, "        ? - display this short message\n");
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "UNMACRO.CMP"
$ CHECKSUM_IS = 320693003
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ CC COMMANDS
X$ CC DISASSEMBLE
X$ CC DISPLACEMENTS
X$ CC GETDATA
X$ CC HEADER
X$ CC INSTRUCTIONS
X$ CC I_TYPE
X$ CC MASKS
X$ CC OPERANDS
X$ CC POSNEG
X$ CC SYMTAB
X$ CC UNDATA
X$ CC UNMACRO
$ GOSUB UNPACK_FILE
$ FILE_IS = "UNMACRO.COM"
$ CHECKSUM_IS = 1780770552
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ Link/Map/Full UnMacro,GetData,Instructions,Operands,I_Type,SymTab,Header,-
X   Displacements,Masks,Commands,Disassemble,Undata,PosNeg,Sys$Input:/Option
XSys$Share:VAXCRTL/Share
$ GOSUB UNPACK_FILE
$ FILE_IS = "UNMACRO.DOC"
$ CHECKSUM_IS = 878020598
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XNOTE: Please send any corrections/bugs/typos in this manual and any other part
Xof UNMACRO to chojnacki@vaxmfg.tech.nwu.edu.  Thank you.
X
X                           UNMACRO - A Disassembler
X
X0 Introduction
X
XThis is not even a beta release of UNMACRO.  I have this funny feeling that
Xthere are many bugs and problems with it but I hope that through correspondance
XI can correct them.  The user interface is somewhat like the VAX/VMS debugger
Xin that it takes commands of the form "SET BYTE ...", etcetera.
X
X1 Features
X
X`009o Creates output that can be assembled by MACRO (I hope)
X`009o Lets you disassemble for a while, save your session, exit, and
X`009  at a later time you can pick up where you left off
X`009o Symbolic addresses for CALLS and CALLG instructions
X`009o Default symbol table includes calls to the P1 system vector table
X`009o Automatically labels any addresses referenced by branch, jump, and
X`009  subroutine calls.  It automatically puts a .ENTRY on addresses
X`009  referenced by CALLS and CALLG instructions
X`009o Interprets the image header if you so desire via STATS command.
X`009o DUMP format listings of the header any other part of the image via
X`009  the HEADER and DUMP commands.
X`009o On-line help
X`009o Ability to search for a string of bytes in the image
X
X2 Commands
X
X2.1 DISASSEMBLE - Disassembles an instruction or data value
X
X  Format:
X
X    DISASSEMBLE entity
X
X  where entity is either a mask-type, UNTIL, or ALL
X
X    UNTIL - Disassmebles until the program counter (pc):
X
X      END  - reaches the end of the image
X      PC   - is greater than or equal to a value
X      DATA - reaches a non-instruction byte
X
V    ALL - Disassemble starting at the base of the image and going until the end
X.
X
X2.2 DUMP - Display the next 256 byte in a dump format
X
X2.3 HEADER - Display the image header in a dump format
X
X2.4 GOTO - Set the pc to a new value
X
X  Format:
X
X    GOTO address
X
X2.5 QUIT - Exit the program
X
X2.6 SAVE-UNSAVE - Store and recall the image mask.  The image mask is a byte
X  array the same size as the image that specifies whether the byte it
X  corresponds to is an instruction or a data value of some sort.
X
X2.7 SEARCH - Search the image, starting at the current pc and going until the
X  string is found or until the end of the image is reached.
X
X2.8 SET-SHOW - Force part of the image to be a particular data type/display
X  the data type at the current pc.
X
X  Format:
X
X    SET entity mask-type
X
X  Valid entities:
X
X    BYTE - Force the next byte to be interpreted as the mask-type given.
X    WORD - Force the next 2 bytes to be interpreted as the mask-type given.
X    LONG - Force the next 4 bytes to be interpreted as the mask-type given.
X    QUAD - Force the next 8 bytes to be interpreted as the mask-type given.
X    OCTA - Force the next 16 bytes to be interpreted as the mask-type given.
X    RANGE - Force the next n bytes to be interpreted as the mask-type given.
X
X      Format:
X
X        SET RANGE mask-type count
X
X      Where count is the number of bytes to force to be interpreted as the
X      mask-type specifies.  Note: count is a hexadecimal number.
X
X  Mask-Types - These are the different types of masks that may be placed on top
X  of the image to force how it will be disassembled:
X
X    UNDEFINED - The byte will not be interpreted.
X    INSTRUCTION - The byte will be interpreted as an instruction.
X    BYTE - The byte will be interpreted as a .BYTE directive.
X    WORD - The byte will be interpreted as a .WORD directive.
X    LONG - The byte will be interpreted as a .LONG directive.
X    QUAD - The byte will be interpreted as a .QUAD directive.
X    OCTA - The byte will be interpreted as a .OCTA directive.
X    F_FLOATING - The byte will be interpreted as a .F_FLOATING directive.
X    D_FLOATING - The byte will be interpreted as a .D_FLOATING directive.
X    G_FLOATING - The byte will be interpreted as a .G_FLOATING directive.
X    H_FLOATING - The byte will be interpreted as a .H_FLOATING directive.
X    ASCII - The byte will be interpreted as a .ASCII directive.
X    ASCIC - The byte will be interpreted as a .ASCIC directive.
X    ASCID - The byte will be interpreted as a .ASCID directive.
X    ASCIZ - The byte will be interpreted as a .ASCIZ directive.
X    BLKB - The byte will be interpreted as a .BLKB directive.
X    BLKW - The byte will be interpreted as a .BLKW directive.
X    BLKL - The byte will be interpreted as a .BLKL directive.
X    BLKQ - The byte will be interpreted as a .BLKQ directive.
X    BLKO - The byte will be interpreted as a .BLKO directive.
X    ADDRESS - The byte will be interpreted as a .ADDRESS directive.
X    MASK - The byte will be interpreted as a .MASK directive.
X    ENTRY - The byte will be interpreted as a .ENTRY directive.
X
X  Set also can do the following:
X
X  Format:
X
X    SET command
X
X  Where valid commands are:
X
V    LABEL - When the byte is disassembled, there will be a label preceding it o
Xf
X            the form:
X
X      laddress:
X
X      For example: if the byte at pc 200 was labeled, then, when it is
X      disassembled, it would appear as follows:
X
X        l200:   .byte  x`094025
X
X    UNLABEL - Removes a label set by SET LABEL.
X
X2.9 STATS
X  Displays important information such as transfer addresses, image base,
X  etc.
X
X2.10 WRITE - Disassembles the entire image and sends the output to a file.
X
X2.11 SYMBOL - Lets you define symbols, display, and remove
X
X  Format:
X
X    SYMBOL command
X
X  Valid commands are:
X
X    DEFINE - Define a symbol name.
X    LIST - Lists all symbols in the symbol table.
X    REMOVE - Removes a symbol from the symbol table.
X
X3 Example
X
X$ unmacro
XImage file: unmacro.exe
X75 blocks found in unmacro.exe.
XIs there an image header? y
XFirst transfer address = 7ffedf68
XSecond transfer address = 00003600
Xbase, top = 00000200, 00009600
X00000200> stats
XStats for image unmacro.exe
X;header statistics:
X;`009header size = 168. bytes
X;`009offsets to b, c, d, e = 0030, 0044, 0058, 0000
X;`009major id = 3230, minor id = 3530
X;`009number of header blocks = 1.
X;`009image type, priv mask = 01, ffffffff, ffffffff
X;`009i/o channels = 0., i/o seg pages = 0.
X;`009image flags = 01000028, gsid = 0696872d, sys version = 00000000
X;`009    PICIMG
X;`009    DBGDMT
X;`009transfer addresses = 7ffedf68, 00003600, 00000000
X;image section descriptors:
X;    isd 0
X;`009size = 0010 pages = 001a starting vpn = 0001 pfc = 00
X;`009flags = 0000008a base vbn = 0002
X;`009    Copy on reference
X;`009    Writable
X;`009    Last cluster in P0 space
X;    isd 1
X;`009size = 0010 pages = 0028 starting vpn = 001b pfc = 00
X;`009flags = 00000080 base vbn = 001c
X;`009    Last cluster in P0 space
X;    isd 2
X;`009size = 0010 pages = 0002 starting vpn = 0043 pfc = 00
X;`009flags = 0000040a base vbn = 0044
X;`009    Copy on reference
X;`009    Writable
X;`009    Fixup vector
X;    isd 3
X;`009size = 000c pages = 0014 starting vpn = ffec pfc = 00
X;`009flags = fd00008c
X;`009    Demand zero
X;`009    Writable
X;`009    Last cluster in P0 space
X;    isd 4
X;`009size = 0020 pages = 0004 starting vpn = 0000 pfc = 00
X;`009flags = 03000021 base vbn = 0000
X;`009    Global section
X;`009gsid = 04000002 name = 'VAXCRTL_001'
X;    isd 5
X;`009size = 001f pages = 0042 starting vpn = 0000 pfc = 00
X;`009flags = 03000021 base vbn = 0000
X;`009    Global section
X;`009gsid = 01000064 name = 'FORRTL_001'
X;    isd 6
X;`009size = 001f pages = 00b0 starting vpn = 0000 pfc = 00
X;`009flags = 03000021 base vbn = 0000
X;`009    Global section
X;`009gsid = 0100000e name = 'LIBRTL_001'
X;    isd 7
X;`009size = 001f pages = 008e starting vpn = 0000 pfc = 00
X;`009flags = 03000021 base vbn = 0000
X;`009    Global section
X;`009gsid = 8100800c name = 'MTHRTL_001'
X;    isd 8
X;`009size = 001f pages = 00c1 starting vpn = 0000 pfc = 00
X;`009flags = 03000021 base vbn = 0000
X;`009    Global section
X;`009gsid = 01000066 name = 'SMGSHR_001'
X00000200> header
Xheader block 0
X
X35 30 32 30 00 00 00 00 00 58 00 44 00 30 00 a8  (.0.D.X.....0205 00000000
X00 00 00 00 ff ff ff ff ff ff ff ff 00 00 01 01  ................ 00000010
X00 00 86 00 00 00 00 00 06 96 87 2d 01 00 00 28  (...-........... 00000020
X00 00 00 00 00 00 00 00 00 00 36 00 7f fe df 68  h_`126..6.......... 00000030
X00 00 00 06 00 00 00 00 00 00 00 46 00 00 00 00  ....F........... 00000040
X4f 52 43 41 4d 4e 55 07 00 00 00 00 00 00 00 00  .........UNMACRO 00000050
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00000060
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00000070
X00 00 00 00 00 00 00 00 00 00 00 30 2e 31 56 04  .V1.0........... 00000080
X00 00 32 30 2d 35 30 05 00 92 06 96 87 2d 26 a0   &-......05-02.. 00000090
X00 00 00 01 00 1a 00 10 00 00 00 00 00 00 00 00  ................ 000000a0
X00 00 00 1b 00 28 00 10 00 00 00 02 00 00 00 8a  ..........(..... 000000b0
X00 00 00 43 00 02 00 10 00 00 00 1c 00 00 00 80  ............C... 000000c0
X00 3f ff ec 00 14 00 0c 00 00 00 44 00 00 04 0a  ....D.......l.?. 000000d0
X03 00 00 21 00 00 00 00 00 04 00 20 fd 00 00 8c  ...`125 .......!... 000000e0
X4c 54 52 43 58 41 56 0b 04 00 00 02 00 00 00 00  .........VAXCRTL 000000f0
X03 00 00 21 00 00 00 00 00 42 00 1f 31 30 30 5f  _001..B.....!... 00000100
X5f 4c 54 52 52 4f 46 0a 01 00 00 64 00 00 00 00  ....d....FORRTL_ 00000110
X00 03 00 00 21 00 00 00 00 00 b0 00 1f 31 30 30  001..0.....!.... 00000120
X30 5f 4c 54 52 42 49 4c 0a 01 00 00 0e 00 00 00  ........LIBRTL_0 00000130
X00 00 03 00 00 21 00 00 00 00 00 8e 00 1f 31 30  01........!..... 00000140
X30 30 5f 4c 54 52 48 54 4d 0a 81 00 80 0c 00 00  .......MTHRTL_00 00000150
X00 00 00 03 00 00 21 00 00 00 00 00 c1 00 1f 31  1..A.....!...... 00000160
X31 30 30 5f 52 48 53 47 4d 53 0a 01 00 00 66 00  .f....SMGSHR_001 00000170
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00  ................ 00000180
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 00000190
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001a0
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001b0
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001c0
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001d0
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001e0
Xff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................ 000001f0
X00000200> goto 3600
X00003600> set word .entry
XSyntax error for SET BYTE/LONG... (argument 1)
XValid arguments are:
XUNDEFINED INSTRUCTION BYTE WORD LONG QUAD OCTA F_FLOATING D_FLOATING`032
XG_FLOATING H_FLOATING ASCII ASCIC ASCID ASCIZ BLKB BLKW BLKL BLKQ`032
XBLKO ADDRESS MASK ENTRY`032
X00003600> set word entry
X00003600>`032
X`009.entry`009l3600,`094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
X00003602>`032
X`009movab`009w`094`094x0fed8(sp),sp`009`009;3602
X00003607>`032
X`009jsb`009@l`094`094x866c`009`009;3607
X0000360d>`032
X`009movab`009l`094`094x200,r3`009`009;360d
X00003614>`032
X`009movab`009l`094`094x24e8,r5`009`009;3614
X0000361b>`032
X`009movab`009l`094`094x22c4,r8`009`009;361b
X00003622>`032
X`009movab`009l`094`094x2488,r9`009`009;3622
X00003629>`032
X`009movab`009l`094`094x35a8,r10`009`009;3629
X00003630>`032
X`009movab`009l`094`094x22c0,r6`009`009;3630
X00003637>`032
X`009movab`009@l`094`094x86c0,r11`009`009;3637
X0000363e>`032
X`009movab`009@l`094`094x86c4,r7`009`009;363e
X00003645>`032
X`009movw`009s`094#`094x24,b`094`094x0cc(fp)`009`009;3645
X00003649>`032
X`009movb`009s`094#`094xe,b`094`094x0ce(fp)`009`009;3649
X0000364d>`032
X`009movb`009s`094#`094x1,b`094`094x0cf(fp)`009`009;364d
X00003651>`032
X`009moval`009(r3),b`094`094x0d0(fp)`009`009;3651
X00003655>`032
X`009pushal`009b`094`094x025(r3)`009`009;3655
X00003658>`032
X`009pushl`009(r11)`009`009;3658
X0000365a>
X`009calls`009s`094#`094x2,@l`094`094x8690`009`009;365a
X00003661> go 8690
X00008690> disassemble long
X`009.long`009`094x0000007c
X00008690> dump
X00 00 00 a4 00 00 01 44 00 00 01 04 00 00 00 7c  `124.......D...$... 00008690
X00 00 06 e4 00 00 01 cc 00 00 03 fc 00 00 00 ac  ,...`124...L...d... 000086a0
X00 00 00 00 00 00 05 18 00 00 00 03 00 00 00 01  ................ 000086b0
X00 00 09 74 00 00 0a 38 00 00 0a 30 00 00 0a 2c  ,...0...8...t... 000086c0
X00 00 00 00 00 0d 00 02 00 00 84 00 00 00 00 01  ................ 000086d0
X00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00  ............@... 000086e0
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 000086f0
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008700
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008710
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008720
X00 00 00 00 4c 54 52 43 58 41 56 07 00 00 00 00  .....VAXCRTL.... 00008730
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008740
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008750
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008760
X00 00 00 00 00 4c 54 52 52 4f 46 06 00 00 00 00  .....FORRTL..... 00008770
X00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 00008780
X00008690> help
X  Information available:
X
X  DISASSEMBLE           DUMP       GOTO       HEADER     Introduction
X  Mask-Types QUIT       SAVE-UNSAVE           SEARCH     SET-SHOW   STATS
X  SYMBOL     WRITE
X
XTopic?
X00008690>`032
Xl8690:`009.long`009`094x0000007c
X00008694> shoe
XSyntax error for UNMACRO> (argument 0)
XValid arguments are:
XDISASSEMBLE SET SHOW QUIT GOTO SAVE UNSAVE DUMP STATS SEARCH HEADER`032
XHELP WRITE SYMBOL`032
X00008694> show
XINSTRUCTION
X
X00008694> go 8690
X00008690> show long
XLONG (labeled)
X
X00008690>`032
Xl8690:`009.long`009`094x0000007c
X00008c2e> quit
X
X4 Known Bugs
X
X    o DISASSEMBLE ALL may get stuck at a byte whose type is UNDEFINED
X    o SYMBOL REMOVE does not work yet
-+-+-+-+-+ End of part 7 +-+-+-+-+-
