Xref: utzoo comp.lang.c:11392 comp.arch:5562 Path: utzoo!attcan!uunet!munnari!moncskermit!moncsbruce!conybear From: conybear@moncsbruce.oz (Roland Conybeare) Newsgroups: comp.lang.c,comp.arch Subject: Re: Self-modifying code Message-ID: <476@moncsbruce.oz> Date: 18 Jul 88 03:51:45 GMT References: <752@cernvax.UUCP> Organization: Comp Sci, Monash Uni, Australia Lines: 27 From article <752@cernvax.UUCP>, by hjm@cernvax.UUCP (hjm): > As a final note, why is it 'clean' to alter a jump table and 'unclean' to > alter an inline constant (e.g. jmp @offset(r0) uses a value in memory as the > address but mov (pc)+,#1234 which loads an immediate does so too)? Why > the subtle difference? Any thoughts on the subject? > > Hubert Matthews I can see several reasons. * the big, big reason for referring to code via pointers, and getting the effect of self-modifying code via such pointers, is that you make your changes independent of the size of the code. Real SMC will only work when the new code is no larger than the old code. I think this is a very restrictive assumption. * when you alter a jump table (in C, at least) you are doing so within the language, and can expect the compiler to understand you. A language which allows you to modify instructions directly would of necessity depend strongly on the machine architecture to run these instructions. Otherwise, why don't we all use Universal Assembly Language? Roland Conybeare conybear@moncsbruce.oz an instruction, like mov (pc)+,#1234 you are assuming that the change you make