home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / books / 68k_book / arp_doc / chap_11.doc < prev    next >
Text File  |  1985-11-20  |  76KB  |  2,078 lines

  1.    Atari ST Machine Specific Programming In Assembly
  2.  
  3. Chapter 11: Reconstructing Source Files
  4.  
  5.      There are four legitimate sources for software.  You can 
  6. purchase it, you can find it in magazines and books, you can 
  7. obtain it free as public domain or you can write it yourself.  
  8. Rarely will you be satisfied with any of it.  Software that you 
  9. write is easy to alter because you have the source program.  
  10. Magazines and books usually provide source programs also.  But 
  11. commercial and public domain software rarely, if ever, provide 
  12. that convenience.  Altering programs for which you do not have 
  13. the source program is difficult, but not impossible.  The task is 
  14. addressed in this chapter.
  15.  
  16. Learning From Other Programmers
  17.  
  18.      If you are a new programmer, you may not realize the extent 
  19. to which experienced programmers study code produced by other 
  20. programmers.  Of course, you will read in your references that 
  21. the only way to become a programmer is to write programs.  To the 
  22. extent that writing programs is the only way in which you can 
  23. test your accumulation of knowledge about programming, that 
  24. statement is true.  But it is not the whole story.  I don't think 
  25. that I can be contradicted in the least when I say that you will 
  26. learn more about programming by studying programs produced by 
  27. other programmers than you ever will by working alone.
  28.  
  29.      I am convinced of that because I am convinced that the 
  30. accumulation of knowledge and ability is regenerative, in the 
  31. electronic sense; that is, you learn a little from someone, apply 
  32. that to what you already know and use that combined knowledge to 
  33. generate new knowledge by your own initiative.  Then you initiate 
  34. the cycle again by learning a little from someone else.  I am not 
  35. striving to impress you with some radical new concept here; I am 
  36. constructing an argument concerning our debt to each other.  The 
  37. conclusion of that argument is this: no one has ever learned 
  38. anything in solitude.  We all learn from each other; therefore, 
  39. no one owns knowledge.
  40.  
  41.      To the extent that every idea we can possibly conceive is 
  42. based on knowledge contributed by others, no idea, however 
  43. original can stand isolated; therefore, every item of work that 
  44. we produce is inherently public domain to some degree, whether we 
  45. admit the fact and regardless of our feelings about the matter.  
  46. But, because I want to illustrate the alteration of programs 
  47. produced by third party programmers; that is, programs not 
  48. produced by you nor me; I am forced to consider the feelings and 
  49. opinions of those programmers.  I want to assure those 
  50. programmers and you that my intent is not to provide you with 
  51. assistance in pirating or plagiarizing their works.  With no 
  52. malice intended, I only suggest that after you have purchased 
  53. software you have the right to study and alter it for your own 
  54. use if you choose to do so.
  55.  
  56.      Furthermore, I suggest that, unless you attempt to 
  57. unethically exploit that right by selling or giving away copies 
  58. of either the original works or altered versions, the authors and 
  59. distributors of those works lose nothing by your study and 
  60. alterations, and, in fact, invite such activities merely by 
  61. making the material available.  If I design a program or write a 
  62. book that I don't want you to study or alter, then I would be 
  63. foolish to publish either.  Imagine the difficulties that 
  64. publishers would encounter if they were to try to prevent readers 
  65. from revealing the contents of magazines and books to those who 
  66. had not purchased and read them.
  67.  
  68.      One final point, then we'll get down to the business at 
  69. hand.  Software producers have asked that purchasers help to 
  70. protect them against piracy.  I would be more sympathetic to that 
  71. plea if software developers, in turn, would help to protect 
  72. purchasers from software that does not perform as specified and 
  73. from expensive upgrades that introduce more errors than are 
  74. corrected; would write manuals for their products which actually 
  75. explained their use; and, finally, would provide the source code 
  76. so that users could correct the errors that seem beyond the 
  77. ability of the developers.
  78.  
  79. From Machine Language to Source Program
  80.  
  81.      As a first example, I will step you through the process of 
  82. converting the machine language of PRG_8AR.ACC, introduced in 
  83. chapter 10, to a source program that may be altered and 
  84. assembled.  The process involves the use of the AssemPro debugger 
  85. to provide disassembly and reassembly listings of the object 
  86. program.  A few things to remember are:
  87.  
  88.      1. The disassembly and reassembly AssemPro functions are 
  89.         rather unforgiving.  Any errors in usage are apt to cause 
  90.         system crashes.
  91.  
  92.      2. The listings provided by these functions are saved to the 
  93.         directory from which the object program is loaded; 
  94.         therefore, make sure that there is room before you begin.
  95.  
  96.      3. Tiny programs produce large listings; large programs 
  97.         produce extremely large listings.  Examples will be 
  98.         given.
  99.  
  100.      4. The listings provided may contain characters that are not 
  101.         printer compatible.  These must be removed before 
  102.         hardcopy is feasible.
  103.  
  104.      During the machine language to assembly language conversion 
  105. process you may find it necessary to reload the object program in 
  106. order to single step through a portion of the program or to 
  107. obtain a fresh disassembly or reassembly listing.  To insure that 
  108. the initial disassembly will be reproducible, you must be able to 
  109. load and reload the object program into a reproducible 
  110. environment.  This means that all accessories and auto executed 
  111. programs contained in the system environment during initial 
  112. disassembly and/or reassembly must reside within the environment 
  113. during subsequent disassemblies and/or reassemblies.  
  114. Furthermore, no other programs should be executed before using 
  115. AssemPro to disassemble your object code.  In fact, you may find 
  116. it necessary to cold boot the system between subsequent 
  117. disassemblies of one object program.  The point is that you will 
  118. want the addresses shown on all listings to be identical; 
  119. therefore, you must insure that the object program will be loaded 
  120. into the same area of memory each time.
  121.  
  122.      Begin by executing AssemPro.  From the debugger, click on 
  123. the Execute program button.  When the dialog box appears, click 
  124. on the OK button.  From the file selector choose PRG_8AR.ACC.  
  125. Remember that the disassembly and reassembly listings will be 
  126. saved to the directory from which the program is loaded into the 
  127. debugger.  Always allow sufficient room for the listings.  For 
  128. example, PRG_8AR.ACC occupies only 1082 bytes of disk space, but 
  129. the disassembly listing requires 15,881 bytes and the reassembly 
  130. listing requires 17,074 bytes.  At those ratios, a program that 
  131. requires 30K to 40K bytes of disk space may produce listings that 
  132. require as much as 500K bytes of space.
  133.  
  134.      After the program has been loaded into the debugger, record 
  135. the program's start address.  I will be using the values obtained 
  136. on my machine so that you will be able to observe the addresses 
  137. and calculations involved.  The starting address for my example 
  138. is $B20F0.  Click on the from address button.  On the line which 
  139. appears at the bottom of the debugger screen, type the address of 
  140. the program's basepage.  That address is Start address minus 
  141. $100; for this example it is $B20F0 - $100 = $B1FF0.  Refer to 
  142. page 97 of the COMPUTE! TOS book and figure 11.1 during the 
  143. discussion to follow.
  144.  
  145.   Figure 11.1. PRG_8AR.ACC's basepage as it appears in the 
  146.   AssemPro debugger output window.
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.      The longword stored at the first address of the basepage is 
  173. just the first address of the basepage itself; that is, $000B1FF0 
  174. is stored at $0B1FF0.  The longword stored at basepage address + 
  175. 8 ($0B1FF8) is the program's start address, $000B20F0.  This 
  176. address is also called the text segment address.  The longword 
  177. stored at basepage address + 12 ($0B1FFC) is the length of the 
  178. program's text segment, $000001E8.  The longword stored at 
  179. basepage address + 16 ($0B2000) is the address of the program's 
  180. data segment, $000B22D8.  The longword stored at basepage address 
  181. + 20 ($0B2004) is the length of the program's data segment, 
  182. $0000021C.  The longword stored at basepage address + 24 
  183. ($0B2008) is the address of the program's bss segment, $000B24F4.  
  184. The longword stored at basepage address + 28 ($0B200C) is the 
  185. length of the program's bss segment, $00000552.
  186.  
  187.      We want disassembly and reassembly listings that begin at 
  188. the program's start address, called the "from address" by 
  189. AssemPro, and terminate at the end of the longword following the 
  190. end of the program, called the "to address" by AssemPro.  The 
  191. from address is given; it is $B20F0.  The to address must be 
  192. calculated; it is the sum of the program's bss address plus the 
  193. length of the bss segment plus 4; that is, $B24F4 + $552 + $4 = 
  194. $B2A4A.  Figure 11.2 illustrates the appearance of the 
  195. Disassembling dialog box just before the OK button is pressed; 
  196. figure 11.3 is the disassembly listing.
  197.  
  198.      Note: there will be times when you will want to exclude a 
  199. program's bss section from a disassembly listing because of its 
  200. extreme length.  In fact, the bss section reveals little 
  201. information beyond the amount of memory reserved for the data to 
  202. be stored there.  Here I have simply omitted a large repetitious 
  203. segment of the listing.
  204.  
  205. Figure 11.2. Preparing the Disassembling dialog box.
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.         From the Debugger menu, click on the Disassembling 
  226.   option.  Type the from address and the to address on the 
  227.   appropriate lines.  Click on File: and type the name to be 
  228.   assigned to the listing file.  On the heading line, type an 
  229.   appropriate heading for the listing.  Click on the continuous 
  230.   button, and make sure that the hexadecimal button is 
  231.   highlighted; click on the button if it is not.  Finally, click 
  232.   on the OK button.  A flag will appear in place of the mouse 
  233.   arrow, and it will remain until the disassembly is complete.
  234.  
  235.   Figure 11.3. The disassembly listing.
  236.  
  237. PRG_8AR.ACC Disassembly
  238.  
  239. 0B20F0 4FFA0954             LEA $B2A46(PC),A7
  240. 0B20F4 3F3C0000             MOVE.W #0,-(A7)
  241. 0B20F8 487A03E5             PEA $B24DF(PC)
  242. 0B20FC 3F3C003C             MOVE.W #$3C,-(A7)
  243. 0B2100 4E41                 TRAP #1
  244. 0B2102 508F                 ADDQ.L #8,A7
  245. 0B2104 33C0000B2530         MOVE.W D0,$B2530
  246. 0B210A 3F3A0424             MOVE.W $B2530(PC),-(A7)
  247. 0B210E 3F3C0001             MOVE.W #1,-(A7)
  248. 0B2112 3F3C0046             MOVE.W #$46,-(A7)
  249. 0B2116 4E41                 TRAP #1
  250. 0B2118 5C8F                 ADDQ.L #6,A7
  251. 0B211A 363C00C8             MOVE.W #$C8,D3
  252. 0B211E 4BFA01B8             LEA $B22D8(PC),A5
  253. 0B2122 49FA03D0             LEA $B24F4(PC),A4
  254. 0B2126 47FA02E3             LEA $B240B(PC),A3
  255. 0B212A 610000DE             BSR $B220A
  256. 0B212E 38BC000A             MOVE.W #$A,(A4)
  257. 0B2132 397C00000002         MOVE.W #0,2(A4)
  258. 0B2138 397C00010004         MOVE.W #1,4(A4)
  259. 0B213E 397C00000006         MOVE.W #0,6(A4)
  260. 0B2144 397C00000008         MOVE.W #0,8(A4)
  261. 0B214A 61000178             BSR $B22C4
  262. 0B214E 610000BA             BSR $B220A
  263. 0B2152 38BC0023             MOVE.W #$23,(A4)
  264. 0B2156 397C00010002         MOVE.W #1,2(A4)
  265. 0B215C 397C00010004         MOVE.W #1,4(A4)
  266. 0B2162 397C00010006         MOVE.W #1,6(A4)
  267. 0B2168 397C00000008         MOVE.W #0,8(A4)
  268. 0B216E 41FA038E             LEA $B24FE(PC),A0
  269. 0B2172 33E80004000B2508     MOVE.W 4(A0),$B2508
  270. 0B217A 23FC000B24CB000B251C MOVE.L #$B24CB,$B251C
  271. 0B2184 6100013E             BSR $B22C4
  272. 0B2188 33FA0388000B2544     MOVE.W $B2512(PC),$B2544
  273. 0B2190 61000078             BSR $B220A
  274. 0B2194 23FC000B2534000B251C MOVE.L #$B2534,$B251C
  275. 0B219E 38BC0017             MOVE.W #$17,(A4)
  276. 0B21A2 397C00000002         MOVE.W #0,2(A4)
  277. 0B21A8 397C00010004         MOVE.W #1,4(A4)
  278. 0B21AE 397C00010006         MOVE.W #1,6(A4)
  279. 0B21B4 397C00000008         MOVE.W #0,8(A4)
  280. 0B21BA 61000108             BSR $B22C4
  281. 0B21BE 41FA0374             LEA $B2534(PC),A0
  282. 0B21C2 0C500028             CMPI.W #$28,(A0)
  283. 0B21C6 66D6                 BNE.S $B219E
  284. 0B21C8 30280008             MOVE.W 8(A0),D0
  285. 0B21CC B07A0376             CMP.W $B2544(PC),D0
  286. 0B21D0 66CC                 BNE.S $B219E
  287. 0B21D2 0C790005000B2532     CMPI.W #5,$B2532
  288. 0B21DA 67C2                 BEQ.S $B219E
  289. 0B21DC 6100002C             BSR $B220A
  290. 0B21E0 0C790005000B2532     CMPI.W #5,$B2532
  291. 0B21E8 6702                 BEQ.S $B21EC
  292. 0B21EA 60B2                 BRA.S $B219E
  293. 0B21EC 3F3A0342             MOVE.W $B2530(PC),-(A7)
  294. 0B21F0 3F3C003E             MOVE.W #$3E,-(A7)
  295. 0B21F4 4E41                 TRAP #1
  296. 0B21F6 588F                 ADDQ.L #4,A7
  297. 0B21F8 3F3C0001             MOVE.W #1,-(A7)
  298. 0B21FC 3F3A0332             MOVE.W $B2530(PC),-(A7)
  299. 0B2200 3F3C0046             MOVE.W #$46,-(A7)
  300. 0B2204 4E41                 TRAP #1
  301. 0B2206 5C8F                 ADDQ.L #6,A7
  302. 0B2208 6094                 BRA.S $B219E
  303. 0B220A 41FA020F             LEA $B241B(PC),A0
  304. 0B220E 610000BC             BSR $B22CC
  305. 0B2212 41FA00DC             LEA $B22F0(PC),A0
  306. 0B2216 303A031A             MOVE.W $B2532(PC),D0
  307. 0B221A E548                 LSL.W #2,D0
  308. 0B221C 20700000             MOVEA.L 0(A0,D0.W),A0
  309. 0B2220 610000AA             BSR $B22CC
  310. 0B2224 41FA0295             LEA $B24BB(PC),A0
  311. 0B2228 610000A2             BSR $B22CC
  312. 0B222C 41FA021D             LEA $B244B(PC),A0
  313. 0B2230 6100009A             BSR $B22CC
  314. 0B2234 41FA0285             LEA $B24BB(PC),A0
  315. 0B2238 61000092             BSR $B22CC
  316. 0B223C 41FA0245             LEA $B2483(PC),A0
  317. 0B2240 6100008A             BSR $B22CC
  318. 0B2244 7E00                 MOVEQ #0,D7
  319. 0B2246 7C04                 MOVEQ #4,D6
  320. 0B2248 41FA02FC             LEA $B2546(PC),A0
  321. 0B224C 2C4D                 MOVEA.L A5,A6
  322. 0B224E 3A3C0005             MOVE.W #5,D5
  323. 0B2252 303C000B             MOVE.W #$B,D0
  324. 0B2256 10FC0020             MOVE.B #$20,(A0)+
  325. 0B225A 51C8FFFA             DBRA D0,$B2256
  326. 0B225E 3007                 MOVE.W D7,D0
  327. 0B2260 0200000F             ANDI.B #$F,D0
  328. 0B2264 10330000             MOVE.B 0(A3,D0.W),D0
  329. 0B2268 10C0                 MOVE.B D0,(A0)+
  330. 0B226A 10FC003A             MOVE.B #$3A,(A0)+
  331. 0B226E 10FC0020             MOVE.B #$20,(A0)+
  332. 0B2272 3007                 MOVE.W D7,D0
  333. 0B2274 E348                 LSL.W #1,D0
  334. 0B2276 225E                 MOVEA.L (A6)+,A1
  335. 0B2278 30310000             MOVE.W 0(A1,D0.W),D0
  336. 0B227C 7403                 MOVEQ #3,D2
  337. 0B227E E958                 ROL.W #4,D0
  338. 0B2280 1200                 MOVE.B D0,D1
  339. 0B2282 0201000F             ANDI.B #$F,D1
  340. 0B2286 4881                 EXT.W D1
  341. 0B2288 12331000             MOVE.B 0(A3,D1.W),D1
  342. 0B228C 10C1                 MOVE.B D1,(A0)+
  343. 0B228E 51CAFFEE             DBRA D2,$B227E
  344. 0B2292 10FC0020             MOVE.B #$20,(A0)+
  345. 0B2296 10FC0020             MOVE.B #$20,(A0)+
  346. 0B229A 51CDFFC2             DBRA D5,$B225E
  347. 0B229E 10BC0000             MOVE.B #0,(A0)
  348. 0B22A2 41FA02A2             LEA $B2546(PC),A0
  349. 0B22A6 61000024             BSR $B22CC
  350. 0B22AA 41FA016F             LEA $B241B(PC),A0
  351. 0B22AE 6100001C             BSR $B22CC
  352. 0B22B2 06470001             ADDI.W #1,D7
  353. 0B22B6 51CEFF90             DBRA D6,$B2248
  354. 0B22BA 06790001000B2532     ADDI.W #1,$B2532
  355. 0B22C2 4E75                 RTS
  356. 0B22C4 220D                 MOVE.L A5,D1
  357. 0B22C6 3003                 MOVE.W D3,D0
  358. 0B22C8 4E42                 TRAP #2
  359. 0B22CA 4E75                 RTS
  360. 0B22CC 2F08                 MOVE.L A0,-(A7)
  361. 0B22CE 3F3C0009             MOVE.W #9,-(A7)
  362. 0B22D2 4E41                 TRAP #1
  363. 0B22D4 5C8F                 ADDQ.L #6,A7
  364. 0B22D6 4E75                 RTS
  365. 0B22D8 000B                 DC.W $B  
  366. 0B22DA 24F4000B             MOVE.L $B(A4,D0.W),(A2)+
  367. 0B22DE 24FE                 MOVE.L SR,(A2)+
  368. 0B22E0 000B                 DC.W $B  
  369. 0B22E2 2508                 MOVE.L A0,-(A2)
  370. 0B22E4 000B                 DC.W $B  
  371. 0B22E6 2512                 MOVE.L (A2),-(A2)
  372. 0B22E8 000B                 DC.W $B  
  373. 0B22EA 251C                 MOVE.L (A4)+,-(A2)
  374. 0B22EC 000B                 DC.W $B  
  375. 0B22EE 2526                 MOVE.L -(A6),-(A2)
  376. 0B22F0 000B                 DC.W $B  
  377. 0B22F2 2304                 MOVE.L D4,-(A1)
  378. 0B22F4 000B                 DC.W $B  
  379. 0B22F6 2329000B             MOVE.L $B(A1),-(A1)
  380. 0B22FA 2363000B             MOVE.L -(A3),$B(A1)
  381. 0B22FE 239E000B             MOVE.L (A6)+,$B(A1,D0.W)
  382. 0B2302 23D80D0A5445         MOVE.L (A0)+,$A5445
  383. 0B2308 5354                 SUBQ.W #1,(A4)
  384. 0B230A 2050                 MOVEA.L (A0),A0
  385. 0B230C 4F49                 DC.W $4F49 ;"OI"
  386. 0B230E 4E542030             LINK A4,#$2030
  387. 0B2312 3A20                 MOVE.W -(A0),D5
  388. 0B2314 4265                 CLR.W -(A5)
  389. 0B2316 666F                 BNE.S $B2387
  390. 0B2318 7265                 MOVEQ #$65,D1
  391. 0B231A 2061                 MOVEA.L -(A1),A0
  392. 0B231C 7070                 MOVEQ #$70,D0
  393. 0B231E 6C5F                 BGE.S $B237F
  394. 0B2320 696E                 BVS.S $B2390
  395. 0B2322 6974                 BVS.S $B2398
  396. 0B2324 0D0A0D0A             MOVEP.W $D0A(A2),D6
  397. 0B2328 000D                 DC.W $D  
  398. 0B232A 0A544553             EORI.W #$4553,(A4)
  399. 0B232E 5420                 ADDQ.B #2,-(A0)
  400. 0B2330 504F                 ADDQ.W #8,A7
  401. 0B2332 494E                 DC.W $494E ;"IN"
  402. 0B2334 5420                 ADDQ.B #2,-(A0)
  403. 0B2336 313A2041             MOVE.W $B4379(PC),-(A0)
  404. 0B233A 6674                 BNE.S $B23B0
  405. 0B233C 6572                 BCS.S $B23B0
  406. 0B233E 2061                 MOVEA.L -(A1),A0
  407. 0B2340 7070                 MOVEQ #$70,D0
  408. 0B2342 6C5F                 BGE.S $B23A3
  409. 0B2344 696E                 BVS.S $B23B4
  410. 0B2346 6974                 BVS.S $B23BC
  411. 0B2348 2C20                 MOVE.L -(A0),D6
  412. 0B234A 6265                 BHI.S $B23B1
  413. 0B234C 666F                 BNE.S $B23BD
  414. 0B234E 7265                 MOVEQ #$65,D1
  415. 0B2350 206D656E             MOVEA.L $656E(A5),A0
  416. 0B2354 755F                 DC.W $755F ;"u_"
  417. 0B2356 7265                 MOVEQ #$65,D1
  418. 0B2358 6769                 BEQ.S $B23C3
  419. 0B235A 7374                 DC.W $7374 ;"st"
  420. 0B235C 6572                 BCS.S $B23D0
  421. 0B235E 0D0A0D0A             MOVEP.W $D0A(A2),D6
  422. 0B2362 000D                 DC.W $D  
  423. 0B2364 0A544553             EORI.W #$4553,(A4)
  424. 0B2368 5420                 ADDQ.B #2,-(A0)
  425. 0B236A 504F                 ADDQ.W #8,A7
  426. 0B236C 494E                 DC.W $494E ;"IN"
  427. 0B236E 5420                 ADDQ.B #2,-(A0)
  428. 0B2370 323A2041             MOVE.W $B43B3(PC),D1
  429. 0B2374 6674                 BNE.S $B23EA
  430. 0B2376 6572                 BCS.S $B23EA
  431. 0B2378 206D656E             MOVEA.L $656E(A5),A0
  432. 0B237C 755F                 DC.W $755F ;"u_"
  433. 0B237E 7265                 MOVEQ #$65,D1
  434. 0B2380 6769                 BEQ.S $B23EB
  435. 0B2382 7374                 DC.W $7374 ;"st"
  436. 0B2384 6572                 BCS.S $B23F8
  437. 0B2386 2C20                 MOVE.L -(A0),D6
  438. 0B2388 6265                 BHI.S $B23EF
  439. 0B238A 666F                 BNE.S $B23FB
  440. 0B238C 7265                 MOVEQ #$65,D1
  441. 0B238E 2065                 MOVEA.L -(A5),A0
  442. 0B2390 766E                 MOVEQ #$6E,D3
  443. 0B2392 745F                 MOVEQ #$5F,D2
  444. 0B2394 6D65                 BLT.S $B23FB
  445. 0B2396 7361                 DC.W $7361 ;"sa"
  446. 0B2398 670D                 BEQ.S $B23A7
  447. 0B239A 0A0D                 DC.W $A0D  
  448. 0B239C 0A000D0A             EORI.B #$A,D0
  449. 0B23A0 5445                 ADDQ.W #2,D5
  450. 0B23A2 5354                 SUBQ.W #1,(A4)
  451. 0B23A4 2050                 MOVEA.L (A0),A0
  452. 0B23A6 4F49                 DC.W $4F49 ;"OI"
  453. 0B23A8 4E542033             LINK A4,#$2033
  454. 0B23AC 3A20                 MOVE.W -(A0),D5
  455. 0B23AE 496E                 DC.W $496E ;"In"
  456. 0B23B0 206D6573             MOVEA.L $6573(A5),A0
  457. 0B23B4 7361                 DC.W $7361 ;"sa"
  458. 0B23B6 6765                 BEQ.S $B241D
  459. 0B23B8 2068616E             MOVEA.L $616E(A0),A0
  460. 0B23BC 646C                 BCC.S $B242A
  461. 0B23BE 6572                 BCS.S $B2432
  462. 0B23C0 2C20                 MOVE.L -(A0),D6
  463. 0B23C2 6265                 BHI.S $B2429
  464. 0B23C4 666F                 BNE.S $B2435
  465. 0B23C6 7265                 MOVEQ #$65,D1
  466. 0B23C8 2065                 MOVEA.L -(A5),A0
  467. 0B23CA 766E                 MOVEQ #$6E,D3
  468. 0B23CC 745F                 MOVEQ #$5F,D2
  469. 0B23CE 6D65                 BLT.S $B2435
  470. 0B23D0 7361                 DC.W $7361 ;"sa"
  471. 0B23D2 670D                 BEQ.S $B23E1
  472. 0B23D4 0A0D                 DC.W $A0D  
  473. 0B23D6 0A000D0A             EORI.B #$A,D0
  474. 0B23DA 5445                 ADDQ.W #2,D5
  475. 0B23DC 5354                 SUBQ.W #1,(A4)
  476. 0B23DE 2050                 MOVEA.L (A0),A0
  477. 0B23E0 4F49                 DC.W $4F49 ;"OI"
  478. 0B23E2 4E542034             LINK A4,#$2034
  479. 0B23E6 3A20                 MOVE.W -(A0),D5
  480. 0B23E8 496E                 DC.W $496E ;"In"
  481. 0B23EA 206D6573             MOVEA.L $6573(A5),A0
  482. 0B23EE 7361                 DC.W $7361 ;"sa"
  483. 0B23F0 6765                 BEQ.S $B2457
  484. 0B23F2 2068616E             MOVEA.L $616E(A0),A0
  485. 0B23F6 646C                 BCC.S $B2464
  486. 0B23F8 6572                 BCS.S $B246C
  487. 0B23FA 2073                 DC.W $2073 ;" s"
  488. 0B23FC 6563                 BCS.S $B2461
  489. 0B23FE 6F6E                 BLE.S $B246E
  490. 0B2400 6420                 BCC.S $B2422
  491. 0B2402 7469                 MOVEQ #$69,D2
  492. 0B2404 6D65                 BLT.S $B246B
  493. 0B2406 0D0A0D0A             MOVEP.W $D0A(A2),D6
  494. 0B240A 0030                 DC.W $30  
  495. 0B240C 3132                 DC.W $3132 ;"12"
  496. 0B240E 3334                 DC.W $3334 ;"34"
  497. 0B2410 3536                 DC.W $3536 ;"56"
  498. 0B2412 37383941             MOVE.W $3941,-(A3)
  499. 0B2416 4243                 CLR.W D3
  500. 0B2418 4445                 NEG.W D5
  501. 0B241A 460D                 DC.W $460D  
  502. 0B241C 0A002020             EORI.B #$20,D0
  503. 0B2420 2020                 MOVE.L -(A0),D0
  504. 0B2422 2020                 MOVE.L -(A0),D0
  505. 0B2424 2020                 MOVE.L -(A0),D0
  506. 0B2426 2020                 MOVE.L -(A0),D0
  507. 0B2428 2020                 MOVE.L -(A0),D0
  508. 0B242A 2020                 MOVE.L -(A0),D0
  509. 0B242C 2020                 MOVE.L -(A0),D0
  510. 0B242E 2020                 MOVE.L -(A0),D0
  511. 0B2430 2020                 MOVE.L -(A0),D0
  512. 0B2432 2020                 MOVE.L -(A0),D0
  513. 0B2434 2020                 MOVE.L -(A0),D0
  514. 0B2436 2020                 MOVE.L -(A0),D0
  515. 0B2438 2020                 MOVE.L -(A0),D0
  516. 0B243A 2020                 MOVE.L -(A0),D0
  517. 0B243C 2020                 MOVE.L -(A0),D0
  518. 0B243E 4145                 DC.W $4145 ;"AE"
  519. 0B2440 5320                 SUBQ.B #1,-(A0)
  520. 0B2442 4152                 DC.W $4152 ;"AR"
  521. 0B2444 5241                 ADDQ.W #1,D1
  522. 0B2446 5953                 SUBQ.W #4,(A3)
  523. 0B2448 0D0A0043             MOVEP.W $43(A2),D6
  524. 0B244C 4F4E                 DC.W $4F4E ;"ON"
  525. 0B244E 5452                 ADDQ.W #2,(A2)
  526. 0B2450 4F4C                 DC.W $4F4C ;"OL"
  527. 0B2452 2020                 MOVE.L -(A0),D0
  528. 0B2454 474C                 DC.W $474C ;"GL"
  529. 0B2456 4F42                 DC.W $4F42 ;"OB"
  530. 0B2458 414C                 DC.W $414C ;"AL"
  531. 0B245A 2020                 MOVE.L -(A0),D0
  532. 0B245C 2049                 MOVEA.L A1,A0
  533. 0B245E 4E545F49             LINK A4,#$5F49
  534. 0B2462 4E20                 DC.W $4E20 ;"N "
  535. 0B2464 2020                 MOVE.L -(A0),D0
  536. 0B2466 494E                 DC.W $494E ;"IN"
  537. 0B2468 545F                 ADDQ.W #2,(A7)+
  538. 0B246A 4F55                 DC.W $4F55 ;"OU"
  539. 0B246C 5420                 ADDQ.B #2,-(A0)
  540. 0B246E 2041                 MOVEA.L D1,A0
  541. 0B2470 4444                 NEG.W D4
  542. 0B2472 525F                 ADDQ.W #1,(A7)+
  543. 0B2474 494E                 DC.W $494E ;"IN"
  544. 0B2476 2020                 MOVE.L -(A0),D0
  545. 0B2478 4144                 DC.W $4144 ;"AD"
  546. 0B247A 4452                 NEG.W (A2)
  547. 0B247C 5F4F                 SUBQ.W #7,A7
  548. 0B247E 5554                 SUBQ.W #2,(A4)
  549. 0B2480 0D0A002D             MOVEP.W $2D(A2),D6
  550. 0B2484 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  551. 0B2488 2D2D2020             MOVE.L $2020(A5),-(A6)
  552. 0B248C 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  553. 0B2490 2D2D2D20             MOVE.L $2D20(A5),-(A6)
  554. 0B2494 202D2D2D             MOVE.L $2D2D(A5),D0
  555. 0B2498 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  556. 0B249C 2020                 MOVE.L -(A0),D0
  557. 0B249E 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  558. 0B24A2 2D2D2D20             MOVE.L $2D20(A5),-(A6)
  559. 0B24A6 202D2D2D             MOVE.L $2D2D(A5),D0
  560. 0B24AA 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  561. 0B24AE 2020                 MOVE.L -(A0),D0
  562. 0B24B0 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  563. 0B24B4 2D2D2D2D             MOVE.L $2D2D(A5),-(A6)
  564. 0B24B8 0D0A0020             MOVEP.W $20(A2),D6
  565. 0B24BC 2020                 MOVE.L -(A0),D0
  566. 0B24BE 2020                 MOVE.L -(A0),D0
  567. 0B24C0 2020                 MOVE.L -(A0),D0
  568. 0B24C2 2020                 MOVE.L -(A0),D0
  569. 0B24C4 2020                 MOVE.L -(A0),D0
  570. 0B24C6 2000                 MOVE.L D0,D0
  571. 0B24C8 2020                 MOVE.L -(A0),D0
  572. 0B24CA 00202041             ORI.B #$41,-(A0)
  573. 0B24CE 6363                 BLS.S $B2533
  574. 0B24D0 6573                 BCS.S $B2545
  575. 0B24D2 736F                 DC.W $736F ;"so"
  576. 0B24D4 7279                 MOVEQ #$79,D1
  577. 0B24D6 2041                 MOVEA.L D1,A0
  578. 0B24D8 7272                 MOVEQ #$72,D1
  579. 0B24DA 6179                 BSR.S $B2555
  580. 0B24DC 7320                 DC.W $7320 ;"s "
  581. 0B24DE 00453A5C             ORI.W #$3A5C,D5
  582. 0B24E2 5052                 ADDQ.W #8,(A2)
  583. 0B24E4 475F                 DC.W $475F ;"G_"
  584. 0B24E6 385C                 MOVEA.W (A4)+,A4
  585. 0B24E8 5052                 ADDQ.W #8,(A2)
  586. 0B24EA 475F                 DC.W $475F ;"G_"
  587. 0B24EC 3841                 MOVEA.W D1,A4
  588. 0B24EE 522E4441             ADDQ.B #1,$4441(A6)
  589. 0B24F2 5400                 ADDQ.B #2,D0
  590. 0B24F4 00000000             ORI.B #0,D0
  591.  
  592. The section containing addresses 0B24F8 - 0B2A40 omitted.
  593.  
  594. 0B2A44 00000000             ORI.B #0,D0
  595. 0B2A48 00000000             ORI.B #0,D0
  596.   
  597.  
  598.      When the mouse arrow appears following disassembly, choose 
  599. the Reassembling option from the debugger menu.  Click on File: 
  600. and change the extension from DSM to ASM.  Click on the OK 
  601. button.  When the More Start Addresses dialog box appears, click 
  602. on the Quit button.  A flag will appear in place of the mouse 
  603. arrow until the reassembly is complete.  Figure 11.4 illustrates 
  604. the appearance of the Reassembling dialog box just before you 
  605. press the OK button; figure 11.5 is the reassembly listing, 
  606. somewhat abbreviated, with the repetitious portion omitted.
  607. Figure 11.4. Preparing the reassembling dialog box.
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625. Preparing the File for Printing
  626.  
  627.      Before I place the reassembly listing in this document, I 
  628. must remove certain characters that are not compatible with my 
  629. printer.  These are the characters following the semicolons on 
  630. the lines 148 through 169.  With TEMPUS, I remove the unwanted 
  631. character groups by typing ;* on the Search below string: line, 
  632. and by typing a blank space on the ... and replace by following 
  633. line.  I choose the whole text for the search region; start 
  634. search at cursor, with the cursor at the semicolon of the first 
  635. group; and selectable for the quantity option.  When the START 
  636. button is pressed, the cursor advances to each semicolon in turn, 
  637. stopping to permit a selection from the Search & Replace 
  638. selection dialog box.  I can then choose YES, NO or CANCEL as 
  639. desired.
  640.  
  641. Figure 11.5. The reassembly listing.
  642.  
  643.    1: K00001=0
  644.    2: K00003=$3C
  645.    3: K00004=1
  646.    4: K00006=$46
  647.    5: K00007=$C8
  648.    6: K0000C=$A
  649.    7: K0000D=2
  650.    8: K0000E=4
  651.    9: K0000F=6
  652.   10: K00010=8
  653.   11: K00012=$23
  654.   12: K0001A=$17
  655.   13: K0001B=$28
  656.   14: K0001D=5
  657.   15: K00020=$3E
  658.   16: K00028=$B
  659.   17: K00029=$20
  660.   18: K0002B=$F
  661.   19: K0002C=$3A
  662.   20: K0002D=3
  663.   21: K00031=9
  664.   22:  LEA L00000(PC),A7
  665.   23:  MOVE.W #K00001,-(A7)
  666.   24:  PEA L00002+1(PC)
  667.   25:  MOVE.W #K00003,-(A7)
  668.   26:  TRAP #K00004
  669.   27:  ADDQ.L #8,A7
  670.   28:  MOVE.W D0,L00005
  671.   29:  MOVE.W L00005(PC),-(A7)
  672.   30:  MOVE.W #K00004,-(A7)
  673.   31:  MOVE.W #K00006,-(A7)
  674.   32:  TRAP #K00004
  675.   33:  ADDQ.L #6,A7
  676.   34:  MOVE.W #K00007,D3
  677.   35:  LEA L00008(PC),A5
  678.   36:  LEA L00009(PC),A4
  679.   37:  LEA L0000A+1(PC),A3
  680.   38:  BSR L0000B
  681.   39:  MOVE.W #K0000C,(A4)
  682.   40:  MOVE.W #K00001,K0000D(A4)
  683.   41:  MOVE.W #K00004,K0000E(A4)
  684.   42:  MOVE.W #K00001,K0000F(A4)
  685.   43:  MOVE.W #K00001,K00010(A4)
  686.   44:  BSR L00011
  687.   45:  BSR L0000B
  688.   46:  MOVE.W #K00012,(A4)
  689.   47:  MOVE.W #K00004,K0000D(A4)
  690.   48:  MOVE.W #K00004,K0000E(A4)
  691.   49:  MOVE.W #K00004,K0000F(A4)
  692.   50:  MOVE.W #K00001,K00010(A4)
  693.   51:  LEA L00013(PC),A0
  694.   52:  MOVE.W K0000E(A0),L00014
  695.   53:  MOVE.L #L00015+1,L00016
  696.   54:  BSR L00011
  697.   55:  MOVE.W L00017(PC),L00018
  698.   56:  BSR L0000B
  699.   57:  MOVE.L #L00019,L00016
  700.   58: L0001C:MOVE.W #K0001A,(A4)
  701.   59:  MOVE.W #K00001,K0000D(A4)
  702.   60:  MOVE.W #K00004,K0000E(A4)
  703.   61:  MOVE.W #K00004,K0000F(A4)
  704.   62:  MOVE.W #K00001,K00010(A4)
  705.   63:  BSR L00011
  706.   64:  LEA L00019(PC),A0
  707.   65:  CMPI.W #K0001B,(A0)
  708.   66:  BNE.S L0001C
  709.   67:  MOVE.W K00010(A0),D0
  710.   68:  CMP.W L00018(PC),D0
  711.   69:  BNE.S L0001C
  712.   70:  CMPI.W #K0001D,L0001E
  713.   71:  BEQ.S L0001C
  714.   72:  BSR L0000B
  715.   73:  CMPI.W #K0001D,L0001E
  716.   74:  BEQ.S L0001F
  717.   75:  BRA.S L0001C
  718.   76: L0001F:MOVE.W L00005(PC),-(A7)
  719.   77:  MOVE.W #K00020,-(A7)
  720.   78:  TRAP #K00004
  721.   79:  ADDQ.L #4,A7
  722.   80:  MOVE.W #K00004,-(A7)
  723.   81:  MOVE.W L00005(PC),-(A7)
  724.   82:  MOVE.W #K00006,-(A7)
  725.   83:  TRAP #K00004
  726.   84:  ADDQ.L #6,A7
  727.   85:  BRA.S L0001C
  728.   86: L0000B:LEA L00021+1(PC),A0
  729.   87:  BSR L00022
  730.   88:  LEA L00023(PC),A0
  731.   89:  MOVE.W L0001E(PC),D0
  732.   90:  LSL.W #K0000D,D0
  733.   91:  MOVEA.L K00001(A0,D0.W),A0
  734.   92:  BSR L00022
  735.   93:  LEA L00024+1(PC),A0
  736.   94:  BSR L00022
  737.   95:  LEA L00025+1(PC),A0
  738.   96:  BSR L00022
  739.   97:  LEA L00024+1(PC),A0
  740.   98:  BSR L00022
  741.   99:  LEA L00026+1(PC),A0
  742.  100:  BSR L00022
  743.  101:  MOVEQ #K00001,D7
  744.  102:  MOVEQ #K0000E,D6
  745.  103: L00030:LEA L00027(PC),A0
  746.  104:  MOVEA.L A5,A6
  747.  105:  MOVE.W #K0001D,D5
  748.  106:  MOVE.W #K00028,D0
  749.  107: L0002A:MOVE.B #K00029,(A0)+
  750.  108:  DBRA D0,L0002A
  751.  109: L0002F:MOVE.W D7,D0
  752.  110:  ANDI.B #K0002B,D0
  753.  111:  MOVE.B K00001(A3,D0.W),D0
  754.  112:  MOVE.B D0,(A0)+
  755.  113:  MOVE.B #K0002C,(A0)+
  756.  114:  MOVE.B #K00029,(A0)+
  757.  115:  MOVE.W D7,D0
  758.  116:  LSL.W #K00004,D0
  759.  117:  MOVEA.L (A6)+,A1
  760.  118:  MOVE.W K00001(A1,D0.W),D0
  761.  119:  MOVEQ #K0002D,D2
  762.  120: L0002E:ROL.W #K0000E,D0
  763.  121:  MOVE.B D0,D1
  764.  122:  ANDI.B #K0002B,D1
  765.  123:  EXT.W D1
  766.  124:  MOVE.B K00001(A3,D1.W),D1
  767.  125:  MOVE.B D1,(A0)+
  768.  126:  DBRA D2,L0002E
  769.  127:  MOVE.B #K00029,(A0)+
  770.  128:  MOVE.B #K00029,(A0)+
  771.  129:  DBRA D5,L0002F
  772.  130:  MOVE.B #K00001,(A0)
  773.  131:  LEA L00027(PC),A0
  774.  132:  BSR L00022
  775.  133:  LEA L00021+1(PC),A0
  776.  134:  BSR L00022
  777.  135:  ADDI.W #K00004,D7
  778.  136:  DBRA D6,L00030
  779.  137:  ADDI.W #K00004,L0001E
  780.  138:  RTS
  781.  139: L00011:MOVE.L A5,D1
  782.  140:  MOVE.W D3,D0
  783.  141:  TRAP #K0000D
  784.  142:  RTS
  785.  143: L00022:MOVE.L A0,-(A7)
  786.  144:  MOVE.W #K00031,-(A7)
  787.  145:  TRAP #K00004
  788.  146:  ADDQ.L #6,A7
  789.  147:  RTS
  790.  148: L00008:DC.W K00028  
  791.  149:  DC.W $24F4  
  792.  150:  DC.W K00028  
  793.  151:  DC.W $24FE  
  794.  152:  DC.W K00028  
  795.  153:  DC.W $2508  
  796.  154:  DC.W K00028  
  797.  155:  DC.W $2512  
  798.  156:  DC.W K00028  
  799.  157:  DC.W $251C  
  800.  158:  DC.W K00028  
  801.  159:  DC.W $2526  
  802.  160: L00023:DC.W K00028  
  803.  161:  DC.W $2304  
  804.  162:  DC.W K00028  
  805.  163:  DC.W $2329  
  806.  164:  DC.W K00028  
  807.  165:  DC.W $2363  
  808.  166:  DC.W K00028  
  809.  167:  DC.W $239E  
  810.  168:  DC.W K00028  
  811.  169:  DC.W $23D8  
  812.  170:  DC.W $D0A ;">CR<>LF<"
  813.  171:  DC.W $5445 ;"TE"
  814.  172:  DC.W $5354 ;"ST"
  815.  173:  DC.W $2050 ;" P"
  816.  174:  DC.W $4F49 ;"OI"
  817.  175:  DC.W $4E54 ;"NT"
  818.  176:  DC.W $2030 ;" 0"
  819.  177:  DC.W $3A20 ;": "
  820.  178:  DC.W $4265 ;"Be"
  821.  179:  DC.W $666F ;"fo"
  822.  180:  DC.W $7265 ;"re"
  823.  181:  DC.W $2061 ;" a"
  824.  182:  DC.W $7070 ;"pp"
  825.  183:  DC.W $6C5F ;"l_"
  826.  184:  DC.W $696E ;"in"
  827.  185:  DC.W $6974 ;"it"
  828.  186:  DC.W $D0A ;">CR<>LF<"
  829.  187:  DC.W $D0A ;">CR<>LF<"
  830.  188:  DC.W $D ;">0<>CR<"
  831.  189:  DC.W $A54 ;">LF<T"
  832.  190:  DC.W $4553 ;"ES"
  833.  191:  DC.W $5420 ;"T "
  834.  192:  DC.W $504F ;"PO"
  835.  193:  DC.W $494E ;"IN"
  836.  194:  DC.W $5420 ;"T "
  837.  195:  DC.W $313A ;"1:"
  838.  196:  DC.W $2041 ;" A"
  839.  197:  DC.W $6674 ;"ft"
  840.  198:  DC.W $6572 ;"er"
  841.  199:  DC.W $2061 ;" a"
  842.  200:  DC.W $7070 ;"pp"
  843.  201:  DC.W $6C5F ;"l_"
  844.  202:  DC.W $696E ;"in"
  845.  203:  DC.W $6974 ;"it"
  846.  204:  DC.W $2C20 ;", "
  847.  205:  DC.W $6265 ;"be"
  848.  206:  DC.W $666F ;"fo"
  849.  207:  DC.W $7265 ;"re"
  850.  208:  DC.W $206D ;" m"
  851.  209:  DC.W $656E ;"en"
  852.  210:  DC.W $755F ;"u_"
  853.  211:  DC.W $7265 ;"re"
  854.  212:  DC.W $6769 ;"gi"
  855.  213:  DC.W $7374 ;"st"
  856.  214:  DC.W $6572 ;"er"
  857.  215:  DC.W $D0A ;">CR<>LF<"
  858.  216:  DC.W $D0A ;">CR<>LF<"
  859.  217:  DC.W $D ;">0<>CR<"
  860.  218:  DC.W $A54 ;">LF<T"
  861.  219:  DC.W $4553 ;"ES"
  862.  220:  DC.W $5420 ;"T "
  863.  221:  DC.W $504F ;"PO"
  864.  222:  DC.W $494E ;"IN"
  865.  223:  DC.W $5420 ;"T "
  866.  224:  DC.W $323A ;"2:"
  867.  225:  DC.W $2041 ;" A"
  868.  226:  DC.W $6674 ;"ft"
  869.  227:  DC.W $6572 ;"er"
  870.  228:  DC.W $206D ;" m"
  871.  229:  DC.W $656E ;"en"
  872.  230:  DC.W $755F ;"u_"
  873.  231:  DC.W $7265 ;"re"
  874.  232:  DC.W $6769 ;"gi"
  875.  233:  DC.W $7374 ;"st"
  876.  234:  DC.W $6572 ;"er"
  877.  235:  DC.W $2C20 ;", "
  878.  236:  DC.W $6265 ;"be"
  879.  237:  DC.W $666F ;"fo"
  880.  238:  DC.W $7265 ;"re"
  881.  239:  DC.W $2065 ;" e"
  882.  240:  DC.W $766E ;"vn"
  883.  241:  DC.W $745F ;"t_"
  884.  242:  DC.W $6D65 ;"me"
  885.  243:  DC.W $7361 ;"sa"
  886.  244:  DC.W $670D ;"g>CR<"
  887.  245:  DC.W $A0D ;">LF<>CR<"
  888.  246:  DC.W $A00 ;">LF<>0<"
  889.  247:  DC.W $D0A ;">CR<>LF<"
  890.  248:  DC.W $5445 ;"TE"
  891.  249:  DC.W $5354 ;"ST"
  892.  250:  DC.W $2050 ;" P"
  893.  251:  DC.W $4F49 ;"OI"
  894.  252:  DC.W $4E54 ;"NT"
  895.  253:  DC.W $2033 ;" 3"
  896.  254:  DC.W $3A20 ;": "
  897.  255:  DC.W $496E ;"In"
  898.  256:  DC.W $206D ;" m"
  899.  257:  DC.W $6573 ;"es"
  900.  258:  DC.W $7361 ;"sa"
  901.  259:  DC.W $6765 ;"ge"
  902.  260:  DC.W $2068 ;" h"
  903.  261:  DC.W $616E ;"an"
  904.  262:  DC.W $646C ;"dl"
  905.  263:  DC.W $6572 ;"er"
  906.  264:  DC.W $2C20 ;", "
  907.  265:  DC.W $6265 ;"be"
  908.  266:  DC.W $666F ;"fo"
  909.  267:  DC.W $7265 ;"re"
  910.  268:  DC.W $2065 ;" e"
  911.  269:  DC.W $766E ;"vn"
  912.  270:  DC.W $745F ;"t_"
  913.  271:  DC.W $6D65 ;"me"
  914.  272:  DC.W $7361 ;"sa"
  915.  273:  DC.W $670D ;"g>CR<"
  916.  274:  DC.W $A0D ;">LF<>CR<"
  917.  275:  DC.W $A00 ;">LF<>0<"
  918.  276:  DC.W $D0A ;">CR<>LF<"
  919.  277:  DC.W $5445 ;"TE"
  920.  278:  DC.W $5354 ;"ST"
  921.  279:  DC.W $2050 ;" P"
  922.  280:  DC.W $4F49 ;"OI"
  923.  281:  DC.W $4E54 ;"NT"
  924.  282:  DC.W $2034 ;" 4"
  925.  283:  DC.W $3A20 ;": "
  926.  284:  DC.W $496E ;"In"
  927.  285:  DC.W $206D ;" m"
  928.  286:  DC.W $6573 ;"es"
  929.  287:  DC.W $7361 ;"sa"
  930.  288:  DC.W $6765 ;"ge"
  931.  289:  DC.W $2068 ;" h"
  932.  290:  DC.W $616E ;"an"
  933.  291:  DC.W $646C ;"dl"
  934.  292:  DC.W $6572 ;"er"
  935.  293:  DC.W $2073 ;" s"
  936.  294:  DC.W $6563 ;"ec"
  937.  295:  DC.W $6F6E ;"on"
  938.  296:  DC.W $6420 ;"d "
  939.  297:  DC.W $7469 ;"ti"
  940.  298:  DC.W $6D65 ;"me"
  941.  299:  DC.W $D0A ;">CR<>LF<"
  942.  300:  DC.W $D0A ;">CR<>LF<"
  943.  301: L0000A:DC.W $30 ;">0<0"
  944.  302:  DC.W $3132 ;"12"
  945.  303:  DC.W $3334 ;"34"
  946.  304:  DC.W $3536 ;"56"
  947.  305:  DC.W $3738 ;"78"
  948.  306:  DC.W $3941 ;"9A"
  949.  307:  DC.W $4243 ;"BC"
  950.  308:  DC.W $4445 ;"DE"
  951.  309: L00021:DC.W $460D ;"F>CR<"
  952.  310:  DC.W $A00 ;">LF<>0<"
  953.  311:  DC.W $2020 ;"  "
  954.  312:  DC.W $2020 ;"  "
  955.  313:  DC.W $2020 ;"  "
  956.  314:  DC.W $2020 ;"  "
  957.  315:  DC.W $2020 ;"  "
  958.  316:  DC.W $2020 ;"  "
  959.  317:  DC.W $2020 ;"  "
  960.  318:  DC.W $2020 ;"  "
  961.  319:  DC.W $2020 ;"  "
  962.  320:  DC.W $2020 ;"  "
  963.  321:  DC.W $2020 ;"  "
  964.  322:  DC.W $2020 ;"  "
  965.  323:  DC.W $2020 ;"  "
  966.  324:  DC.W $2020 ;"  "
  967.  325:  DC.W $2020 ;"  "
  968.  326:  DC.W $2020 ;"  "
  969.  327:  DC.W $4145 ;"AE"
  970.  328:  DC.W $5320 ;"S "
  971.  329:  DC.W $4152 ;"AR"
  972.  330:  DC.W $5241 ;"RA"
  973.  331:  DC.W $5953 ;"YS"
  974.  332:  DC.W $D0A ;">CR<>LF<"
  975.  333: L00025:DC.W $43 ;">0<C"
  976.  334:  DC.W $4F4E ;"ON"
  977.  335:  DC.W $5452 ;"TR"
  978.  336:  DC.W $4F4C ;"OL"
  979.  337:  DC.W $2020 ;"  "
  980.  338:  DC.W $474C ;"GL"
  981.  339:  DC.W $4F42 ;"OB"
  982.  340:  DC.W $414C ;"AL"
  983.  341:  DC.W $2020 ;"  "
  984.  342:  DC.W $2049 ;" I"
  985.  343:  DC.W $4E54 ;"NT"
  986.  344:  DC.W $5F49 ;"_I"
  987.  345:  DC.W $4E20 ;"N "
  988.  346:  DC.W $2020 ;"  "
  989.  347:  DC.W $494E ;"IN"
  990.  348:  DC.W $545F ;"T_"
  991.  349:  DC.W $4F55 ;"OU"
  992.  350:  DC.W $5420 ;"T "
  993.  351:  DC.W $2041 ;" A"
  994.  352:  DC.W $4444 ;"DD"
  995.  353:  DC.W $525F ;"R_"
  996.  354:  DC.W $494E ;"IN"
  997.  355:  DC.W $2020 ;"  "
  998.  356:  DC.W $4144 ;"AD"
  999.  357:  DC.W $4452 ;"DR"
  1000.  358:  DC.W $5F4F ;"_O"
  1001.  359:  DC.W $5554 ;"UT"
  1002.  360:  DC.W $D0A ;">CR<>LF<"
  1003.  361: L00026:DC.W $2D ;">0<-"
  1004.  362:  DC.W $2D2D ;"--"
  1005.  363:  DC.W $2D2D ;"--"
  1006.  364:  DC.W $2D2D ;"--"
  1007.  365:  DC.W $2020 ;"  "
  1008.  366:  DC.W $2D2D ;"--"
  1009.  367:  DC.W $2D2D ;"--"
  1010.  368:  DC.W $2D2D ;"--"
  1011.  369:  DC.W $2D20 ;"- "
  1012.  370:  DC.W $202D ;" -"
  1013.  371:  DC.W $2D2D ;"--"
  1014.  372:  DC.W $2D2D ;"--"
  1015.  373:  DC.W $2D2D ;"--"
  1016.  374:  DC.W $2020 ;"  "
  1017.  375:  DC.W $2D2D ;"--"
  1018.  376:  DC.W $2D2D ;"--"
  1019.  377:  DC.W $2D2D ;"--"
  1020.  378:  DC.W $2D20 ;"- "
  1021.  379:  DC.W $202D ;" -"
  1022.  380:  DC.W $2D2D ;"--"
  1023.  381:  DC.W $2D2D ;"--"
  1024.  382:  DC.W $2D2D ;"--"
  1025.  383:  DC.W $2020 ;"  "
  1026.  384:  DC.W $2D2D ;"--"
  1027.  385:  DC.W $2D2D ;"--"
  1028.  386:  DC.W $2D2D ;"--"
  1029.  387:  DC.W $2D2D ;"--"
  1030.  388:  DC.W $D0A ;">CR<>LF<"
  1031.  389: L00024:DC.W K00029 ;">0< "
  1032.  390:  DC.W $2020 ;"  "
  1033.  391:  DC.W $2020 ;"  "
  1034.  392:  DC.W $2020 ;"  "
  1035.  393:  DC.W $2020 ;"  "
  1036.  394:  DC.W $2020 ;"  "
  1037.  395:  DC.W $2000 ;" >0<"
  1038.  396:  DC.W $2020 ;"  "
  1039.  397: L00015:DC.W K00029 ;">0< "
  1040.  398:  DC.W $2041 ;" A"
  1041.  399:  DC.W $6363 ;"cc"
  1042.  400:  DC.W $6573 ;"es"
  1043.  401:  DC.W $736F ;"so"
  1044.  402:  DC.W $7279 ;"ry"
  1045.  403:  DC.W $2041 ;" A"
  1046.  404:  DC.W $7272 ;"rr"
  1047.  405:  DC.W $6179 ;"ay"
  1048.  406:  DC.W $7320 ;"s "
  1049.  407: L00002:DC.W $45 ;">0<E"
  1050.  408:  DC.W $3A5C ;":\"
  1051.  409:  DC.W $5052 ;"PR"
  1052.  410:  DC.W $475F ;"G_"
  1053.  411:  DC.W $385C ;"8\"
  1054.  412:  DC.W $5052 ;"PR"
  1055.  413:  DC.W $475F ;"G_"
  1056.  414:  DC.W $3841 ;"8A"
  1057.  415:  DC.W $522E ;"R."
  1058.  416:  DC.W $4441 ;"DA"
  1059.  417:  DC.W $5400 ;"T>0<"
  1060.  418: L00009:DC.W K00001
  1061.  419:  DC.W K00001
  1062.  420:  DC.W K00001
  1063.  421:  DC.W K00001
  1064.  422:  DC.W K00001
  1065.  423: L00013:DC.W K00001
  1066.  424:  DC.W K00001
  1067.  425:  DC.W K00001
  1068.  426:  DC.W K00001
  1069.  427:  DC.W K00001
  1070.  428: L00014:DC.W K00001
  1071.  429:  DC.W K00001
  1072.  430:  DC.W K00001
  1073.  431:  DC.W K00001
  1074.  432:  DC.W K00001
  1075.  433: L00017:DC.W K00001
  1076.  434:  DC.W K00001
  1077.  435:  DC.W K00001
  1078.  436:  DC.W K00001
  1079.  437:  DC.W K00001
  1080.  438: L00016:DC.W K00001
  1081.  439:  DC.W K00001
  1082.  440:  DC.W K00001
  1083.  441:  DC.W K00001
  1084.  442:  DC.W K00001
  1085.  443:  DC.W K00001
  1086.  444:  DC.W K00001
  1087.  445:  DC.W K00001
  1088.  446:  DC.W K00001
  1089.  447:  DC.W K00001
  1090.  448: L00005:DC.W K00001
  1091.  449: L0001E:DC.W K00001
  1092.  450: L00019:DC.W K00001
  1093.  451:  DC.W K00001
  1094.  452:  DC.W K00001
  1095.  453:  DC.W K00001
  1096.  454:  DC.W K00001
  1097.  455:  DC.W K00001
  1098.  456:  DC.W K00001
  1099.  457:  DC.W K00001
  1100.  458: L00018:DC.W K00001
  1101.  459: L00027:DC.W K00001
  1102.  460:  DC.W K00001
  1103.  
  1104.        Lines 461 - 1097 omitted to conserve space. 
  1105.  
  1106. 1098:  DC.W K00001
  1107. 1099: L00000:DC.W K00001
  1108. 1100:  DC.W K00001
  1109. 1101:  END
  1110.  
  1111.  
  1112.      If you have the TEMPUS editor, you should exit AssemPro and 
  1113. load the disassembly file into one window, then load the 
  1114. reassembly file into another.  Then you can choose the underneath 
  1115. option to observe both files simultaneously.  Alternately, you 
  1116. can use a word processor such as 1st Word Plus; otherwise, you 
  1117. will have to work with the files individually, but I intend to 
  1118. proceed with the discussion as if you are able to view both files 
  1119. simultaneously.  Do not attempt to print either of the files on 
  1120. your printer yet.
  1121.  
  1122. Compressing the Reassembly Listing
  1123.  
  1124.      The particular example that I am using provides a reassembly 
  1125. listing that is easily reworked.  Other programs do not.  
  1126. Regardless of the its condition, the reassembly listing is 
  1127. usually the one that is altered so that it becomes a source 
  1128. program; however, the disassembly listing provides visual 
  1129. information that is sometimes obscured in the reassembly listing.  
  1130. As an example of the difference in information content of the 
  1131. listings, notice that virtually every number in the reassembly 
  1132. listing has been replaced by a constant identifier.  We must 
  1133. change every one of those back to the original numbers so that we 
  1134. can see what it is that the program does.  We can do that as we 
  1135. go along, or we can replace them all at once with the editor's 
  1136. replace function.  Initially, I prefer to make changes 
  1137. individually until I know it is safe to perform a mass replace.  
  1138. Notice also that most of the addresses in the reassembly listing 
  1139. have been converted to labels.  There is a list of the constant 
  1140. identifiers and their values at the beginning of the reassembly 
  1141. listing, but it is sometimes easier to refer to the disassembly 
  1142. listing to obtain those values.
  1143.  
  1144.      As the first instruction in the reassembly listing, you can 
  1145. see that the address of label L00000 is being loaded into 
  1146. register A7.  That means, of course, that L00000 is the AssemPro 
  1147. generated label for the stack.  If you run down the listing to 
  1148. L00000, you will see that it is the last label in the program, 
  1149. and you will see that it is preceded by a long list of DC.W 
  1150. K00001 pseudo ops.  If you now run up to the K00001 declaration 
  1151. at the top of the listing, you will see that K00001 is the 
  1152. identifier for the quantity 0.
  1153.  
  1154.      Now run back down to L00000, then carefully run back up to 
  1155. the next label, which is L00027.  All of the DC.W 0 pseudo ops 
  1156. between L00027 and L00000 are bss declarations in the original 
  1157. program.  Unfortunately, AssemPro does not differentiate between 
  1158. data and bss declarations when it generates the reassembly 
  1159. listing.  But that's ok; we can find out where we are by 
  1160. referring to the disassembly listing and the information in the 
  1161. basepage.  Now, what we don't know is how many of those DC.W 0 
  1162. declarations belong to L00027 and how many belong to L00000.  
  1163. That's ok too, because it doesn't matter; in the source program, 
  1164. the space reserved was only cosmetically separated.  The 
  1165. declarations in the original program would have had to have been 
  1166. similar to that shown below.
  1167.  
  1168.                     L00027: ds.l xxx
  1169.                             ds.l yyy
  1170.                     L00000: ds.l zzz
  1171.  
  1172. where the space reserved by xxx and that reserved by yyy would 
  1173. have been inseparable anyway.
  1174.  
  1175.      All that we need is the total space reserved in the original 
  1176. program.  That can be calculated thus: L00027 is at line number 
  1177. 459 in the listing, and there is a DC.W 0 declared there; L00000 
  1178. is at line number 1099 in the listing, and there is a DC.W 0 
  1179. declared there also, but we don't count that one--we only want 
  1180. those declared from L00027 to L00000 (Refer to the model above.  
  1181. We desire the sum of xxx and yyy.).  Subtracting 459 from 1099 
  1182. yields 640 (that's declared words), which is 320 longwords.
  1183.  
  1184.      Since we don't know what portion of this declaration to 
  1185. allocate to each label, and since it doesn't matter anyway, we 
  1186. can just split the amount between them, and we can delete all of 
  1187. the DC.W K00001 declarations from L00027 to L00000.  And since we 
  1188. can determine that there are no other references to the label 
  1189. L00000 within the program simply by searching for that label, we 
  1190. can change the reference in the first instruction and the label 
  1191. itself to stack.  After the alteration, the declarations would 
  1192. appear as shown below.
  1193.  
  1194.                    L00027: ds.l 160          ds.l 160
  1195.                    stack:  ds.l   1
  1196.  
  1197. Notice that I use lower case letters to indicate items which have 
  1198. been altered.  Notice also that I have declared a single longword 
  1199. at the stack label, as is indicated in the reassembly listing, 
  1200. even though we know that in the original program ds.l 0 was used.  
  1201. That can always be changed later if to do so is desirable.  
  1202. Finally, notice that we have reduced the number of lines in the 
  1203. listing from 1101 to 462.
  1204.  
  1205.      If we had no hint about the output of the program, we could 
  1206. simply return to the top of the listing and begin to decipher 
  1207. instructions linearly.  But we are able to execute the program 
  1208. and obtain output in a file.  Furthermore, we know that the 
  1209. program is a desk accessory, so we know a great deal about the 
  1210. types of instructions within the text segment and something about 
  1211. the declarations in the data segment.  With all of this 
  1212. knowledge, and with the help of the ASCII characters that are 
  1213. present, we can begin to reconstruct the data segment of the 
  1214. program.  That activity will permit the most rapid reduction in 
  1215. listing size.
  1216.  
  1217.      As you run up the listing from L00027, past L0000A, to label 
  1218. L00023, notice that there are no labels at locations we might 
  1219. expect them to be if we refer to the original listing in chapter 
  1220. 10.  That's because the labels zero, one, two, three and four 
  1221. were referenced indirectly within the program.  Their locations 
  1222. were stored in pointer array test_header, and the address of 
  1223. test_header was stored in an address register.  Without knowledge 
  1224. of the original listing, we would discover that as we work 
  1225. through the conversion.  Still, we can work with the data 
  1226. declarations and insert the labels as we discover their 
  1227. locations.
  1228.  
  1229.      Starting at line 170 of the listing and continuing through 
  1230. line 417, referring to the program's output and to an ASCII table 
  1231. when necessary, we reconstruct the data section as shown in the 
  1232. listing in figure 11.6.  We can assume that the carriage 
  1233. return/linefeed declared at line 170 is part of the declaration 
  1234. at line 171 because there is no null character between the two 
  1235. lines.  At line 188, you can see how the null character would be 
  1236. declared; there, note the ">0<>CR<" following the semicolon.  The 
  1237. >0< indicates the null character.  The $D for the carriage return 
  1238. follows the null character at that location.  The CR, LF and T 
  1239. mark the beginning of a new declaration.
  1240.  
  1241. Figure 11.6. Partially reconstructed data section.
  1242.  
  1243.  dc.b $D,$A,'TEST POINT 0: Before appl_init',$D,$A,$D,$A,0
  1244.  dc.b $D,$A,'TEST POINT 1: After appl_init, before menu_register',$D,$A,$D,$A,0
  1245.  dc.b $D,$A,'TEST POINT 2: After menu_register, before evnt_mesag',$D,$A,$D,$A,0
  1246.  dc.b $D,$A,'TEST POINT 3: In message handler, before evnt_mesag',$D,$A,$D,$A,0
  1247.  dc.b $D,$A,'TEST POINT 4: In message handler second time',$D,$A,$D,$A,0
  1248.  
  1249. L0000A:   dc.b '0123456789ABCDEF' 
  1250. L00021+1: dc.b $D,$A,0 
  1251.  dc.b '                                AES ARRAYS',$D,$A,0
  1252.   
  1253. L00025+1:
  1254.  dc.b 'CONTROL  GLOBAL  INT_IN  INT_OUT  ADDR_IN  ADDR_OUT',$D,$A,0
  1255. L00026+1
  1256.  dc.b '_______  ______  ______  _______  _______  ________',$D,$A,0  
  1257. L00024+1:
  1258.  dc.b '            ',$D,$A,0
  1259.  dc.b '  ',$D,$A,0
  1260. L00015+1:
  1261.  dc.b '  Accessory Arrays ',0
  1262. L00002+1:
  1263.  dc.b 'E:\PRG_8\PRG_8AR.DAT',0
  1264.  
  1265.   
  1266.      As we reconstruct the data segment of the program, we use 
  1267. dc.b pseudo ops to declare strings, not the dc.w pseudo ops.  At 
  1268. line 309, note that the character F, which is part of the 
  1269. declaration above L00021, has been combined with the declaration 
  1270. at L00021.  This occurred because a null character was not placed 
  1271. after the hex_table string in the original program (Remember the 
  1272. assumption made in the paragraph above--it could be wrong.).  
  1273. This fact would become evident as we work through the reassembly 
  1274. listing because there are no references to L00021 within the 
  1275. listing, but L00021+1 is referenced.  You can verify this by 
  1276. searching through the listing for references to L00021.  An 
  1277. explanation is provided in the last paragraph on page 105 of the 
  1278. AssemPro manual.  The Label+1  phenomenon occurs whenever 
  1279. AssemPro must create a label at an odd address.  We can handle 
  1280. this by changing L00021 to L00021+1 at line 309 and by placing 
  1281. the F character in the string to which it belongs.
  1282.  
  1283.      Concerning the hex string declaration, the pseudo op at line 
  1284. 301 is L0000A:DC.W $30 ;">0<0".  This declares a null character 
  1285. followed by a 0.  If we take the time to search for references to 
  1286. L0000A within the listing, we find that there are none.  But 
  1287. L0000A+1 is referenced at line 37.  There, the address of the 
  1288. table is loaded into A3.  We can easily infer that an adjustment 
  1289. is in order.  We can change the L0000A+1 to L0000A and declare 
  1290. the table as it should be.
  1291.  
  1292.      As it is with L00021, there is no direct reference to 
  1293. L00025, but L00025+1 is referenced, so we handle line 333 as we 
  1294. did line 309.  L00026 at line 361 is changed to L00026+1.  At 
  1295. line 389, L00024 is changed to L00024+1; and note that the 
  1296. constant K00029 at that location is just $20, the ASCII code for 
  1297. a space.  Note also that a null character precedes the space.  At 
  1298. line 396 two spaces are declared, following the null on line 395, 
  1299. and preceding the null on line 396.  The space following the null 
  1300. on line 396 is part of the L00015+1 declaration "  Accessory 
  1301. Arrays ".  L00002 at line 407 must be changed to L00002+1, and we 
  1302. readily observe a file name and directory path at that location.
  1303.  
  1304.      We can now begin converting statements from the top of the 
  1305. listing, using the disassembly listing and the list of constant 
  1306. identifiers to fill in numeric values, and referring to the 
  1307. appropriate reference books to identify functions.  The most 
  1308. prominent candidates for immediate conversion are the trap 
  1309. numbers.  At each TRAP word, simply exchange the constant 
  1310. identifier for the constant itself.  Then, at each location of a 
  1311. trap invocation, replace all constant identifiers with constants.  
  1312. As each function is identified, replace the appropriate label 
  1313. references within the invocation and at their site if possible.  
  1314. Above each function invocation, place a suitable label to 
  1315. describe the function.  After doing this for the first two 
  1316. functions, they would appear as shown in figure 11.7.
  1317.  
  1318.   Figure 11.7. First two functions of the listing.
  1319.  
  1320.               create_file:
  1321.                lea        stack(pc), sp
  1322.                move.w     #0, -(sp)
  1323.                pea        filename(pc)
  1324.                move.w     #$3C, -(sp)
  1325.                trap       #1
  1326.                addq.l     #8, sp
  1327.                move.w     d0, file_handle
  1328.  
  1329.               redirect_output:
  1330.                move.w     file_handle(pc), -(sp)
  1331.                move.w     #1, -(sp)
  1332.                move.w     #$46, -(sp)
  1333.                trap       #1
  1334.                addq.l     #6, sp
  1335.   
  1336.        
  1337.      As the alterations shown in figure 11.7 are made, L00002+1 
  1338. must be changed to filename at the label's site, as must L00005 
  1339. be changed to file_handle.  As we are making the file_handle 
  1340. exchange for L00005, we should notice that the program can be 
  1341. improved by pushing d0 onto the stack in the redirect_output 
  1342. function instead of pushing the variable file_handle, as was done 
  1343. in the original program; but, at this time, we should simply 
  1344. place a note in the listing to which attention can be directed 
  1345. later.  We want to suppress improvements until we have confirmed 
  1346. the accuracy of the machine language to assembly language 
  1347. conversion.  Don't forget to declare the ds.w 1 at the 
  1348. file_handle label site.
  1349.  
  1350.      As the first two functions are being transformed, the labels 
  1351. that are replaced there and at the label sites must also be 
  1352. replaced at all referencing locations.  That activity would lead 
  1353. to the transformation of the two functions that exist at the 
  1354. L0001F label site.  Those two transformed functions are shown in 
  1355. figure 11.8.  Don't forget to alter all references to L0001F when 
  1356. it is changed to close_file.
  1357.  
  1358. Figure 11.8. Two more functions disclosed.
  1359.  
  1360.            beq.s      close_file
  1361.            BRA.S L0001C
  1362.  
  1363.           close_file:
  1364.            move.w     file_handle(pc), -(sp)
  1365.            move.w     #$3E, -(sp)
  1366.            trap       #1
  1367.            addq.l     #4, sp
  1368.  
  1369.           _redirect_output:
  1370.            move.w     #1, -(sp)
  1371.            move.w     file_handle(pc), -(sp)
  1372.            move.w     #$46, -(sp)
  1373.            trap       #1
  1374.            addq.l     #6, sp
  1375.  
  1376.      The two program statements following the functions shown in 
  1377. figure 11.8 will lead us to a trap #2 subroutine.  The first 
  1378. statement stores $C8, the AES call number in register D3; the 
  1379. second statement stores the address of a label in A5.  Searching 
  1380. for all references to A5, eventually leads us to L00011 at which 
  1381. the trap #2 invocation resides.  The very structure of the 
  1382. subroutine identifies it as the AES call.  Thus we are able to 
  1383. identify L00008 as the label for the aes_pb.  And, when all of 
  1384. the constant identifiers residing just below the BSR L0000B 
  1385. statement are replaced by the respective constants; and after 
  1386. observing the BSR L00011 statement just below those replaced 
  1387. constants, we can be sure that the address of the label being 
  1388. loaded into register A4 must be that of the array control.  
  1389. Therefore, each BSR L00011 can be changed to bsr aes, each 
  1390. reference to L00008 can be changed to a reference to aes_pb and 
  1391. each reference to L00009 can be changed to a reference to 
  1392. control.  Control can be declared as a five word array thus: ds.w 
  1393. 5.
  1394.  
  1395.      At this point, we are unable to clearly identify references 
  1396. to the other five AES structures within the reassembly listing; 
  1397. but we do know the order in which their addresses must be stored 
  1398. in the aes_pb structure; therefore, using the disassembly listing 
  1399. as a guide, we can obtain the address of aes_pb as that which is 
  1400. being loaded into A5 at line 16, and at that location we can 
  1401. obtain the addresses of the other structures.  At those addresses 
  1402. we will be able to determine both the amount of space reserved 
  1403. for each array and the relative positions of those declarations 
  1404. within the program.  We then possess the required information to 
  1405. declare the structures within the reassembly listing.  See figure 
  1406. 11.9, which shows the relevant parts of the disassembly listing.  
  1407. At address $B22D8, we can see the disassembly listing address of 
  1408. each of the structures in question.
  1409.  
  1410. Figure 11.9. Relevant portions of the disassembly 
  1411. listing.
  1412.  
  1413. 0B211A 363C00C8             MOVE.W #$C8,D3
  1414.  
  1415. 0B211E 4BFA01B8             LEA $B22D8(PC),A5
  1416.  
  1417. 0B2122 49FA03D0             LEA $B24F4(PC),A4
  1418.  
  1419. 0B22D6 4E75                 RTS
  1420.  
  1421. 0B22D8 000B                 DC.W $B  
  1422. 0B22DA 24F4000B             MOVE.L $B(A4,D0.W),(A2)+
  1423. 0B22DE 24FE                 MOVE.L SR,(A2)+
  1424. 0B22E0 000B                 DC.W $B  
  1425. 0B22E2 2508                 MOVE.L A0,-(A2)
  1426. 0B22E4 000B                 DC.W $B  
  1427. 0B22E6 2512                 MOVE.L (A2),-(A2)
  1428. 0B22E8 000B                 DC.W $B  
  1429. 0B22EA 251C                 MOVE.L (A4)+,-(A2)
  1430. 0B22EC 000B                 DC.W $B  
  1431. 0B22EE 2526                 MOVE.L -(A6),-(A2)
  1432.  
  1433. 0B22F0 000B                 DC.W $B  
  1434. 0B22F2 2304                 MOVE.L D4,-(A1)
  1435. 0B22F4 000B                 DC.W $B  
  1436. 0B22F6 2329000B             MOVE.L $B(A1),-(A1)
  1437. 0B22FA 2363000B             MOVE.L -(A3),$B(A1)
  1438. 0B22FE 239E000B             MOVE.L (A6)+,$B(A1,D0.W)
  1439. 0B2302 23D80D0A5445         MOVE.L (A0)+,$A5445
  1440.  
  1441.  Section omitted as unnecessary.
  1442.  
  1443. 0B24F4 00000000             ORI.B #0,D0
  1444. 0B24F8 00000000             ORI.B #0,D0
  1445. 0B24FC 00000000             ORI.B #0,D0
  1446. 0B2500 00000000             ORI.B #0,D0
  1447. 0B2504 00000000             ORI.B #0,D0
  1448. 0B2508 00000000             ORI.B #0,D0
  1449. 0B250C 00000000             ORI.B #0,D0
  1450. 0B2510 00000000             ORI.B #0,D0
  1451. 0B2514 00000000             ORI.B #0,D0
  1452. 0B2518 00000000             ORI.B #0,D0
  1453. 0B251C 00000000             ORI.B #0,D0
  1454. 0B2520 00000000             ORI.B #0,D0
  1455. 0B2524 00000000             ORI.B #0,D0
  1456. 0B2528 00000000             ORI.B #0,D0
  1457. 0B252C 00000000             ORI.B #0,D0
  1458.  
  1459. 0B2530 00000000             ORI.B #0,D0
  1460. 0B2534 00000000             ORI.B #0,D0
  1461. 0B2538 00000000             ORI.B #0,D0
  1462. 0B253C 00000000             ORI.B #0,D0
  1463. 0B2540 00000000             ORI.B #0,D0
  1464. 0B2544 00000000             ORI.B #0,D0
  1465. 0B2548 00000000             ORI.B #0,D0
  1466.  
  1467.  
  1468.      Using the information in figure 11.9 we easily confirm that 
  1469. L00013 marks the declaration of the array global; and that 
  1470. L00014, L00017 and L00016 mark the declarations for int_in, 
  1471. int_out and addr_in.  Notice that no label for addr_out appears 
  1472. in the reassembly listing.  That's because the other structures 
  1473. were directly referenced within the program, but addr_out was 
  1474. not.  As the labels for the referenced structures are altered, 
  1475. don't forget to change the label identifiers in the instructions 
  1476. which reference them.  From figure 11.1, the image of a portion 
  1477. of the program's basepage, we can obtain the information needed 
  1478. to mark the data and bss seqments of the program.  But that 
  1479. information is also pretty obvious from the layout of the 
  1480. reassembly and disassembly listings.  Don't forget that the align 
  1481. statement is needed after those dc.b declarations.  With the 
  1482. other AES structures identified, we are able to seek out the 
  1483. other AES function invocations, and with a knowledge of the input 
  1484. requirements for those functions and their returns, we are able 
  1485. to identify the location of the menu text string, the message 
  1486. array and the variable menu_id.
  1487.  
  1488.      From the top of the listing again, the BSR L0000B 
  1489. instruction sends us to the statement which loads L00021+1 into 
  1490. A0.  The BSR L00022 statement just below that sends us to a trap 
  1491. #1 invocation.  Replacing the constant identifier there, K00031, 
  1492. with 9 readily identifies the function as GEMDOS c_conws, the 
  1493. print line function, and thereby, we realize that the contents of 
  1494. A0 must be the address of a string.  We have, of course, already 
  1495. noted that the string declared at L00021+1 is a carriage 
  1496. return/linefeed combination; we can now choose to replace 
  1497. references to L00021+1 as references to the label newline, and 
  1498. references to L00022 as references to print_line.
  1499.  
  1500.      The five instructions below the branch to the print_line 
  1501. subroutine accomplish the following:
  1502.  
  1503.      1. An address is loaded into A0.
  1504.  
  1505.      2. A value is stored in D0; then the contents of D0 are 
  1506.         multiplied by 4.
  1507.  
  1508.      3. D0 is used as an index register in an address register 
  1509.         indirect with index instruction to load a new address 
  1510.         into A0.
  1511.  
  1512.      4. The print_line subroutine is invoked to print a string.
  1513.  
  1514.      We conclude that L00023, the label identifying the address 
  1515. which is loaded into A0 in item 1, must be that of a pointer 
  1516. array that contains the addresses of the strings that are to be 
  1517. processed by the five instructions.  Referring to the disassembly 
  1518. listing, where we see that the address loaded into A0 is $B22F0, 
  1519. then by observing the data stored at that address, we confirm 
  1520. that such is the case.
  1521.  
  1522.      Figure 11.10 contains a section of the disassembly listing 
  1523. that is relevant to the identification of each address stored in 
  1524. the pointer array, and just enough of the beginning of each 
  1525. string.  You could easily confirm that the strings stored at 
  1526. those locations match those of the reassembly listing simply by 
  1527. converting each of the ASCII codes in the disassembly listing to 
  1528. characters.
  1529.  
  1530. Figure 11.10. The section of the disassembly listing 
  1531. containing the addresses referenced in the pointer 
  1532. array at $B22F0.
  1533.  
  1534. 0B2302 23D80D0A5445         MOVE.L (A0)+,$A5445
  1535. 0B2308 5354                 SUBQ.W #1,(A4)
  1536.  
  1537. 0B2328 000D                 DC.W $D  
  1538. 0B232A 0A544553             EORI.W #$4553,(A4)
  1539.  
  1540. 0B2362 000D                 DC.W $D  
  1541. 0B2364 0A544553             EORI.W #$4553,(A4)
  1542.  
  1543. 0B2392 745F                 MOVEQ #$5F,D2
  1544. 0B2394 6D65                 BLT.S $B23FB
  1545.  
  1546. 0B23D6 0A000D0A             EORI.B #$A,D0
  1547. 0B23DA 5445                 ADDQ.W #2,D5
  1548.  
  1549.  
  1550.      We need not be concerned with the actual names used for the 
  1551. labels of the strings; we need only realize that we must place 
  1552. labels at their declarations and store those labels in the 
  1553. pointer array in place of the addresses that are present in the 
  1554. reassembly listing.  Let us chose to use "string_zero" for the 
  1555. first, to match the "TEST POINT 0" reference within the string 
  1556. itself, and continue with the rest of them through "string_four".  
  1557. Remember that the pseudo op for the pointer array declaration at 
  1558. L00023 must be dc.l, for two reasons.  The first is that 32-bit 
  1559. addresses are being stored in the array; the second is that the 
  1560. run time addresses would not be stored if a ds pseudo op were 
  1561. used.
  1562.  
  1563.      Still within the same subroutine, after the five 
  1564. instructions which lead us to the pointer array, there are a 
  1565. series of loads into A0 followed by branches to the print_line 
  1566. subroutine.  The labels referenced in that area are those that we 
  1567. left with the "+1" excess baggage.  We can now alter those labels 
  1568. and the references to them to L00024, L00025 and L00026.  In 
  1569. addition we can replace the two constant identifiers, K00001 and 
  1570. K0000E by the actual values that are stored in registers D7 and 
  1571. D6.  At the conclusion of that activity, we will have arrived at 
  1572. label L00030.
  1573.  
  1574.      At this point, it would be advantageous to exchange each of 
  1575. the constant identifiers remaining in the subroutine for the 
  1576. actual constants.  Simultaneously, we can convert upper case 
  1577. statements which require no alterations to lower case as an 
  1578. indication that we need not be concerned about the format of 
  1579. those statements.  Figure 11.11 shows the reassembly listing at 
  1580. its current stage of reconstruction.
  1581.  
  1582. Figure 11.11.  The partially reconstructed reassembly 
  1583. listing.
  1584.  
  1585. K00001=0    K00003=$3C  K00004=1    K00006=$46  K00007=$C8  K0000C=$A
  1586. K0000D=2    K0000E=4    K0000F=6    K00010=8    K00012=$23  K0001A=$17
  1587. K0001B=$28  K0001D=5    K00020=$3E  K00028=$B   K00029=$20  K0002B=$F
  1588. K0002C=$3A  K0002D=3    K00031=9
  1589.  
  1590. create_file:
  1591.  lea        stack(pc), sp
  1592.  move.w     #0, -(sp)
  1593.  pea        filename(pc)
  1594.  move.w     #$3C, -(sp)
  1595.  trap       #1
  1596.  addq.l     #8, sp
  1597.  move.w     d0, file_handle
  1598.  
  1599. redirect_output:
  1600.  move.w     file_handle(pc), -(sp) ; CAN USE D0 FOR IMPROVEMENT.
  1601.  move.w     #1, -(sp)
  1602.  move.w     #$46, -(sp)
  1603.  trap       #1
  1604.  addq.l     #6, sp
  1605.  
  1606.  move.w     #$C8, d3
  1607.  lea        aes_pb(pc), a5
  1608.  lea        control(pc)
  1609.  lea        L0000A(PC), a3
  1610.  BSR L0000B
  1611.  
  1612. initialize_application:
  1613.  move.w     #$A, (a4)
  1614.  move.w     #0, 2(a4)
  1615.  move.w     #1, 4(a4)
  1616.  move.w     #0, 6(a4)
  1617.  move.w     #0, 8(a4)
  1618.  bsr        aes
  1619.  BSR L0000B
  1620.  
  1621. menu_register:
  1622.  move.w     #$23, (a4)
  1623.  move.w     #1, 2(a4)
  1624.  move.w     #1, 4(a4)
  1625.  move.w     #1, 6(a4)
  1626.  move.w     #0, 8(a4)
  1627.  lea        global(pc), a0
  1628.  move.w     4(a0), int_in
  1629.  move.l     #menu_text, addr_in
  1630.  bsr        aes
  1631.  move.w     int_out(pc), menu_id
  1632.  BSR L0000B
  1633.  
  1634.  move.l     #message, addr_in
  1635. evnt_mesag:
  1636.  move.w     #$17, (a4)
  1637.  move.w     #0, 2(a4)
  1638.  move.w     #1, 4(a4)
  1639.  move.w     #1, 6(a4)
  1640.  move.w     #0, 8(a4)
  1641.  bsr        aes
  1642.  lea        message(pc), a0
  1643.  cmpi.w     #$28, (a0)
  1644.  bne.s      evnt_mesag
  1645.  move.w     8(a0), d0
  1646.  cmp.w      menu_id(pc), d0
  1647.  bne.s      evnt_mesag
  1648.  cmpi.w     #5, L0001E
  1649.  beq.s      evnt_mesag
  1650.  BSR L0000B
  1651.  
  1652.  cmpi.w     #5, L0001E
  1653.  beq.s      close_file
  1654.  bra.s      evnt_mesag
  1655.  
  1656. close_file:
  1657.  move.w     file_handle(pc), -(sp)
  1658.  move.w     #$3E, -(sp)
  1659.  trap       #1
  1660.  addq.l     #4, sp
  1661.  
  1662. _redirect_output:
  1663.  move.w     #1, -(sp)
  1664.  move.w     file_handle(pc), -(sp)
  1665.  move.w     #$46, -(sp)
  1666.  trap       #1
  1667.  addq.l     #6, sp
  1668.  bra.s      evnt_mesag
  1669.  
  1670. L0000B:
  1671.  lea newline(pc), a0
  1672.  bsr        print_line
  1673.  LEA L00023(PC),A0
  1674.  MOVE.W L0001E(PC),D0
  1675.  lsl.w      #2, d0               ; Multiply by 4.
  1676.  movea.l    0(a0,d0.w), a0
  1677.  bsr        print_line
  1678.  lea        L00024(pc), a0
  1679.  bsr        print_line
  1680.  lea        L00025(pc), a0
  1681.  bsr        print_line
  1682.  lea        L00024(pc), a0
  1683.  bsr        print_line
  1684.  lea        L00026(pc), a0
  1685.  bsr        print_line
  1686.  moveq      #0, d7
  1687.  moveq      #4, d6
  1688. L00030:
  1689.  lea        L00027(pc), a0
  1690.  movea.l    a5, a6
  1691.  move.w     #5, d5
  1692.  move.w     #11, d0
  1693. L0002A:
  1694.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1695.  dbra       d0, L0002A
  1696. L0002F:
  1697.  move.w     d7, d0
  1698.  andi.b     #$F, d0
  1699.  move.b     0(a3,d0.w), d0
  1700.  move.b     d0, (a0)+
  1701.  move.b     #$3A, (a0)+          ; $3A = ASCII for colon.
  1702.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1703.  move.b     d7, d0
  1704.  lsl.w      #1, d0
  1705.  movea.l    (a6)+, a1
  1706.  move.w     0(a1,d0.w), d0
  1707.  moveq      #3, d2
  1708. L0002E:
  1709.  rol.w      #4, d0
  1710.  move.b     d0, d1
  1711.  andi.b     #$F, d1
  1712.  ext.w      d1
  1713.  move.b     0(a3,d1.w), d1
  1714.  move.b     d1, (a0)+
  1715.  dbra       d2, L0002E
  1716.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1717.  move.b     #$20, (a0)+
  1718.  dbra       d5, L0002F
  1719.  move.b     #0, (a0)
  1720.  lea        L00027(pc), a0
  1721.  bsr        print_line
  1722.  lea        newline(pc), a0
  1723.  bsr        print_line
  1724.  addi.w     #1, d7
  1725.  dbra       d6, L00030
  1726.  addi.w     #1, L0001E
  1727.  rts
  1728.  
  1729. aes:
  1730.  move.l     a5, d1
  1731.  move.w     d3, d0
  1732.  trap       #2
  1733.  rts
  1734.  
  1735. print_line:
  1736.  move.l     a0, -(sp)
  1737.  move.w     #9, -(sp)
  1738.  trap       #1
  1739.  addq.l     #6, sp
  1740.  rts
  1741.  
  1742.  data
  1743. aes_pb: dc.l  control,global,int_in,int_out,addr_in,addr_out
  1744.   
  1745. L00023:
  1746.         dc.l string_zero,string_one,string_two,string_three,string_four
  1747. string_zero:  
  1748.  dc.b $D,$A,'TEST POINT 0: Before appl_init',$D,$A,$D,$A,0
  1749. string_one:
  1750.  dc.b $D,$A,'TEST POINT 1: After appl_init, before menu_register',$D,$A,$D,$A,0
  1751. string_two:
  1752.  dc.b $D,$A,'TEST POINT 2: After menu_register, before evnt_mesag',$D,$A,$D,$A,0
  1753. string_three:
  1754.  dc.b $D,$A,'TEST POINT 3: In message handler, before evnt_mesag',$D,$A,$D,$A,0
  1755. string_four:
  1756.  dc.b $D,$A,'TEST POINT 4: In message handler second time',$D,$A,$D,$A,0
  1757.  
  1758. L0000A:   dc.b '0123456789ABCDEF' 
  1759. newline:  dc.b $D,$A,0
  1760.  
  1761.  dc.b '                                AES ARRAYS',$D,$A,0  ; Label is unknown.
  1762.   
  1763. L00025:
  1764.  dc.b 'CONTROL  GLOBAL  INT_IN  INT_OUT  ADDR_IN  ADDR_OUT',$D,$A,0
  1765. L00026:
  1766.  dc.b '_______  ______  ______  _______  _______  ________',$D,$A,0  
  1767. L00024:
  1768.  dc.b '            ',$D,$A,0
  1769.  dc.b '  ',$D,$A,0                   ; Label is unknown.
  1770. menu_text:
  1771.  dc.b '  Accessory Arrays ',0
  1772. filename:
  1773.  dc.b 'E:\PRG_8\PRG_8AR.DAT',0
  1774.  
  1775.  bss
  1776.  align
  1777.  
  1778. control:       ds.w   5
  1779. global:        ds.w   5
  1780. int_in:        ds.w   5
  1781. int_out:       ds.w   5
  1782. addr_in:       ds.w   5
  1783. addr_out:      ds.w   5
  1784.  
  1785. file_handle:   ds.w   1
  1786. L0001E:DC.W K00001
  1787. message:       ds.w   8
  1788. menu_id:       ds.w   1
  1789. L00027:        ds.l 160
  1790.                ds.l 160
  1791. stack:         ds.l   1
  1792.  end
  1793.   
  1794.   
  1795.      I would now like to draw your attention to two particular 
  1796. declarations within the listing.  I have marked them with the 
  1797. comment Label is unknown.  The first declaration is just below 
  1798. the newline label; the second is just above L00015+1.  In the 
  1799. original program, the label at the first declaration was 
  1800. "aes_header"; the label at the second was "spaces".  There is no 
  1801. reference to these labels in the reassembly listing because they 
  1802. were never referenced in the original program.  You can confirm 
  1803. the omission of the first just by looking at the program's 
  1804. output.  The header does not appear.  I had intended that it 
  1805. should, therefore, its omission is an error.  The second 
  1806. declaration should have been removed from the original program 
  1807. because I replaced the function that was to be performed with the 
  1808. "spaces" declaration with in-line code.
  1809.  
  1810.      You can be sure that you will observe similar errors and 
  1811. superfluous statements in other programs that you reconstruct.  
  1812. In fact, you can be sure that you will sometimes see superflous 
  1813. statements that have been deliberately inserted in a program to 
  1814. hinder a reconstruction of the source program.  Other ploys 
  1815. include self-modifying code and hardware devices which provide 
  1816. signals for the program.  Examples will be investigated later.
  1817.  
  1818. Concluding the Reconstruction
  1819.  
  1820.      We can choose to continue with the source program 
  1821. reconstruction by returning to the top of the program and resolve 
  1822. any further label references, or we can immerse ourselves in the 
  1823. subroutine which seems to accomplish most of the work in the 
  1824. program.  One activity that can be immediately identified is that 
  1825. which follows the evnt_mesag function invocation.  The 
  1826. comparisons performed there; comparing #$28 to message[0], and 
  1827. menu_id to message[4]; clearly marks this as the message handler 
  1828. algorithm; therefore, we can designate it as such.  Then, let us 
  1829. turn our attention to the program's major subroutine.
  1830.  
  1831.      The third instruction of the subroutine loads the address of 
  1832. the pointer array declared at L00023 into A0; the fourth moves 
  1833. the contents of the variable declared at L0001E into D0; the 
  1834. fifth multiplies the value of that variable by 4; and in the 
  1835. sixth instruction, D0 is used as an index register to load a new 
  1836. address into A0.  We already know that the pointer array contains 
  1837. the addresses of the strings declared just below the pointer 
  1838. array declaration.
  1839.  
  1840.      The series of instructions which setup D0 and A0 so that a 
  1841. selection from that group of strings depends on the value stored 
  1842. at L0001E tend to indicate that the value at that location is 
  1843. dynamic.  Indeed, if we search the reassembly listing for other 
  1844. references to L0001E, we see that the value stored there is 
  1845. compared to the value 5 in two instructions, and it is 
  1846. incremented as the last instruction in the subroutine.  Since the 
  1847. value stored at L0001E is used in an index register that 
  1848. determines the choice from a group of strings which identify 
  1849. themselves as TEST POINTS, we need little imagination to rename 
  1850. the variable test_number or some other name that is indicative of 
  1851. its function, and then to properly perform a bss declaration.  
  1852. Remember to alter all references to L0001E.  Figure 11.12 shows 
  1853. the reconstructed, but untested, listing.
  1854.  
  1855. Figure 11.12. Reconstructed source listing.
  1856.  
  1857.  ; PRG_8AR.ASM
  1858.  
  1859.  ; MAJOR NOTE:
  1860.  
  1861.  ;      THIS PROGRAM MAY NOT FUNCTION CORRECTLY IF TURBO ST IS INSTALLED.
  1862.  
  1863.  ;      This program has been reconstructed from PRG_8AR.ACC.
  1864.  
  1865. create_file:
  1866.  lea        stack(pc), sp
  1867.  move.w     #0, -(sp)
  1868.  pea        filename(pc)
  1869.  move.w     #$3C, -(sp)
  1870.  trap       #1
  1871.  addq.l     #8, sp
  1872.  move.w     d0, file_handle
  1873.  
  1874. redirect_output:
  1875.  move.w     file_handle(pc), -(sp) ; CAN USE D0 FOR IMPROVEMENT.
  1876.  move.w     #1, -(sp)
  1877.  move.w     #$46, -(sp)
  1878.  trap       #1
  1879.  addq.l     #6, sp
  1880.  
  1881.  move.w     #$C8, d3
  1882.  lea        aes_pb(pc), a5
  1883.  lea        control(pc), a4
  1884.  lea        L0000A(PC), a3
  1885.  BSR L0000B
  1886.  
  1887. initialize_application:
  1888.  move.w     #$A, (a4)
  1889.  move.w     #0, 2(a4)
  1890.  move.w     #1, 4(a4)
  1891.  move.w     #0, 6(a4)
  1892.  move.w     #0, 8(a4)
  1893.  bsr        aes
  1894.  BSR L0000B
  1895.  
  1896. menu_register:
  1897.  move.w     #$23, (a4)
  1898.  move.w     #1, 2(a4)
  1899.  move.w     #1, 4(a4)
  1900.  move.w     #1, 6(a4)
  1901.  move.w     #0, 8(a4)
  1902.  lea        global(pc), a0
  1903.  move.w     4(a0), int_in
  1904.  move.l     #menu_text, addr_in
  1905.  bsr        aes
  1906.  move.w     int_out(pc), menu_id
  1907.  BSR L0000B
  1908.  
  1909.  move.l     #message, addr_in
  1910. evnt_mesag:
  1911.  move.w     #$17, (a4)
  1912.  move.w     #0, 2(a4)
  1913.  move.w     #1, 4(a4)
  1914.  move.w     #1, 6(a4)
  1915.  move.w     #0, 8(a4)
  1916.  bsr        aes
  1917.  
  1918. message_handler:
  1919.  lea        message(pc), a0
  1920.  cmpi.w     #$28, (a0)
  1921.  bne.s      evnt_mesag
  1922.  move.w     8(a0), d0
  1923.  cmp.w      menu_id(pc), d0
  1924.  bne.s      evnt_mesag
  1925.  cmpi.w     #5, test_number
  1926.  beq.s      evnt_mesag
  1927.  BSR L0000B
  1928.  cmpi.w     #5, test_number
  1929.  beq.s      close_file
  1930.  bra.s      evnt_mesag
  1931.  
  1932. close_file:
  1933.  move.w     file_handle(pc), -(sp)
  1934.  move.w     #$3E, -(sp)
  1935.  trap       #1
  1936.  addq.l     #4, sp
  1937.  
  1938. _redirect_output:
  1939.  move.w     #1, -(sp)
  1940.  move.w     file_handle(pc), -(sp)
  1941.  move.w     #$46, -(sp)
  1942.  trap       #1
  1943.  addq.l     #6, sp
  1944.  bra.s      evnt_mesag
  1945.  
  1946. L0000B:
  1947.  lea newline(pc), a0
  1948.  bsr        print_line
  1949.  LEA L00023(PC),A0
  1950.  move.w     test_number(pc), d0
  1951.  lsl.w      #2, d0               ; Multiply by 4.
  1952.  movea.l    0(a0,d0.w), a0
  1953.  bsr        print_line
  1954.  lea        L00024(pc), a0
  1955.  bsr        print_line
  1956.  lea        L00025(pc), a0
  1957.  bsr        print_line
  1958.  lea        L00024(pc), a0
  1959.  bsr        print_line
  1960.  lea        L00026(pc), a0
  1961.  bsr        print_line
  1962.  moveq      #0, d7
  1963.  moveq      #4, d6
  1964. L00030:
  1965.  lea        L00027(pc), a0
  1966.  movea.l    a5, a6
  1967.  move.w     #5, d5
  1968.  move.w     #11, d0
  1969. L0002A:
  1970.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1971.  dbra       d0, L0002A
  1972. L0002F:
  1973.  move.w     d7, d0
  1974.  andi.b     #$F, d0
  1975.  move.b     0(a3,d0.w), d0
  1976.  move.b     d0, (a0)+
  1977.  move.b     #$3A, (a0)+          ; $3A = ASCII for colon.
  1978.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1979.  move.b     d7, d0
  1980.  lsl.w      #1, d0
  1981.  movea.l    (a6)+, a1
  1982.  move.w     0(a1,d0.w), d0
  1983.  moveq      #3, d2
  1984. L0002E:
  1985.  rol.w      #4, d0
  1986.  move.b     d0, d1
  1987.  andi.b     #$F, d1
  1988.  ext.w      d1
  1989.  move.b     0(a3,d1.w), d1
  1990.  move.b     d1, (a0)+
  1991.  dbra       d2, L0002E
  1992.  move.b     #$20, (a0)+          ; $20 = ASCII for space.
  1993.  move.b     #$20, (a0)+
  1994.  dbra       d5, L0002F
  1995.  move.b     #0, (a0)
  1996.  lea        L00027(pc), a0
  1997.  bsr        print_line
  1998.  lea        newline(pc), a0
  1999.  bsr        print_line
  2000.  addi.w     #1, d7
  2001.  dbra       d6, L00030
  2002.  addi.w     #1, test_number
  2003.  rts
  2004.  
  2005. aes:
  2006.  move.l     a5, d1
  2007.  move.w     d3, d0
  2008.  trap       #2
  2009.  rts
  2010.  
  2011. print_line:
  2012.  move.l     a0, -(sp)
  2013.  move.w     #9, -(sp)
  2014.  trap       #1
  2015.  addq.l     #6, sp
  2016.  rts
  2017.  
  2018.  data
  2019. aes_pb: dc.l  control,global,int_in,int_out,addr_in,addr_out
  2020.   
  2021. L00023:
  2022.         dc.l string_zero,string_one,string_two,string_three,string_four
  2023. string_zero:  
  2024.  dc.b $D,$A,'TEST POINT 0: Before appl_init',$D,$A,$D,$A,0
  2025. string_one:
  2026.  dc.b $D,$A,'TEST POINT 1: After appl_init, before menu_register',$D,$A,$D,$A,0
  2027. string_two:
  2028.  dc.b $D,$A,'TEST POINT 2: After menu_register, before evnt_mesag',$D,$A,$D,$A,0
  2029. string_three:
  2030.  dc.b $D,$A,'TEST POINT 3: In message handler, before evnt_mesag',$D,$A,$D,$A,0
  2031. string_four:
  2032.  dc.b $D,$A,'TEST POINT 4: In message handler second time',$D,$A,$D,$A,0
  2033.  
  2034. L0000A:   dc.b '0123456789ABCDEF' 
  2035. newline:  dc.b $D,$A,0 
  2036.  dc.b '                                AES ARRAYS',$D,$A,0
  2037.   
  2038. L00025:
  2039.  dc.b 'CONTROL  GLOBAL  INT_IN  INT_OUT  ADDR_IN  ADDR_OUT',$D,$A,0
  2040. L00026:
  2041.  dc.b '_______  ______  ______  _______  _______  ________',$D,$A,0  
  2042. L00024:
  2043.  dc.b '            ',0
  2044.  dc.b '  ',$D,$A,0
  2045. menu_text:
  2046.  dc.b '  Accessory Arrays ',0
  2047. filename:
  2048.  dc.b 'E:\PRG_8\PRG_8AR.DAT',0
  2049.  
  2050.  bss
  2051.  align
  2052.  
  2053. control:       ds.w   5
  2054. global:        ds.w   5
  2055. int_in:        ds.w   5
  2056. int_out:       ds.w   5
  2057. addr_in:       ds.w   5
  2058. addr_out:      ds.w   5
  2059.  
  2060. file_handle:   ds.w   1
  2061. test_number:   ds.w   1
  2062. message:       ds.w   8
  2063. menu_id:       ds.w   1
  2064. L00027:        ds.l 160
  2065.                ds.l 160
  2066. stack:         ds.l   1
  2067.  end
  2068.  
  2069.   
  2070.      Actually, I have assembled the program and tested it.  
  2071. That's why I know that it will not function correctly if my 
  2072. version of TURBO ST is installed.  And there are other problems.  
  2073. That's why I was forced to write a program to assist with the 
  2074. corrections that are necessary to make the reconstructed listing 
  2075. produce object code that is identical to the object code from 
  2076. which we have generated the source.
  2077.  
  2078.