>TOTAL number of MOVs in the copy routine. The most surprising thing I
>found was that using 1 MOV is NEVER a good idea. The ONLY exception is
>in the case of a 1 line mobile program - the IMP. :)
>
Maybe I'm missing something, but what about the following routine:
(BTW, I'm not much on using EQU statements, so bear with the example)
source DAT #10
dest DAT #30
start mov temp1,source
mov temp2,dest
loop mov <source,<dest
jmn start,source
add #2,dest
jmp @dest
temp1 DAT #10
temp2 DAT #30
This would copy the entire program to a location 20 cells from the
position of "source" and jump to that program. Now, true, it has to
reload the source and dest at the beginning, but once it gets to the
copying stage, it moves quite fast. I think it works especially well
for long programs. Seeing that most of the successfull programs are
short, though, I can understand why one wouldn't want to waste time
with the "loading" portion of the code. Please pick at this. I'd
personally like to know why this is a bad idea; it would help me
out. Thanks...
--
"Have you ever danced with the Devil by the pale moonlight?
I ask that of all my prey. I just like the sound of it..." - the Joker
************************************************************************
Damon Gallaty E-mail: dg...@cad.gatech.edu
init mov <prog length>,0
mov <init,<dest
jmn -1,init
... lots of really useful code ...
dest jmp @0,<offset to new location>
-Andy
ajpi...@med.unc.edu
size equ 4
dist equ 617
length equ 5
start mov #length,start ; size of code
mov #dist, dest ; destination
copy mov <start, <dest ; copy
jmn copy, start ; till the end
dest jmp @dest, dist ; jump to new code
end
--
"Pis Bourassa qui est toujours la. Y'a pas d'remede contre le SIDA" - French B
"This is a mad house !" - Rosencrantz
...........................................................d...@info.polymtl.ca
Everybody who has posted a copy routine used only 1 mov
instruction in the copy loop. The reason this is a bad idea is simple-
it takes X cycles longer where X is 1/6th the program size when compared
to a 2 MOV copy routine. In programs where the copying code is controlled
by a tight scanner, or where the program is large, those extra cycles
cost a lot. When your program splits, those cycles often mean the difference
between life and death.
Oh, and thanks to Andrew Pierce for his JMP B-field instruction. That
*NEVER* occurred to me.
Example:
offset equ 100 ; the distance the program jumps
;spinner - in this part you split up and synchronize the processes
;
;
;bomber - the bombing or scanning code, or whatever - the parallel
; processes work best for bombing
;
;jumper - the copy part
jmp copy, #0
src dat #last, #0 ; points to the bottom of your code
dst dat -offset, #0 ; where it's all going to go
copy mov <src, <dst ; this copies N lines of code, for N =
; number of processes
mov <src, <dst ; do this until you've got enough to
; copy the whole thing
jmp bomber-offset, #0
--
Stephen Beitzel -- sbei...@wet.com | "Happy, happy. Joy, joy."
"Ownership of the above opinions |
depends solely on how offended you are | Relax. Have a homebrew.
by them." |
Not quite . . . The self-copying program ImpDwarf I posted uses four
processes to copy itself with no loops. This actually slows down the copy
procedure (20 cycles copying as opposed to 16 with a loop) but I used it anyway
because it put more emphasis on the copying over the bombing, which I felt was
less important.
***********************************************************************
* Warren Kurt * "Bones, quick! He's choking!" *
* vonRoeschlaub * "Dammit Jim, I'm a doctor, not a . . . oh yeah!" *
***********************************************************************
The added code for splitting would make that useful (IMHO) only for larger
programs. For very specific applications (Molerat & ilk, Lichen & ilk)
multi-threaded copies are great. For an application like a scanner
I don't think they're very useful - they take too much code to handle
'properly' , and slow down the scanning.
Right now the best scanner can scan 2 locations in 3 cycles. Using
multi-threading if would be possible to scan 4 locations in two cycles,
but you'd still use another 4 cycles for the add/loop. On the average that
is still 2 locations for 3 cycles. Programmed right, (i.e. with a LOT of
tweaking) you could gain the benefit of scanning while bombing, but I don't
think the effort is worth the gain because a better bomber would work just
as well.
It's possible scan (2x-1) locations in x cycles with the following -
START cmp <A, <B
jmp ...
cmp <C, <D
jmp ...
cmp <E, <F
:
jmz START, <POS
The main compromise involved is the linear nature of the scans.
Campbell
--
---
Hi, I'm a .signature virus. Copy me to yours and then wipe all your files.
As has been posted to the net already (I thought it was by Campbell
Fraser but maybe I'm wrong on that) it is possible to scan three locations
in three cycles with something like:
add offset,1
cmp a,b
slt #len,-1 ;self protection
jmz -3,<y ;the third scan
-Andy
ajpi...@med.unc.edu