0 Members and 4 Guests are viewing this topic.
userMem (address $95D5 if memory serves well).
I will only start using SMC when I need speed.Not using SMC keeps compatibility with APPS and is much more reusable code for other projects (like OSes or other APPS).I see some confusion between SMC (Self Modifying Code) and write-back on Omnimaga forums. Not only on this topic. I will try to differentiate them.SMC is when code will simply modify some other code.Only possible when the code is in RAM so it is easily changed like normal data. The modified code is temporary. (true for 99% of cases) So very rarely if ever SMC needs write-back for the program to work as expected.Write-back is writing the "copy" back to the "original" program.This happens because the assembly programs you run is not the original but a copy in a address equated as userMem (address $95D5 if memory serves well). For example, in the end of the program data resides the save game data. In order to the program work as expected and your precious progress be kept you need some additional code (it finds out the position of the original program and copies the data back to it) or a shell with write-back option that does the job for the coder.Note that SMC and write-back are independent. But generally data needs write-back and SMC do not.If I made a mistake or was not clear, please point out, no one is perfect.EDIT: bonus exampleQuote from: Builderboy on June 11, 2010, 07:30:31 pmMmm i like programs that use SMC for highscores ^^ It makes the appvar space less cluttered It is correctly write-back and not self modifying code. You are modifying some data of a highscore, not code and you need that is copied back to the original program.(curiously you can hard code high score data into code but is very rare and not the best way to store this kind of data)EDIT: Oh, but if you are talking about Axe Parser, it is possible you are using both SMC and write-back.
Mmm i like programs that use SMC for highscores ^^ It makes the appvar space less cluttered
Thanks for the clarification Galandros! Quote from: Galandros on June 12, 2010, 05:29:37 pmuserMem (address $95D5 if memory serves well).It's $9D95.
aAH thanks for the carification Galandros ^^
I occasionally use it. Sometimes, its for speed considerations, sometimes for size, other times for simplicity. Its not too difficult to copy small code segments from apps into ram and then execute them there so compatibility is usually not an issue. One smc I really like to use is modifying (ix+0) and change the 0 to other values to really quickly read and write to the nth element of a list without using any extra registers. I did this in Pyoro for the "closest block" algorithm.
Yeah, I use the (ix+nn) trick sometimes in my variable-height masked sprite routines