Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!portal!cup.portal.com!Radagast From: Radagast@cup.portal.com (sullivan - segall) Newsgroups: comp.sys.amiga.emulations Subject: Re: Emulator Mechanics (sorry long post) Message-ID: <39935@cup.portal.com> Date: 8 Mar 91 00:27:32 GMT References: <4992@mindlink.UUCP> <1991Mar6.010141.5905@mintaka.lcs.mit.edu> <1303@macuni.mqcc.mq.oz> <1304@macuni.mqcc.mq.oz> Distribution: na Organization: The Portal System (TM) Lines: 36 Even without self-modifying code, it can be very difficult to separate code from data. I will often use functions that have inline data (eg: call Print db "Hello World!",0 mov ax,4c00h int 21h or: call Case db 2 dw OFFSET default_sub db 'A' dw OFFSET case_a_sub db 'B' dw OFFSET case_b_sub jmp loop ) This sort of problem is impossible to resolve without an interpreter running at the same time as the cross-compiler. By following the path of the program, you might possibly find most of the code and data segments, but it is quite easy to write a branch which will only be taken one out of a million times. If the compiler assumes that the conditional branch may or may not be taken in the future (ie: ignoring the current processor state) it might very well find itself modifying data rather than code. The branch may have been written conditionally to take advantage of the relative addressing inherent in those branches so that the code is relocatable on the fly. I think you'd stand a better chance with a resourcer, and a cross compiler allowing you to control the intermediate code, and correct any obvious flaws, than with a one step process. -kls