home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d188 / execdis.lha / ExecDis / instructions < prev    next >
Text File  |  1989-02-26  |  15KB  |  420 lines

  1. Copyright (c) 1989 Markus Wandel
  2.  
  3. Version 1.0
  4.  
  5. Release notes, February 3, 1989
  6.  
  7.  
  8. INTRODUCTION
  9. ------------
  10.  
  11. Here is a complete disassembly of the Amiga operating system
  12. kernel.  This means everything in the ROM component "exec.library".
  13. As this happens to include ROM-Wack and the ROM resident printf
  14. routine, they are disassembled and commented too.  When I say
  15. complete, I mean it.  All code is explained (explained to death
  16. in places), all data tables are formatted nicely, and even the
  17. pad bytes which the linker inserted between object modules are
  18. shown.
  19.  
  20. I originally did this disassembly in the middle of 1988.  I felt
  21. that I had to, since I wanted to write a device driver for a hard
  22. disk project (which still hasn't come to anything), and felt that
  23. there was insufficient information available to do this properly.
  24. So I started tentatively snooping around SendIO() and related
  25. functions, and spent about 60 hours snooping...
  26.  
  27. After the disassembly was done, it slowly came to me that I
  28. couldn't legally give it to anyone, because after all, mixed in
  29. with all my comments was a copy of Commdore-Amiga's proprietary
  30. code.  Yet, numerous people wanted a copy.
  31.  
  32. After much thought and experimentation, this method of making the
  33. disassembly available to the general public was developed.  The
  34. comments are distributed, but the disassembly is not.  Instead,
  35. you get a "script" file, containing the comments and instructions
  36. on how to recreate the disassembly, using code which is disassembled
  37. right out of your ROM.  Thus, I can distribute what I have written
  38. and everybody can add what they already have, to get the whole
  39. thing.  It implies, of course, that without the right version of
  40. the ROM (or kickstart disk), this whole file will be worthless to
  41. you.
  42.  
  43. There is a catch.  After you have run the enclosed programs and
  44. recreated the disassembly, YOU MAY NOT REDISTRIBUTE IT.  You may
  45. redistribute this archive (a Zoo file) in UNMODIFIED form only.
  46. Just as buying a disk copier does not entitle you to redistribute
  47. copies of all the software it allows you to back up, this method
  48. of creating this disassembly does not entitle you to redistribute
  49. the result.
  50.  
  51.  
  52. CONTENTS OF THIS ARCHIVE
  53. ------------------------
  54.  
  55. Upon taking apart the Zoo file, you should have ended up with the
  56. following files:
  57.  
  58.         pipe.device     - a public domain PIPE: handler
  59.         mountlist
  60.  
  61.         dis             - a public domain disassembler (modified)
  62.  
  63.         start           - an EXECUTE script
  64.  
  65.         convert         - the program which does all the work
  66.  
  67.         dis.data        - the file which will be processed to
  68.                           create the disassembly.
  69.  
  70.         instructions    - you are reading them
  71.  
  72. What to do with these files is explained in the next two sections.
  73.  
  74.  
  75. WHAT YOU NEED
  76. -------------
  77.  
  78. To create the disassembly, you need the following:
  79.  
  80. 1. An UNMODIFIED version 1.2 ROM or kickstart disk.  Don't use
  81.    a disk which has NoKlickStart or any other patch installed on
  82.    it.  Don't use 1.3.  I did this disassembly before 1.3 came
  83.    out, and I just didn't have the energy to change it to fit
  84.    1.3 (the exec appears to have been changed slightly).
  85.  
  86. 2. The "run" and "execute" commands in your c: directory.
  87.  
  88. 3. Disk space:  A bit over 600 kilobytes, preferably on two
  89.    separate disks.  One will hold the files from this archive,
  90.    the other will hold the output file.  If you put both on the
  91.    same disk, you will get a lot of disk thrashing.  People
  92.    with 1 megabyte or more of memory can use the RAM: disk.
  93.    People with two drives can use those.  People with only 512K
  94.    and one floppy drive have no choice, just start with a blank
  95.    disk and try not to listen to your drive being worn out.
  96.  
  97. 4. A bit of space in your devs: directory to install the
  98.    supplied PIPE: handler.
  99.  
  100.  
  101. HOW TO RECREATE THE DISASSEMBLY
  102. -------------------------------
  103.  
  104. NOTE:  A user using a heavily enhanced system (ARP, WShell, ARexx,
  105.        ConMan, etc) has told me that the procedure below does not
  106.        work on his setup.  See the next section for additional
  107.        information if it also does not work for you.
  108.  
  109. 1.  Have two sections of disk space, of approximately 300 and
  110.     350 kilobytes.  Into the smaller section, put the following
  111.     files:
  112.  
  113.         dis
  114.         start
  115.         convert
  116.         dis.data
  117.         run
  118.         execute
  119.  
  120.     Get "run" and "execute" from your c: directory.  People who
  121.     have hard disks or enough floppy drives or RAM to keep their
  122.     c: directory online don't have to do this.
  123.  
  124.     At this point, if your system is anything like mine, you
  125.     will have the above files on a floppy and either another
  126.     floppy, or a RAM: disk, or a hard disk, with enough space
  127.     to receive the output file.
  128.  
  129. 2.  Install the PIPE: device.  1.3 workbench users can skip this,
  130.     since they already have one.  1.2 users do the following:
  131.  
  132.     (a) copy the file "pipe.device" into the DEVS: directory
  133.  
  134.     (b) edit your devs:mountlist file to include the segment
  135.         from the "mountlist" file in this archive.
  136.  
  137.     Note:  Only the included PIPE: device and the PIPE: device
  138.     from 1.3 have been tested with this.  Other PIPE: devices
  139.     (if any exist) may not work.
  140.  
  141. 3.  Boot up your computer with a virgin 1.2 kickstart disk, or
  142.     make sure it has 1.2 ROMs in it.  If you have a 1.3 ROM machine,
  143.     find someone who still uses 1.2.
  144.  
  145. 4.  Type "mount pipe:".  If you are about to remove your workbench
  146.     disk, also type "dir pipe:", which will cause the handler to
  147.     be loaded (you won't get a directory).
  148.  
  149. 5.  Go to the directory where you put the files in step 1.
  150.     Have room available for the output file (about 327 kilobytes).
  151.     As explained earlier, don't make this the same disk as the
  152.     input file or you will get a lot of unnecessary head movement.
  153.  
  154. 6.  Type "execute start".  At this point, you should hear the
  155.     drive gronk away for a while as two programs are loaded at
  156.     the same time.  Eventually, you will get a prompt:
  157.  
  158.     Output filename?
  159.  
  160. 7.  Type in the name, including disk and path if necessary, of
  161.     your desired output file.  For example:
  162.  
  163.     Output filename? ram:exec.disassembly
  164.  
  165.     If you don't want an output file, just press RETURN at this
  166.     point and the program will run without creating one.
  167.  
  168. 8.  Wait as roughly 135 pages of disassembly scroll by.  If you
  169.     (and I!) haven't screwed up anything, it will run all the way
  170.     to the end (this will take a few minutes) and finish properly.
  171.     If something goes wrong, such as that a file got corrupted,
  172.     or you are using the wrong version of the ROM, things may
  173.     abort with an error message.  Let's hope not.
  174.  
  175. 9.  That's it.  Enjoy!  And remember, if you like this, don't
  176.     upload the completed disassembly to a BBS.  Upload this Zoo
  177.     file instead.  Don't convert it to an ARC file, don't throw
  178.     away the Zoo file and then try to piece it back together to
  179.     pass on.  If a BBS absolutely insists that only ARC files
  180.     be uploaded to it (some do), put the Zoo file inside an ARC
  181.     file and upload that.  I'm not kidding.  I think the sooner
  182.     ARC dies out on the Amiga, the better for all of us.
  183.  
  184.  
  185. WHAT TO DO IF IT DOESN'T WORK
  186. -----------------------------
  187.  
  188. The "start" script looks as follows:
  189.  
  190.         run dis <pipe:todis >pipe:fromdis
  191.         convert
  192.  
  193. It appears that this will not work properly on some systems which
  194. have certain enhancements added to them.  On a system running ARP
  195. (a 1.3 beta version), ConMan, ARexx, and WShell, executing the
  196. above script did not start the disassembler running as it should
  197. have.  I was not able to investigate, but the user reported that
  198. the disassembly recreation process worked fine if the following
  199. changes were made:
  200.  
  201. 1.  Start up two CLI (shell) windows.
  202.  
  203. 2.  Run the disassembler in the first CLI window:
  204.  
  205.       dis <pipe:todis >pipe:fromdis
  206.  
  207. 3.  Run the conversion program in the other CLI window:
  208.  
  209.       convert
  210.  
  211. In essence, this takes the RUN and EXECUTE commands out of the
  212. procedure.  I don't know what's wrong; it works fine on my system
  213. with the original AmigaDOS commands and the Matt Dillon shell.
  214.  
  215.  
  216. WHAT TO DO IF IT STILL DOESN'T WORK
  217. -----------------------------------
  218.  
  219. If nothing else works, do what I did to verify the archive prior
  220. to release:
  221.  
  222. - Boot with an original Kickstart 1.2, followed by an original
  223.   Workbench 1.2.  Use CTRL-D to get a CLI right away.
  224.  
  225. - If you don't have two drives, you may want to copy all the
  226.   necessary commands from C: to RAM: and assign C: there.
  227.  
  228. - Insert the disk where the files from the archive are, and get
  229.   the PIPE: handler up and running as follows:
  230.  
  231.       assign devs: {where the pipe.device is}
  232.       mount pipe:
  233.       dir pipe:    (ignore the error)
  234.       assign devs: sys:devs
  235.  
  236. - Get things rolling (make sure you have a big enough destination
  237.   directory; with 1 meg you can use RAM:)
  238.  
  239.       execute start
  240.  
  241.  
  242. HOW IT WORKS
  243. ------------
  244.  
  245. Let me start by explaining the big "dis.data" file.
  246.  
  247. This file contains all the comments from my original disassembly
  248. file, plus commands which tell the program "convert" how to
  249. reinsert the disassembled code and data tables.  The commands
  250. have the following syntax:
  251.  
  252. <width> is a positive or negative number.  Positive means,
  253. left justified within a column <width> spaces wide, negative
  254. means right justified.
  255.  
  256. <width> can always be omitted, in which case no padding is
  257. added.
  258.  
  259. @a=<hex address>
  260.  
  261. This sets the "current address" to the given value.  The next
  262. byte disassembled or otherwise displayed will come from this
  263. location.
  264.  
  265. @a?<hex address>
  266.  
  267. This checks that the current address is as expected.  I use this
  268. periodically to make sure that things are still "on track", i.e.
  269. the right instructions are being mated up with the comments.
  270.  
  271. @<width>b
  272.  
  273. Display a byte.
  274.  
  275. @<width>w
  276.  
  277. Display a word (4 hex digits).
  278.  
  279. @<width>l
  280.  
  281. Display a longword (8 hex digits)
  282.  
  283. @<width>x
  284.  
  285. Display an address (longword with only 6 digits shown).
  286.  
  287. @<width>d
  288.  
  289. Disassemble an instruction.
  290.  
  291. @<width>p
  292.  
  293. Display the current address as 6 hex digits.
  294.  
  295. @<width>,<length>s
  296.  
  297. Display a string.  It will be shown as a series of characters
  298. in double quotes.  Nonprintable characters are shown in hex,
  299. except for CR and LF, which are shown as such.
  300.  
  301. The "dis.data" file is read by the "convert" program and
  302. converted to the final output.  To do this, the "convert"
  303. program utilizes the services of a separate disassembler.
  304.  
  305. The disassembler is run with both the input and the output
  306. redirected.  It takes its input from a pipe named "pipe:todis"
  307. and writes its output to a pipe named "pipe:fromdis".  The
  308. convert program is at the other end of both pipes.
  309.  
  310. The "start" script first uses "run" to launch the disassembler
  311. in the background.  Then it runs the convert program in the
  312. foreground.  The convert program opens its ends of both the
  313. pipes.  When it is finished using the disassembler, it will
  314. send a "quit" command to the disassembler, empty both pipes,
  315. and exit.  This will cause the disassembler to cease running
  316. in the background, and the pipes to be deleted, returning
  317. everything to its original state.
  318.  
  319.  
  320. CAVEATS
  321. -------
  322.  
  323. The "dis" program has bugs.  The original version I used had
  324. two nasty bugs and a couple of minor ones.  This version has
  325. been improved:  The two nasty bugs it currently has are not
  326. the same ones as the original ones.
  327.  
  328. The bugs I currently know of are the following:
  329.  
  330. 1. A lot of instructions involving the status register (SR)
  331.    or the condition codes (CCR) are disassembled incorrectly.
  332.  
  333. 2. Instructions which have a direct byte operand which happens
  334.    to be an ASCII character (such as move.b #'a',D0) are
  335.    truncated after the "#".
  336.  
  337. 3. "stop #$xxxx" is shown only as "stop".
  338.  
  339. Originally, these bugs caused me little grief:  I just patched
  340. up the disassembly where I saw a problem.  But this time, the
  341. disassembler actually has to recreate the code!.  Rather than
  342. fixing the disassembler, I cheated and inserted correct versions
  343. of all the problem instructions into the data file.  These also
  344. include some 68020 and 68881 instructions (not many) which this
  345. disassembler knows nothing about.
  346.  
  347. As a result, the "dis.data" file is not *quite* free of
  348. Commodore-Amiga's proprietary code.  It includes about 200
  349. bytes or so of readable disassembly.  But they are not
  350. contiguous bytes, so they won't do anyone any good.
  351.  
  352. Why did I use this buggy disassembler in the first place?  I
  353. had access to another disassembler, which was extremely well
  354. written, had seen industrial strength debugging and testing,
  355. and could disassemble 68020 and 68881 instructions.
  356. Unfortunately, its output didn't look nearly as readable as
  357. that of "dis".  I used it extensively to track down the
  358. places where "dis" had screwed up, and to fill in the few
  359. instructions specific to the 68020/68881.
  360.  
  361.  
  362. CREDITS
  363. -------
  364.  
  365. The "dis" program was written by Greg Lee, and later modified by
  366. Willi Kusche.  I have changed it in the following ways:
  367.  
  368.     (a) The input can now come from a pipe, or a file, without
  369.         crashing the program.
  370.  
  371.     (b) An input "end of file" condition causes the disassembler
  372.         to exit.
  373.  
  374.     (c) No prompts are printed.
  375.  
  376. The program is still useable interactively though, just load it
  377. by typing "dis" and type "?" to get a command summary.
  378.  
  379. The PIPE: handler was written by Matt Dillon.  It's pretty hard
  380. to do anything on the Amiga and not use a program by Matt Dillon.
  381.  
  382. I should express my gratitude to all Amiga PD authors, and the
  383. above in particular, for making this possible.  While I went to
  384. much trouble to be able to release this file, I wouldn't have
  385. gone as far as writing a disassembler or a PIPE: handler, so if
  386. these hadn't been available, you wouldn't be seeing this.
  387.  
  388. Both these programs are declared to be public domain in their
  389. respective release notes.  If you want to use them for anything
  390. else, I suggest you scour the Fred Fish disks for the complete
  391. versions, with source code and documentation.  Sorry, I forgot the
  392. numbers of the disks, but start at the top and work your way
  393. down in order to get the newest versions.
  394.  
  395. The files "instructions" and "dis.data" are by me, and are
  396. copyrighted.  You may pass them on to other people, but only
  397. as part of the unmodified Zoo file as described earlier.
  398.  
  399. The program "convert" was written by me and placed in the public
  400. domain.  If you want to use it for a disassembly distribution
  401. project similar to this one, please do!
  402.  
  403. The output file you get will contain material which is copyrighted
  404. by me, and material which is copyrighted by Commdore-Amiga.  It
  405. is explicitly NOT redistributable.
  406.  
  407. Finally, if you want to reach me for comments, this is my address
  408. and phone number.  Well, it's my home address; I'm currently
  409. attending university and my address varies.  Mail sent there
  410. will reach me, and phone calls there will result in a phone
  411. number where you can reach me.
  412.  
  413.     Markus Wandel
  414.     R.R. #1
  415.     Bruce Mines, Ont.
  416.     P0R 1C0
  417.     Canada
  418.  
  419.     (705) 785-3383
  420.