Yet Another LMM Loop
lonesock
Posts: 917
EDIT: Phil's been here, done this! Please ignore this thread.
Hi, All.
I was looking at Phil's reverse LMM loop, and trying to do something similar, but forward...can I get some eyes on this proposed solution?
* load 4 into Inst1, but don't execute (self-modified code isn't changed till after the next instruction)
* load 3 (masked as 0) into Inst0, then execute
* load 12 into Inst 1, but execute the 4 that was stored there previously
* load 11 (masked as 8) into Inst0, and execute it
* load 20 into Inst1, but execute the 12 that was stored previously
* etc.
For jumps (changing ptr), you'd probably need to wipe Inst1 to a nop (set to #0), then resume at #StartHere.
What am I missing?
thanks,
Jonathan
Hi, All.
I was looking at Phil's reverse LMM loop, and trying to do something similar, but forward...can I get some eyes on this proposed solution?
' get started by reading the 2nd long rdlong ptr, par add ptr, #4 jmp #StartHere ' my main LMM loop LMM_fwd rdlong Inst0, ptr add ptr, #9 Inst0 nop StartHere rdlong Inst1, ptr Inst1 nop djnz ptr, #LMM_fwdIn theory (or at least, "what I want"), if you pass in address 0 as the start address, the load sequence will be:
* load 4 into Inst1, but don't execute (self-modified code isn't changed till after the next instruction)
* load 3 (masked as 0) into Inst0, then execute
* load 12 into Inst 1, but execute the 4 that was stored there previously
* load 11 (masked as 8) into Inst0, and execute it
* load 20 into Inst1, but execute the 12 that was stored previously
* etc.
For jumps (changing ptr), you'd probably need to wipe Inst1 to a nop (set to #0), then resume at #StartHere.
What am I missing?
thanks,
Jonathan
Comments
This looks familiar, I've definitely seen this one before. Anyway, you probably also want
thanks,
Jonathan
-Phil
Edit: Well, okay, he beat me to it. Here's a perfect example of where it would be nice to be able to delete a post.
OK, please disregard this post, except as a pointer to Phil's original ("Two thou shalt not count, except by way of counting three").
thanks,
Jonathan