Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!snorkelwacker!bu.edu!orc!oliveb!amiga!cbmvax!cbmehq!cbmfra!swinjm!forgeas From: forgeas@swinjm.UUCP (Jean-Michel Forgeas) Newsgroups: comp.sys.amiga.tech Subject: Re: Self Modifying Code! Message-ID: Date: 6 Jul 90 18:47:53 GMT References: <293@smosjc.UUCP> Lines: 55 In article <293@smosjc.UUCP> brett@smosjc.UUCP (Brett Coon) writes: >Is there an acceptable means to write self-modifying code on the Amiga? > >[...] My current plan is to select one of a few possible >versions of the code at the beginning, and then patch the code to use the >appropriate version. You have at least one other solution: use vectors. struct FuncNeeded { void (*func1)(); void (*func2)(); }; struct FuncNeeded Version1 = { Func1_1, Func1_2 }; struct FuncNeeded Version2 = { Func2_1, Func2_2 }; struct FuncNeeded *Version; init() { Version = (TheVersionYouWant ? &Version1 : &Version2 ) } program() { ... (*(Version->func1))(); ... retcode = (int*) (*(Version->func2))(); ... } > It would be done once, during initialization, so >performance at this point is entirely unimportant. It could be coded in asm like: init: ... lea Version1,a5 use a base register rts program: ... move.l func2vectoroffset(a5),a0 jsr (a0) ... rts -- \___/ Jean-Michel Forgeas \-/ cbmvax!cbmbsw!cbmsup!cbmfra!swinjm!forgeas | The Software Winery -^- And, where is the universe ?