home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / unld8615.arj / UNLOAD86.DOC < prev    next >
Encoding:
Text File  |  1992-06-04  |  17.5 KB  |  391 lines

  1. UNLOAD86.COM is a program that converts or "unloads" a file into it's INTeL 
  2. hex representation.  Alternately, it will also output a BNPF, BHLF, OR B10F
  3. type file for those users that require these formats.  This program was 
  4. written in response to the need to have INTeL hex files for downloading to
  5. an EPROM programmer.  As MS-DOS programs don't support INTeL hex, the need
  6. to convert binary files to hex arose.  Most development systems, INTeL, CP/M,
  7. & others do support INTeL hex, and most EPROM programmers expect it.
  8.  
  9.  
  10. Use of the program is simple:
  11.  
  12.  
  13. UNLOAD86  <RETURN>
  14.  
  15. prints a brief help screen.
  16.  
  17. The main form of the unload86 invocation is:
  18.  
  19. UNLOAD86 FILENAME.TYP [/OPTIONS]
  20.  
  21. B  output a BNPF file instead of INTeL hex.  This option overrides any other
  22. selections (Except Z).  If the B option is chosen, no other options will work,
  23. and the program will output a straight 8-bit BNPF file, uless it has been 
  24. modified for BHLF, or B10F.
  25.  
  26. Z  Simply adds a Control-Z end-of-file mark (1A Hex) to the end of the
  27. output file, be it INTeL hex or BNPF.  Most well-behaved programs ignore
  28. this, some expect it, but some can't tolerate it.
  29.  
  30. L  Selects the new "extended linear address record".  See the discussion
  31. at the end of this document for details.  If you don't know what this is,
  32. you probably don't need it.  Interacts with /E, /O, & /P.  Automaticly
  33. turns on /O, thus /O shouldn't be used with /L as /O will turn off /L. 
  34. /L also turns off /E & /P.
  35.  
  36. O Override extended addressing.  Any output file representative of 64K or
  37. greater normally uses extended address records.  This is any file created
  38. with /PC, /PD, /PE, or /PF, as well as any time the input file is longer
  39. than 64K.  This inhibits the extended address records for the rare cases
  40. where this is needed.  Interacts with /E.  Whichever is last is the effective
  41. switch, normaly only one would be used at a time.  This option also turns
  42. off /L
  43.  
  44. E forces the use of extended address records for file smaller than 64K.  Files
  45. larger than 64K already automaticly select extended addressing.  Interacts
  46. with /O and /L.  Whichever is last is the effective switch, normaly only one
  47. would be used at a time.  
  48.  
  49. P allows selection of an EPROM size so that all unused locations are filled
  50. with the user specified data (defaults to FF)  This option interacts with
  51. /L.  Whichever is last is the effective switch, normaly only one would be
  52. used at a time.  This option is followed immediately by a parameter number
  53. 0-F.  This parameter is:
  54.  
  55. 0  32 bytes.  Creates a file to fill a 32 byte ROM.  All unused locations
  56. are filled with the user defined data.  As with all these options, if the
  57. file is already longer than 32 bytes, an error message will be displayed
  58. on the system console, and the operation will be aborted.  The file left in
  59. this case is a useful INTeL hex file, but isn't padded up to size as it is
  60. already too big for the device specified.  32 byte devices are generally 
  61. little bipolar ROMs often used as memory decoders
  62.  
  63. 1  64 bytes.  This is also generally a bipolar device.
  64.  
  65. 2  128 bytes.  Bipolar.
  66.  
  67. 3  256 bytes.  1702A EPROM, some bipolars
  68.  
  69. 4  512 bytes.  2704 EPROM.
  70.  
  71. 5  1k bytes.  2708 EPROM.
  72.  
  73. 6  2k bytes.  2716 EPROM.
  74.  
  75. 7  4k bytes.  2732 EPROM.
  76.  
  77. 8  8K bytes.  2764 EPROM.
  78.  
  79. 9  16K bytes.  27128 EPROM.
  80.  
  81. A  32K bytes.  27256 EPROM.
  82.  
  83. B  64K bytes.  27512 EPROM.
  84.  
  85. C  *128K bytes.  27010 EPROM.
  86.  
  87. D  *256K bytes. 
  88.  
  89. E  *512K bytes. 
  90.  
  91. F  *1M bytes. 
  92.  
  93.    * These options force the generation of extended addressing and thus
  94.      do not require the use of the 'E' option.  This may be overridden
  95.      with the 'O' or 'L' options.
  96.  
  97. It was felt un-necessary to provide padding when the /L switch is used as
  98. an extended linear address is normally used only for files larger than 1
  99. megabyte.  If you are reading this in 1999 and you're still stuck with a
  100. computer that can run MS-DOS programs, need to pad a 4 megabyte PROM, you're
  101. getting what you deserve!  Get a real computer!
  102.  
  103. It should be noted that all INTeL hex output, regardless of options selected,
  104. is padded up to the next 32 byte increment.  This makes the /P0 parameter
  105. redundant, but what else am I going to do with it?
  106.  
  107. ERRORLEVEL support.  UNLOAD86 now supports ERRORLEVEL.  It exits with 0
  108. for no errors, and 255 if there was some kind of error.
  109.  
  110.  
  111. EXAMPLES:
  112.  
  113.  
  114. UNLOAD86 FOOBAR.COM/B    <-- produces a BNPF file called FOOBAR.BNP
  115.  
  116. UNLOAD86 FOOBAR.COM/EB   <-- produces a BNPF file called FOOBAR.BNP
  117.  
  118. UNLOAD86 FOOBAR.COM/E    <-- produces a hex file called FOOBAR.HEX
  119.                              w/extended addressing
  120.  
  121. UNLOAD86 FOOBAR.COM/EZ   <-- produces a hex file called FOOBAR.HEX
  122.                              w/extended addressing & CNTRL-Z at the
  123.                              end of the output file
  124.  
  125. UNLOAD86 FOOBAR.COM/L    <-- products a hex file called FOOBAR.HEX
  126.                              w/extended linear addressing
  127.  
  128. UNLOAD86 FOOBAR.COM/LE   <-- produces a hex file called FOOBAR.HEX
  129.                              w/extended addressing
  130.  
  131. UNLOAD86 FOOBAR.COM/EL   <-- products a hex file called FOOBAR.HEX
  132.                              w/extended linear addressing
  133.  
  134. UNLOAD86 FOOBAR.COM      <-- produces a hex file called FOOBAR.HEX
  135.                              w/extended addressing if input >64K
  136.  
  137. UNLOAD86 FOOBAR.COM/P0   <-- produces a hex file called FOOBAR.HEX
  138.                              padded to 32 bytes.
  139.  
  140. UNLOAD86 FOOBAR.COM/PF   <-- produces a hex file called FOOBAR.HEX
  141.                              padded to 1M byte, w/ extended addressing
  142.  
  143. UNLOAD86 FOOBAR.COM/PFO  <-- produces a hex file called FOOBAR.HEX
  144.                              padded to 1M byte, WITHOUT extended addressing
  145.  
  146. UNLOAD86 FOOBAR.COM/PFE  <-- produces a hex file called FOOBAR.HEX
  147.                              padded to 1M byte, w/ extended addressing
  148.  
  149. UNLOAD86 FOOBAR.COM/EPF  <-- produces a hex file called FOOBAR.HEX
  150.                              padded to 1M byte, w/ extended addressing
  151.  
  152. UNLOAD86 FOOBAR.COM/EPFB <-- produces a BNPF file called FOOBAR.BNP
  153.  
  154.  
  155.  
  156. Notes, patches, etc.:
  157.  
  158. UNLOAD86 cannot realisticly handle binary input larger than a megabyte as
  159. the extended addressing scheme runs out of addresses.  If you unload a file
  160. larger than 1 megabyte, the extended addressing will wrap around if it has
  161. been selected with the /E or the /Px options.  This limitation does not apply
  162. if you use the /L switch to select the extended linear address records.
  163.  
  164.  
  165. There are several user patchable options that can be patched with DEBUG.
  166. They are as follows:
  167.  
  168. 102:  FF   This is the data that is padded when using the /Px option.
  169.            Change to meet your requirements.
  170.  
  171. 103:  'PN' Change to 'HL' for BHLF output instead of BNPF, or '10' for B10F.
  172.            Or any other two ASCII characters for other variations of this.
  173.  
  174. 105:  '.'  This is the dot for the hex filename.  Must not be changed...
  175.  
  176. 106:  'HEX' Output file type for INTeL hex.  Change to meet your needs
  177.  
  178. 109:   00  This is the termination for the hex filename.  Don't change...
  179.  
  180. 10A:  '.'  This is the dot for the BNPF filename.  Must not be changed...
  181.  
  182. 10B:  'BNP' Output file type for BNPF.  Change to 'BHL' for BHLF, or
  183.             'B10' for B10F, or to whatever filetype you prefer for this
  184.             format.
  185.  
  186. 10E:   00  This is the termination for the BNPF filename.  Don't change...
  187.  
  188. 10F:   00  Change to FF to add a control-Z to the end of file by default.
  189.            In this case, the Z switch turns control-Z OFF instead of ON.
  190.  
  191.  
  192. This program was written by Mark D. Pickerill on the Pro-Log ABL-2 CP/M
  193. microcomputer. (what else?)  It bears no resemblance to UNLOAD 2.2 or
  194. 2.3 for CP/M by the same author.
  195.  
  196. THE USER BEARS ALL RESPONSIBILITY FOR TESTING AND USE!  IF THE PROGRAM
  197. MANGLES YOUR DATA, BLOWS YOUR HARD DRIVE, MAKES YOUR CAT BARF ON YOUR
  198. KEYBOARD, OR HAS OTHER UNDESIRED EFFECTS, YOUR SOLE RECOURSE IS TO
  199. DISCONTINUE USE OF THE PROGRAM!!
  200.  
  201.  
  202. UPDATES:
  203.  
  204. Ver. 1.5a.  Very minor cleanups to source code and documentation.  Made
  205. the /Z option a toggle rather than a set.  No real functional changes, so
  206. this is just the new 1.5 that will be distributed. 06/04/92
  207.  
  208. Ver. 1.5  After considerable work, and three tries, I have finally hung
  209. a buffered disk I/O routine onto the program.  I've learned a good deal
  210. about 80x86 programming in general, and disk I/O in particular in the four
  211. years this program has been under development.  As the original disk routines
  212. were closely tied to the actual UNLOAD routine, an attempt to increase
  213. the size of data read by these routines was scrapped as un-workable.  Instead,
  214. I borrowed a technique from my CP/M BIOS hacking days called BLOCK/DEBLOCK.
  215. The original routines see no difference in their I/O requests, but instead
  216. calls a couple of new routines pass the data back and forth, and maintain
  217. a rather large set of disk I/O buffers.  The result?  As you might expect,
  218. a huge increase in speed.  A test file, 271,634 bytes long was used.  Ver.
  219. 1.4 took 1:42 to UNLOAD this into Intel hex on a 25MHZ '286.
  220. The new ver. 1.5 only took 0:16.  A test of BNPF resulted in 3:15 vs. 0:36
  221. for the new version.  Plus it no-longer bangs the disk heads reading and
  222. writing all those little blocks of data.  This was all done with a slight
  223. DECREASE in size from 1.4 due to more intellegent buffer overlaying of the
  224. help screen.  No operational differences from 1.4.  Released 04/23/92,
  225. one year to the day that 1.3 was released!
  226.  
  227. Ver. 1.4  After receiving multiple complaints, I found and fixed a bug
  228. that wrote 6 garbage bytes after the EOF mark.  Well-behaved programs
  229. were not affected, but as MS-DOS is *full* of ill-behaved programs....
  230. 09/25/91  Also added the Z switch to turn on the CNTRL-Z EOF mark.
  231.  
  232. Ver. 1.3  It has come to my attention that Intel has finally patched
  233. their specification to accomodate files larger than 1 Megabyte with the
  234. addition of the "Extended Linear Address Record".  Support for this has
  235. been added.  Also changed the help screen such that if the user patches
  236. the file type for .HEX or .BNP, that the help screen will reflect this
  237. change.  Added Intel hex discussion to the documentation.  04/23/91
  238.  
  239. Ver. 1.2  After receiving multiple complaints, I changed the command line
  240. parser so that spaces are now allowed between the filename and the switch
  241. character.  Added - and [ as alternate switch characters for UNIX and CP/M
  242. types.  Input files larger than 64K now automaticly generate extended
  243. address records unless overridden with the /O switch.  /O also overrides
  244. forced extended addressing on the larger /Px options.  Added ERRORLEVEL
  245. support. 01/18/91
  246.  
  247. Ver. 1.1  Corrects a bug that dis-allowed zeros in the output filename.
  248. An input file of ROM0.BIN would be unloaded to ROM.HEX instead of
  249. ROM0.HEX.  Spurious bugs possibly could have also appeared if the input
  250. filename had no extension. 10/3/88
  251.  
  252. Ver. 1.0  Initial release. 8/10/88
  253.  
  254.  
  255. DISCUSSION OF INTEL HEX:
  256.  
  257. Intel hex is a method of representing binary data as ASCII data.  This
  258. has several advantages.  First, it can be viewed and changed with ordinary
  259. text editors.  Second, the data has a checksum so that transmission errors
  260. can be detected.  Third, it is an excellent way to transfer binary data through
  261. a 7 bit port or with software that only has ASCII transfer capability.  Fourth,
  262. and lastly, additional information such as load addresses and execution start
  263. addresses are incoded in the file.  It has one drawback however.  The Intel
  264. hex file is always at least slightly more than twice the size of the binary
  265. file it represents.
  266.  
  267. Intel hex is represented in records.  All records have the same format.
  268. They start with a colon, this is followed by a two digit byte count which tells
  269. how many data bytes are in the data field.  This is followed by a four digit
  270. load address which tells where the data loads in memory.  Then comes a two
  271. digit record type specifier (discussed below) which tells what kind of record
  272. this is.  Then comes 1 or more bytes (two or more digits) of actual data.  Last
  273. comes a one byte (two digit) two's complement checksum (modulo-256) of 
  274. everything that came before, except of course, the colon.  Anything that comes
  275. after this checksum, such as carriage return - line feed pairs, etc. is 
  276. ignored until the next colon.
  277.  
  278. :020000020000FC
  279.  
  280. This is a typical Intel hex record.  We will add spaces for clarity:
  281.  
  282. : 02 0000 02 0000 FC --Checksum
  283. |  |   |  |    |
  284. |  |   |  |    --Data bytes, two in this example
  285. |  |   |  --Record type
  286. |  |   --Load address for data
  287. |  --Byte count of data record
  288. -- Leading colon
  289.  
  290. RECORD TYPES:
  291.  
  292. There are currently 6 types of records.  The Intel hex specification has
  293. undergone 3 different revisions over the years.  The original specification
  294. only defined two record types, then the next revision added one more, and
  295. the most recent has added three more to that.  These revisions were made such
  296. that software that processes Intel hex need only write one routine to process
  297. all different types.  Unfortunately people cannot seem to realize this and
  298. use 3 different routines to process data that was intended to be backwards
  299. compatable.  The exact same problem exists with the XMODEM file transfer
  300. protocol.  XMODEM checksum, XMODEM CRC, and 1K XMODEM are all backwards
  301. compatable, yet most file transfer software makes you select between the three.
  302.  
  303.  
  304. 00 - Data record  
  305.  
  306. This record has a 00 in the record type field.  The byte count is typicaly
  307. 10 or 20 (hex), although it can be any number from 01 to FF.  The "wider"
  308. the record (larger the byte count), the less overhead there is in the file,
  309. but the checksum is less reliable.  Some software cannot handle byte counts
  310. larger than 40.
  311.  
  312. 01 - End record
  313.  
  314. This record has a 01 in the record type field.  This is the only record
  315. type which can have (and always does have) a byte count of zero.  The most
  316. common end record is :00000001FF.  This is a byte count of zero, a load
  317. address of zero, a record type of 1, and the checksum of FF.  What most
  318. people don't know is that the start execution address of the file can be
  319. stored in the address field, with appropiate alterations to the checksum.
  320. However, a lot of software will barf if it encounters a end record other than
  321. the one shown here.
  322.  
  323. The above two types are the original Intel hex specification
  324.  
  325. 02 - Extended address record
  326.  
  327. This record has a 02 in the record type field.  Its byte count is always 02.
  328. It has a load address of zero, and the extended address is in the two data
  329. bytes.  Why the address isn't stored in the address field for this, and all
  330. succeeding record types is unknown.  This record type was added by Intel when
  331. they introduced the 8086.  What Intel didn't make clear at the time was the
  332. fact that this two byte extended address is actually a *segment* address.
  333. It represents address bits 4 through 19.  So this address is the tired old
  334. segment addition:
  335.  
  336.      0000  -- "Extended address"
  337.       0000 -- "Load address"
  338.      00000 -- "Physical address"
  339.  
  340. Some software, especially software written to do Intel hex for other processors
  341. such as the 68000 family, use the extended address record to represent address
  342. bits 16-31.  This is incorrect!  When Intel (finaly) introducted a processor
  343. capable of doing flat addressing, they added record type 4 for this purpose.
  344. When UNLOAD86 uses this type of record, it starts at zero and increments it
  345. in blocks of 64K which adds 1000 hex to this segment address. 
  346.  
  347. The above three types are the "Rev 2" Intel hex specification
  348.  
  349. 03 - Extended start address
  350.  
  351. This record has a 03 in the record type field.  Its byte count is always 02.
  352. It is otherwise identical to record type 02, and is used to indicate the
  353. segment start execution address of the file.  As UNLOAD86 has no way of knowing
  354. this information, this record type is not supported.
  355.  
  356. 04 - Extended linear address record
  357.  
  358. This record has a 04 in the record type field.  Its byte count is always 02.
  359. The data field contains the extended linear load address, address bits 16-31.
  360. This is the much more sensable extended address record.  When UNLOAD86 uses
  361. this type of record, it starts at zero and increments it in blocks of 64K 
  362. which merely adds one to this address.  A lot of software cannot handle any
  363. of these new record types.  It is recomended that this type of addressing be
  364. used if your application and your software permit it, rather than record
  365. type 02.  Although it is perfectly legal to use both types, UNLOAD86 only 
  366. uses one at a time as it is converting a contiguous binary file to Intel hex,
  367. thus it doesn't make a lot of sense to use both.  Both types might be used
  368. in the case of a compiler or assembler output where the data is non-contiguous.
  369.  
  370. 05 - Extended linear start address
  371.  
  372. This record has a 05 in the record type field.  Its byte count is always 02.
  373. It is otherwise identical to record type 04, and is used to indicate the
  374. extended linear start execution address of the file.  As UNLOAD86 has no
  375. way of knowing this information, this record type is not supported.
  376.  
  377.  
  378. Discussion of BNPF:
  379.  
  380. BNPF is an old paper tape format that still crops up from time to 
  381. time.  It has a couple of varients, BHLF, and B10F.  They all work the
  382. same way.
  383.  
  384.  
  385. BPNPNNPNPF  ... Represents one byte.  The B stands for Begin.  The 
  386. following 8 Ns and Ps stand for Negative or Positive.  The F stands for
  387. Finish.  Thus the byte pictured is A5 hex.  BHLF uses H & L for High
  388. and Low instead of N & P.  B10F uses 1 and 0.  These are all ASCII characters,
  389. although I suppose they could be coded in Baudot as well.  You'd think
  390. from the name that BNPF would really be called BPNF, but it never is.
  391.