home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6638 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  6.7 KB

  1. Path: vb.franken.de!volker
  2. From: volker@vb.franken.de (Volker Barthelmann)
  3. Subject: Re: 680X0 -> PPC translator?
  4. Newsgroups: comp.sys.amiga.programmer
  5. References: <31499F8E.26A9@netvision.net.il> <volker.0fw1@vb.franken.de> <315800D7.1854@sapiens.com> <volker.0g32@vb.franken.de> <315C198B.49C2@netvision.net.il>
  6. X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
  7. Message-ID: <volker.0g5w@vb.franken.de>
  8. Date: 31 Mar 96 01:55:19 MET
  9. Organization: home
  10.  
  11. Jack (avilev@netvision.net.il) wrote:
  12. : Hi Volker, well i'll try to keep the lines shorter this time
  13. : so you'll be able to read the text more conveniently and who
  14.  
  15. Thanks!
  16.  
  17. : know. you might actually be convinced that 680x0 -> PPC is possible. ;-)
  18.  
  19. I doubt that. :-)
  20.  
  21. : > Perhaps You can perform this analysis. An algorithm can't.
  22. :
  23. : why the hell not, if i can understand assembly source code,
  24. : the machine can understand machine code right?!
  25.  
  26. I don't know if You (or any human) can really 'understand' EVERY
  27. piece of machine code. Of course typical assembly source can be
  28. understood by humans, because it was written with that in mind.
  29.  
  30. : > Of course You can have a structure holding all Your variables. Now You pass
  31. : > the address of this structure to an external function that writes some
  32. : > values into it and You lost.
  33. :
  34. : i don't seem to care about that, get it through your head, i'm NOT
  35. : going to intervene with what the program does with any memory area,
  36. : just as long as this memory area is not later being used for code
  37.  
  38. Unfortunately You have to know about all other memory areas as well,
  39. because otherwise You cannot determine what is code and what is data.
  40.  
  41. Think about: The program writes a value somwhere. Then copies it around,
  42. shifts it, moves it again etc. and than sometimes it reads it from where
  43. it is now, loads it in a0 and does a jmp (a0) or so.
  44.  
  45. : execution. then, and only then will i have to turn to all the locations
  46. : where that pointer could have been assigned and then change the size
  47. : argument which i already know to the appropriate sizes, once i figure
  48. : out that the area is code, i will perform a well defined series of actions
  49. : to resolve ALL dependecies related to that area, including size, write loops etc.
  50.  
  51. Well, please define those 'well defined' series of actions.
  52.  
  53. : > There are several memory allocating functions or other functions You can't
  54. : > know anything about.
  55. :
  56. : then you take into account all of the various SYSTEM functions which allocate
  57. : memory (there aren't many of them) and proceed as normal.
  58.  
  59. What do You do if a program does an OpenLibrary("some_custom.library",foo);
  60. and a jsr -some_strange_offset_I've_never_seen_before(a6)?
  61. This function could call AllocMem. You don't even know what parameters it
  62. takes etc.
  63.  
  64. : > You would have to adjust EVERYTHING that is in any way dependant on the code
  65. : > size! How are You going to do this?
  66. :
  67. : all you have to look for is where it was allocated and where it is copied,
  68. : assuming you're copying code that is. quite easily done if you follow the
  69. : change made to that pointer while 'running' through the program's logic.
  70.  
  71. If You write a program that only reads a normal assembly source file that
  72. is known to copy some piece of code somewhere and Your program can change the
  73. source to copy one byte more, I'll believe You (and call You god, if You want).
  74.  
  75. : > : > Easy??
  76. : > :
  77. : > : yes easy, cuz as i said you know where it was allocated and you can change the appropriate
  78. : > : argument.
  79. : >
  80. : > Er..have You ever really programmed anything with data flow analysis?
  81.  
  82. : well actually yes, i did, although it wasn't anywhere near as complex
  83. : as the problem we're talking about.
  84.  
  85. Please tell me more, I'm curious!
  86.  
  87. : > As the size of the sub-allocated memory changes You may have to completely
  88. : > rewrite the pool-allocator, because it may depend on the allocations being
  89. : > of certain sizes or a multiple of a certain sizes etc.
  90. : > To do this the translator would have to completely understand the allocator
  91. : > and this is impossible.
  92. :
  93. : what???? all you have to do is request the allocator for more memory, no need
  94. : to change anything in the allocator itself. the only possible problem i see here
  95.  
  96. Yes, You have. E.g. the allocator could assume that all requests are multiples
  97. of 1024 and rely on that. Now the original code may have been a multiple
  98. of 1024, but the PPC-code probably isn't. So when You pass the PPC-code-size
  99. to the allocator it will go nuts.
  100.  
  101. : granted, you're right about that not all solutions are clear cut but when it comes
  102. : to exact sciences such as computer-science then i would disagree, especially
  103. : since the problem we're dealing with isn't related to any human logic, that
  104. : field even in computer-science hasn't been fully explored and understood yet.
  105. : no, the only major problem is self-modification of the program otherwise you
  106. : translate the code 1:1.
  107.  
  108. Still I claim You can't even reliably decide what is code and what is data.
  109. Even if self-modifying code is forbidden.
  110.  
  111. : > I gave several examples. The discussion is rather pointless as long as You
  112. : > just say 'I keep track of this' and 'adjust that according to xyz' etc.
  113. : > Of course it's possible to rewrite a program to PPC, but You have to show
  114. : > that this can be done by an algorithm and this is a different story.
  115. : >well saying that often doesn't mean it's wrong and it would be foolish not
  116. : to explore every suggested solution. if you are so convinced it is not
  117. : possible then surely you can provide me with a concrete proof to undermine
  118. : my theory, can't you?! remember the burden of proof lies on my shoulders
  119. : cuz i claim something is possible, so you have to give me an example
  120. : i can't solve with my theory.
  121.  
  122. Well, I really thought it would be obvious that there are examples, but
  123. I'll give You a detailed one if You like:
  124.  
  125. Assume a program that has some kind of keyfiles. It has n areas that could
  126. be code or data and Your algorithm has to decide that.
  127. Assume that the addresses of those areas are in an array adr[n].
  128. Now the program call the system function Open("env:keyfile",MODE_OLDFILE),
  129. reads all longwords from the file, adds them up and calls adr[sum%n].
  130.  
  131. To know which areas could be called You would have to know all valid
  132. keyfiles. Of course no algorithm knows them and therefore can't decide what
  133. is code. qed.
  134.  
  135. : > Once You describe Your algorithm I will happily give You an example.
  136. :
  137. : the algorithm mainly revolves around self-modification, otherwise it's
  138. : a simple translation of code instructions. and my algorithm, though wasn't
  139.  
  140. No.
  141.  
  142. : presented in a flow-chart, is presented by words. that doesn't mean it's impossible
  143. : to write an actual algorithm in a true sense of the word.
  144.  
  145. Of course You can present an algorithm by words, but You didn't. It was more
  146. like 'First I look at the program, than I decide what is code and then I
  147. rewrite it.' That's A BIT vague, I'm afraid.
  148.  
  149. Volker
  150.  
  151.