home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASMUTL / ASMGN201.ZIP / ASMGEN1.DOC < prev   
Encoding:
Text File  |  1985-10-05  |  26.4 KB  |  637 lines

  1.  
  2.  
  3. ************************************************************************
  4. *                                                                      *
  5. *   ASMGEN.COM - by J. Gersbach   and  J. Damke    (Ver. 2.01)         *
  6. *                                                                      *
  7. *   A program to generate cross-referenced assembly language code      *
  8. *   from any executable file.                                          *
  9. *                                                                      *
  10. *                                                                      *
  11. *                                                                      *
  12. *   Uploaded to PCanada by Mark Magner   November 23, 1983             *
  13. *                                                                      *
  14. ************************************************************************
  15.  
  16.  
  17.  
  18. *  PREFACE  *
  19.  
  20.  
  21. This program will generate 8086/87/88 assembly code text that is 
  22. compatible  with  the IBM Personal Computer Macro Assembler from 
  23. any executable diskette file up to 65,535 bytes.  The output can 
  24. be routed to the console or a disk- ette file.  A reference list 
  25. may be  generated  separately  or  embedded  at  the  appropiate 
  26. instruction counter address in the assembly code.
  27.  
  28. Some  manual  touch  up will be required before reassembly,  but 
  29. nearly all the typing is done for you  by  ASMGEN  and  anything 
  30. questionable is marked with "??".
  31.  
  32. A  file  of  sequential instructions may be resident on the same 
  33. diskette to indicat to  ASMGEN  which  addresses  contain  code, 
  34. byted,   words,   or   strings.   This  file  may  also  include 
  35. instructions to assume segment register  values  or  toggle  the 
  36. output  of  assembley  code  text,  generation  of the reference 
  37. table,  8087 mnemonics,  of the inclusion of embedded  reference 
  38. information in the assembly file.
  39.  
  40. DEBUG  may  be  used  to  browse  through the executable file to 
  41. determine the starting locations of code and data to develop the 
  42. sequential  instruction  file.  It  is important to accu- rately 
  43. specify these locations for  an  accurate  reference  tabel  and 
  44. minimum touching up of the ASM output text.
  45.  
  46. The  number  of references within the file determines the amount 
  47. of memory required since a reference tabel is  built  in  memory 
  48. during  the  first pass.  Disassembly is done from disk and only 
  49. one file sector is in memory at any given time. Therefore memory 
  50. size does not limit the size of the file to be disassembled. 48K 
  51. bytes of memory will be enough for most programs but a few  will 
  52. need  64K  or 128K.  One diskette drive is sufficient but two is 
  53. more convenient.
  54.  
  55.  
  56. *  STARTING ASMGEN  *
  57.  
  58. There are two ways to work with  ASMGEN:  either  by  using  the 
  59. command menu or by calling ASMGEN with parameters. Following are 
  60. the descriptions of both options.
  61.  
  62. *  USING THE ASMGEN MENU  *
  63.  
  64. The program is invoked by typing:  ASMGEN
  65.  
  66. You are then prompted for a file specification. Respond with the 
  67. name  of the executable file from which you wish to generate the 
  68. assembly  code.  The  executable  file  will  normally  have  an 
  69. extension of .EXE or .COM.  ASMGEN will check this file spec for 
  70. validity and then respond with a prompt that includes a  summary 
  71. of  the  command  letters  indicating  that  you  may  give it a 
  72. command.  The executable file contents are not checked for valid 
  73. code  and  ASMGEN  will  try to dis- assemble text or compressed 
  74. BASIC files and produce unintell- igible assembly code.
  75.  
  76. The commands are:
  77.  
  78. X filespec      This file spec replaces any previous executable
  79.                 file spec.  The usual file extension is .COM
  80.                 or .EXE
  81.  
  82.                 EXAMPLE:  X DATE.COM
  83.  
  84.  
  85. A <filespec> The executable file is disassembled and the  assem- 
  86.                 bly  code  is routed to the specified file.  The 
  87.                 usual file extension is .ASM. If the filespec is 
  88.                 omitted, the output will default to the console.
  89.  
  90.                 EXAMPLE:  A DATE.ASM
  91.  
  92. R <filespec>    The reference table is sent to the file specified.
  93.                 The usual file extension is .TBL.  If the filespec
  94.                 is omitted, the output will default to the console.
  95.  
  96.                 EXAMPLE:  R DATE.TBL
  97.  
  98. Q               The program is terminated and control returned to
  99.                 DOS.
  100.  
  101.  
  102. Each  time a command has been executed,  ASMGEN waits with a one 
  103. line prompt for the next command.
  104.  
  105. X <filespec>, A <CON>, R <CON> or Q ?
  106.  
  107. The default filespec for each  command  is  shown  in  brackets. 
  108. Enter the next command of your choice as described above.
  109.  
  110.  
  111. *  USING ASMGEN WITH PARAMETER CALLS  *
  112.  
  113. Up  to  three file specifications may be included when ASMGEN is 
  114. first called from DOS.  The  executable  file's  name  is  given 
  115. first, followed by specifications for the assembly and reference 
  116. table files.
  117.  
  118. EXAMPLE:  ASMGEN DATE.COM, DATE.ASM, DATE.TBL
  119.  
  120. If a semicolon follows the last filespec,  ASMGEN will  exit  to 
  121. DOS  when  the  command  has  been executed.  If no semicolon is 
  122. entered,  ASMGEN will display the menu options  described  above 
  123. and wait for further input after executing the command.
  124.  
  125. EXAMPLE:  ASMGEN DATE.COM, DATE.ASM;
  126.  
  127. If  the  filespec for the .ASM file and/or .TBL file is omitted, 
  128. ASMGEN will generate first the .ASM file, then a .TBL file using 
  129. the filename of the first filespec.
  130.  
  131. EXAMPLE:  ASMGEN  DATE.COM,,;  creates DATE.ASM and DATE.TBL and 
  132.                                exits to DOS.
  133.  
  134. If only the reference table  is  desired,  the  dummy  name  NUL 
  135. should be entered in place of an .ASM filespec
  136.  
  137. EXAMPLE:  ASMGEN DATE.COM, NUL, DATE.TBL
  138.  
  139. If  only  one filespec is given when the program is called,  the 
  140. reference table is built in memory and then the menu options are 
  141. displayed for further commands.
  142.  
  143. EXAMPLE:  ASMGEN DATE.COM
  144.  
  145.  
  146. *  PROGRAM EXECUTION  *
  147.  
  148. The  disassembly is done in two passes through the scource file. 
  149. On pass #1,  the reference table is  built  in  memory  and  the 
  150. actual output is gen- erated during pass #2.  Once the reference 
  151. table is established,  it remains in memory  until  an  X  or  Q 
  152. command  is issued,  and subsequent A and R com- mand executions 
  153. skip pass #1.  This saves a lot of time when the executable file 
  154. is large.
  155.  
  156. Three  contiguous  data  areas  are  built dynamically in memory 
  157. during pass #1.  First is the compressed sequential  instruction 
  158. list.  Second is a list of pointers for .EXE files that point to 
  159. the locations of all relocatable variables in the program,  also 
  160. arranged  in  numerical  order.  These  are  established  before 
  161. reading any code.  Third, the reference table is then built in a 
  162. higher area of memory as pass #1 progresses.
  163.  
  164. If  all available memory in the program segment is filled before 
  165. the first two data areas are completed, ASMGEN will abort to the 
  166. command prompt. After the reference table is started, a shortage 
  167. of memory will produce the message "Reference  Table  Incomplete 
  168. Due to Insufficient Memory" and continue.
  169.  
  170. Ctrl-Break  may  be  used  at any time to interrupt a command in 
  171. progress.
  172.  
  173.  
  174. *  READING THE ASSEMBLY CODE FILE (.ASM)  *
  175.  
  176. This file begins with a title taken from the  executable  file's 
  177. name and date followed by the current date (in brackets).
  178.  
  179. If  not  inhibited  by  the  M  switch  in a SEQ file (explained 
  180. later), the macro library will appear next in the file.
  181.  
  182. Next will be  a  .RADIX  16  pseudo-op  which  tells  the  macro 
  183. assembler that all numbers are in hexadecimal form.
  184.  
  185. Then comes a header that indicates a starting value for the code 
  186. segment,  stack  segment,  instruction  pointer  and  the  stack 
  187. pointer. The stack pointer is usually set to FFFF for .COM files 
  188. but may be somewhat less depending on available  memory.   These 
  189. values are passed by the linker for .EXE files.
  190.  
  191. The  first  ASSUME  statement  might  come  next.  There  is one 
  192. generated for each segment that begins with  code.  All  segment 
  193. registers  are  designated  according  to  the  current  set  of 
  194. ASSUMEs.  They  will  sometimes  be  incorrect,  so  all  ASSUME 
  195. statements should be checked prior to re-assembly.
  196.  
  197. The disassembled output follows,  terminated by an END statement 
  198. and the execution address.   An ORG  psuedo-op  is  included  if 
  199. required.
  200.  
  201. The  text  is  compatible  with  the IBM Macro Assembler and the 
  202. format is the same except for RETurns.  To avoid  the  need  for 
  203. PROCedure  titles,  special  mnemonics  are provided for all RET 
  204. instructions.  These are defined in the  macro  library  at  the 
  205. beginning  of  the  file.  Only  macros  that are needed for the 
  206. current file are produced.  The optional embedded commands  that 
  207. make up the reference table enhance the readability of the file. 
  208. For very large  files,  this  is  sometimes  undesirable  and  a 
  209. separate reference table is best.
  210.  
  211. When  invalid  instructions are encountered in code areas,  they 
  212. are reproduced as byte values followed by "??".  If a near  jump 
  213. is  defined previously in the code,  and it is within range of a 
  214. short jump,  a NOP instruction is inserted after the  jump.  The 
  215. executable  file  created  with  this  .ASM  file  and the Macro 
  216. Assembler and Linker  will  then  be  the  same  length  as  the 
  217. original  file.  This  makes  it less important to differentiate 
  218. between labels and numeric constants since the label values  and 
  219. their offsets within the file will be the same.  The fundamental 
  220. problem of disassembly is in knowing if  the  original  assembly 
  221. code  defined a number as a label which changes as a function of 
  222. it's position or as a number that always remains  the  same.  If 
  223. you make changes in the assembly code however, you must properly 
  224. specify all values.  You might as well remove all  NOPs  at  the 
  225. same time.
  226.  
  227. Labels  are  five  characters  long and begin with "L".  Segment 
  228. labels begin with "S".  The remaining characters are the current 
  229. instruction  counter in hex form,  thus making each label unique 
  230. and showing it's location in the original file.  The instruction 
  231. counter  is  continuous  throughout  the  assembly  code without 
  232. resetting at segment boundaries.  The segment labels are then in 
  233. byte as opposed to paragraph form.  In those cases where a label 
  234. value is modified by an ASSUME statement,  the original value is 
  235. included  as a comment in the referencing instruction so that it 
  236. may be easily changed back if it was not intended as a location.
  237.  
  238. The word "Relocatable" is printed at the end of  any  line  that 
  239. contains an ablolute paragraph value.  These are values that DOS 
  240. modifies after loading but befor executing a program.  They  are 
  241. used  for  loading  segment  registers that are sensitive to the 
  242. program location in menory.  Relocatable values are not modified 
  243. by ASSUMEs. ASMGEN converts these numbers from paragraph to byte 
  244. values by multiplying them by sixteen  so  that  they  will  fit 
  245. within the 16-bit instruction counter field.  When the paragraph 
  246. value is negative or exceeds 0FFFH,  it is left unchanged and  a 
  247. warning (??) is issued on that line.  When a program larger than 
  248. 64K bytes is being  disassembled,  it  should  be  divided  into 
  249. smaller files.
  250.  
  251. All words are produced as labels, except when the "L" switch has 
  252. been enacted in the .SEQ file (explained later).  The label name 
  253. indicates  it's  numeric  value and,  if it does not occur on an 
  254. instruction boundary,  the name indicates it's position relative 
  255. to the current instruction pointer is given by an EQU statement. 
  256. Therefore the Macro Assember will assume that it is a  location, 
  257. but  it is easily changed to a constant since the value is given 
  258. in the label name.  The word OFFSET precedes a label whenever it 
  259. is questionable whether it is a label or an immediate value. You 
  260. must decide which of the labels should be constants and which of 
  261. the  constants  should  be labels,  and change them accordingly. 
  262. When changing labels to numbers, be sure to append an "H" if the 
  263. number  ends  with a "D" or a "B" since the Macro Assembler will 
  264. otherwise assume that it is decimal or binary.
  265.  
  266. Bytes are always treated as constants. An optional switch may be 
  267. included  in  the  .SEQ  file  (explained  later)  which enables 
  268. numbers instead of labels if all references  to  the  value  are 
  269. data segment and immediate operation types.
  270.  
  271. An effective procedure to follow in attempting to understand the 
  272. assembly code file is to look first for the message  text  area, 
  273. the input commands, and the simpler subroutines.  Then add label 
  274. names to addresses in  the  .SEQ  file  (explained  later)  that 
  275. remind the you of their purpose.  Add comments to the labels. If 
  276. these names are well chosen, the larger routines eventually will 
  277. become clear.  The embedded references are produced as labels so 
  278. they will retain their meanings as they are changed.
  279.  
  280. It is also helpful to spend some time studying the structure  of 
  281. data areas.  Vector tables, which are frequently used to control 
  282. the program's flow, reveal the program's structure very quickly. 
  283. If  some  routines  do  not have labels at the beginning,  it is 
  284. usually because the code or tables that reference them  (or  the 
  285. segment  register  assumptions)  are not properly defined in the 
  286. .SEQ file.
  287.  
  288.  
  289. *  READING THE REFERENCE TABLE (.TBL)  *
  290.  
  291. A referencee is defined as a number that is referenced somewhere 
  292. in  the  program.   It  may  be  a program loaction or a numeric 
  293. constant.
  294.  
  295. A referencor is is defined as the address in  the  program  from 
  296. which a refer- ence is made to the referencee.
  297.  
  298. Each  entry  is  composed  of a referencEE followed by a list of 
  299. referencors.  If more than one line is needed,  additional lines 
  300. are indented to the first referencor position. The referencEE is 
  301. followed by an "S" if it includes references to the beginning of 
  302. segment. The referencor is followed by two letters, the first of 
  303. which  represents  the  segment  register  that  is  implied  or 
  304. prefixed  in  the  referencing  instruction.  The  second letter 
  305. indicates the type of operation  on  the  referencEE.  When  the 
  306. reference entries are embedded in the assembly code,  all values 
  307. are preceded with the letter "L".
  308.  
  309. ----------------------------------------------------------------------------
  310. 1st letter      |  2nd letter
  311. SEG REGISTER    |  TYPE OF OPERATION
  312. ----------------------------------------------------------------------------
  313. C  code         |  J  jump         M  modify - INC, ADD, etc.
  314. S  stack        |  C  call         I  immediate - value or offset
  315. D  data         |  R  read         T  test or compare
  316. E  extra        |  W  write        ?  unknown or ESC instruction
  317.                 |  P  port
  318. ----------------|-----------------------------------------------------------
  319.  
  320.  
  321.  
  322. *  WRITING/READING THE SEQUENTIAL INSTRUCTION FILE (.SEQ)  *
  323.  
  324. The  sequential  instruction  file  is   a   list   of   special 
  325. instructions  to  ASMGEN which the user creates.  The file takes 
  326. the form of a list of hexadecimal  addresses  and  single-letter 
  327. instructions or generation switches. If used, the .SEQ file must 
  328. be on the same diskette as the source file  and  have  the  same 
  329. name  as  the  source  file  with  an  extension  of .SEQ.  Each 
  330. instruction in the file must be in one of the following formats:
  331.  
  332. addr    command
  333. or
  334. addr    command         ;comment
  335. or
  336. addr    command         label   comment
  337. or
  338. addr    command         label   comment ;comment
  339.  
  340. "addr" represents the instruction pointer value. All addr values 
  341. must be in numerical sequence in the file.
  342.  
  343. "command"  may  be  either  a  toggle  switch  or  a  generation 
  344. instruction.
  345.  
  346. "label" is optional and replaces the label  generated  for  this 
  347. address with this non-blank string.
  348.  
  349. "comment" is optional and must be preceded by "label" unless the 
  350. dummy label "." is used. Everything following "label" is treated 
  351. as an address comment and will be printed in the ASM file behind 
  352. the generated instruction.  The address comment may be up to 255 
  353. characters in length and should not contain a semi-colon.
  354.  
  355. ";comment"  is optional.  Anything following a semi-colon in the 
  356. .SEQ file instructions is considered as a comment  in  the  .SEQ 
  357. file only and is not added to the generated .ASM file.
  358.  
  359. "label"  and  "comment" are not allowed when a generation switch 
  360. is coded,  but a ";comment" may be used to help clarify the .SEQ 
  361. file.
  362.  
  363. The  .SEQ file is read into memory before the first pass starts. 
  364. The addresses and commands will be compressed,  but "label"  and 
  365. "comment"  will be held in memory one to one.  An effect of this 
  366. is that memory space required for dis- assembly  increases  with 
  367. each "label" and "comment" added to the .SEQ file.
  368.  
  369.  
  370. *  DESCRIPTION OF GENERATION SWITCHES  *
  371.  
  372. THE  VARIOUS TOGGLE SWITCHES ARE SET TO ON BY DEFAULT.  Switches 
  373. may  be  toggled  on  and  off  at   any   point   in  the  .SEQ 
  374. file/disassembly.
  375.  
  376. All  options  switches except /M and /H can be either toggled or 
  377. directly set by the user.  A suffix of "+" turns the switch  ON, 
  378. and  a suffix of "-" turns the switch OFF.  Switches encountered 
  379. in the file that have neither of these suffixes are  toggled  to 
  380. the opposite of their state at the time;  ON switches are turned 
  381. OFF and OFF switches are turned ON.
  382.  
  383. /B - generate byte references
  384.  
  385. When ON,  byte and word references are included in the reference 
  386. table. When OFF, only word references are generated.
  387.  
  388. /E - embedded references in ASM file
  389.  
  390. When  ON,  reference table entries are inserted in the text just 
  391. before the referencee's definition statement.  When  OFF,  these 
  392. entries are not included with the disassembled text.  The entire 
  393. reference table can be printed with the "R" command.
  394.  
  395. /F - 8087 mnemonics
  396.  
  397. When  ON,   ESC  instructions  are  produced.   When   OFF,  ESC 
  398. instructions  are  assumed  to  be  8087  instructions  and 8087 
  399. mnemonics are produced.
  400.  
  401. /H - append hex "H"
  402.  
  403. When this switch appears at any point in the .SEQ file,  an  "H" 
  404. is appended to all hex numbers.  This does not, of course, apply 
  405. to the labels which are hex values preceded by the  letter  "L". 
  406. The  .RADIX 16 pseudo-op is omitted which allows the assembler's 
  407. radix to default to  decimal.  This  switch  defaults  to  NO  H 
  408. APPEND.  Note  that  it  will be set only once.  It retains it's 
  409. value until the next .SEQ file is read.
  410.  
  411. /L - generate label or number
  412.  
  413. When ON, all word references are treated as labels.  When OFF, a 
  414. word  reference  is treated as a constant if all referencors are 
  415. data immediate types.
  416.  
  417. /M - suppress macro library
  418.  
  419. When this switch appears at any point in the .SEQ file, no macro 
  420. library is included in the text output.  The DEFAULT IS THAT THE 
  421. MACRO LIBRARY WILL BE INCLUDED.  Note that this switch  will  be 
  422. set only once. It retains it's value until the next .SEQ file is 
  423. read.
  424.  
  425. /O - control ASM output
  426.  
  427. When ON, ASMGEN will output the generated text. When OFF, output 
  428. will be suppressed.
  429.  
  430. /R - control TBL output
  431.  
  432. When ON,  ASMGEN will output the generated reference data.  When 
  433. OFF, the reference table is not printed.
  434.  
  435. /T - control trace output
  436.  
  437. When ON,  up to 16 bytes of object code are included as comments 
  438. in each line of the assembly code file.   When OFF,  object code 
  439. is not included.
  440.  
  441.  
  442. *  DESCRIPTION OF .SEQ FILE COMMANDS  *
  443.  
  444. A - assume
  445.  
  446. The following lines contain  ASSUMptions  for  segment  register 
  447. values.  They  become effective at the address specified by this 
  448. instruction and may be modified  anywhere  in  the  disassembly.  
  449. The required format for assumptions is:
  450.  
  451. & 0400  DS
  452.  
  453. The ampersand indicates a continuation of the A instruction.
  454.  
  455. In  this  example,  a  data  segment  beginning at a instruction 
  456. pointer value of 400 will be assumed until another A instruction 
  457. changes  it.  CS,  ES,  and  SS are also supported.  The segment 
  458. assumptions are used for effective  address  calculations  only. 
  459. The  code  segment  assumption  does  not affect the instruction 
  460. pointer value.
  461.  
  462. B - bytes
  463.  
  464. The bytes encountered in the source file  are  assumed  to  have 
  465. meaning as single byte values.
  466.  
  467. C - code
  468.  
  469. The bytes encountered in the source file are assumed to be valid 
  470. 8088 machine language instructions.
  471.  
  472. D - generate data operand
  473.  
  474. The operand of the instructions is changed  to  immediate  data. 
  475. Subsequent bytes are interpreted as "C" (code follows).
  476.  
  477. I - initial value for IP
  478.  
  479. The  hexadecimal  value  on  this line overrides the instruction 
  480. pointer value at the beginning of the file - not to be  confused 
  481. with  the address at which execution begins.  The default values 
  482. are 0000 for EXE files and 0100H for COM and  other  files.  The 
  483. execution address following the END statement is omitted if this 
  484. option is invoked.
  485.  
  486. S - strings
  487.  
  488. The bytes encountered in the source file  are  assumed  to  form 
  489. text.  Quoted  text  is  produced for valid ASCII characters and 
  490. byte values for others.
  491.  
  492. # - defined length strings
  493.  
  494. The first byte encountered  in  the  source  file  contains  the 
  495. length  of  the  character  string  which  begins  with the next 
  496. encountered character.  This length value may be overridden by a 
  497. subsequent SEQ file instruction.
  498.  
  499. $ - defined length strings
  500.  
  501. The  first  byte  encountered  in  the  source file contains the 
  502. length of the  character  string  which  begins  with  the  next 
  503. encountered  character plus the length byte itself.  This length 
  504. value may be overridden by a subsequent SEQ file instruction.
  505.  
  506. W - words
  507.  
  508. Pairs of bytes encountered in the source  file  are  assumed  to 
  509. have meaning as word values.
  510.  
  511. X - repeating data structure
  512.  
  513. A  cyclic  data  structure  is assumed to begin at the specified 
  514. instruction pointer value.  The structure definition may  follow 
  515. and is prefixed by an ampersand (&) to indicate the continuation 
  516. of this instruction. If the definition does not follow, then the 
  517. most recent definition is used.  If no structure is yet defined, 
  518. then an error message is displayed.
  519.  
  520. The following elements may be used to define the structure:
  521.  
  522. & NNNN S  -  The next NNNN bytes are defined as string characters
  523. & NNNN B  -  The next NNNN bytes are defined as byte values
  524. & NNNN W  -  The next NNNN bytes are defined as word values
  525. & XXNN $ - The next sequence of bytes is defined as  NN  fields. 
  526.              Each  field  consists of a length byte and a string 
  527.              of  characters.   The  length  of  each   field  is 
  528.              contained  in the first encountered byte.  The high 
  529.              nibble (XX),  if non-zero,  is a bit  mask  of  the 
  530.              length  field within the byte.  The length field is 
  531.              right-justified within  the  byte  after  the  byte 
  532.              value is sent to the output file.
  533.  
  534.  
  535.  
  536. *  EXAMPLES OF .SEQ COMMANDS  *
  537.  
  538. This  example  .SEQ  file shows all the possible instructions in 
  539. the appropriate format.
  540.  
  541. ;All switches are on at the beginning.
  542. 0       /T      ;no object code as comments in output
  543. 0       /M      ;no macro library in output
  544. 0       /H      ;append "H" to all numbers
  545. 00H     /A      ;assume the following segment values
  546. ;Note that the ampersand (&) indicates the extended ASSUME
  547. & 380   DS      ;the data segment starts at 380 hex
  548. & 380   ES      ;the extra segment starts at 380 hex
  549. 0200     I      ;initialize the instruction pointer to 200
  550. 0200    /F      ;introduce 8087 mnemonics (not ESC)
  551. 0200    /E      ;no embedded references
  552. 0200     C      ;code begins at 200
  553. 0203H    W      ;words are at 203
  554. 0207     C      ;more code starting here
  555. 220      X      ;complex data structure begins here
  556. & 3      W      ;words
  557. & 1      B      ;byte
  558. & 0E02   $      ;2 strings starting with the 2nd byte follow
  559.                 ;bits 3,2,1 of the first byte contain the length of the
  560.                 ;string including the length byte.
  561.                 ;the high nibble (0E) is the mask.
  562.                 ;see also # in summary below
  563. & 1      B      ;byte
  564.                 ;the structure repeats until 351
  565. 351      B      ;bytes
  566. 358      C      ;more code
  567. 380      S      ;strings - list of messages
  568. 421      W      ;words
  569. 4FD     /B      ;no further byte references
  570. 502     /R      ;garbage here - turn off reference generation
  571. 502     /O      ;and output
  572. 600H    /O+     ;valid code - turn output back on
  573. 600     /R
  574. 600      C
  575. 1A60 /O-        ;output file about to fill diskette - turn  output 
  576.                 ;off but keep ;scanning for references. another run 
  577.                 ;will be needed to get the remaining code.
  578. 1B00    /D      ;treat operand as immediate data
  579. 1DFD    /B+     ;continue with byte references
  580. 1F45     W      user_prt        ;user provided labels will translate
  581. 2256     S      $MSG            ;to upper case
  582.  
  583.  
  584. Comments may be included if preceded by a semicolon.
  585.  
  586. Alphabetic characters may be either upper or lower case.
  587.  
  588. An "H" may follow the hex address.
  589.  
  590.  
  591.  
  592. *  SAMPLE SESSION  *
  593.  
  594. The external command CHKDSK.COM will serve  as  an  example  for 
  595. this  sample session because it is short.  The .SEQ file is also 
  596. short and easy to generate.  Only  these  few  instructions  are 
  597. needed.
  598.  
  599.  
  600. 0100  /T  ;include object code as comments in .ASM file
  601. 0100  /E  ;simpler output without references
  602. 04F7H  S  ;messages
  603. 04F7H /H  ;append "H" to numeric values
  604.  
  605. Using  DEBUG,  browse  through  CHKDSK.COM  to  see how this was 
  606. arrived at.  Usually,  but not always,  the best procedure is to 
  607. assume code.  If the code appears unintelligible,  display it in 
  608. hex/ASCII.  If it is not text, assume bytes.  Label positions in 
  609. the first disassembly may indicate that some locations should be 
  610. words.  Next, generate the .ASM file by typing
  611.  
  612. ASMGEN CHKDSK.COM <enter>
  613. A                 <enter>
  614.  
  615. The assembly code can be viewed on the screen.  Then type
  616.  
  617. A CHKDSK.ASM      <enter>
  618.  
  619. to save the assembly source code to a file.  Then,
  620.  
  621. R CHKDSK.TBL      <enter>
  622.  
  623. to save the cross-reference table to disk.
  624.  
  625. The Macro Assembler,  Link.exe and Exe2bin could now be used  to 
  626. assemble  CHKDSK.ASM,  link  it to .EXE and convert it to a .COM 
  627. file. No modification should be necessary in this case.
  628.  
  629. If working with code that is to be modified,  the  symbol  types 
  630. must  be  correctly  specified as locations or as constants.  If 
  631. they are constants, place them outside of any segment. The label 
  632. names may then be changed to make the code more readable.
  633.  
  634.  
  635. ENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDENDEND
  636.