I daresay this has been raised many times before but i didnt see it in a search of the site
The repe is bound to be optimised but is it much faster than mov ???
Below is a sort of chunk of code from one of my programs. I produce a result
at the bottom end [rightmost] of a very large buffer (here as Inputbuffer) which could be filled with info
at any length up to the maximum.. it will have numeric zeros at the front end where data
hasnt been written to the buffer and i want to extract the info from the far end so need a count of leading zeros [if any]
Below are two versions [approximately] of the same thing and im interested to know
whether and if so why they might not be comparable in speed .. as i know that many of you have a lot of
experience with timing and have special routines for doing so
//////////////////////////////////////////////////////////////////////////////////////////////////////////
mov edi,offset Inputbuffer
push edi
mov ecx,{some limit} ; set neg so it runs to a char
xor eax,eax
repe scasb
mov eax,edi
pop edi
inc ecx
cmp ecx.... xxxx ; do some check re Inputbuffer
//////////////////////////////////////////////////////////////////////////////////////////////////////////
mov and loop equivalent
xor ecx,ecx
Somelabel:
inc ecx
cmp ecx, {some limit}
jg an_error_routine ; this is not quite as above but i validate out blank records so this is " erm ...safety coding !! "
cmp byte ptr Inputbuffer[ecx],0
je Somelabel
dec ecx
cmp ecx .... xxx ; do some check re Inputbuffer
///////////////////////////////////////////////////////////////////////////////////
regards mikeb
mikeburr,
I don't recall any tests with both. We have made a few tests recently (http://masm32.com/board/index.php?topic=4067.msg89729#msg89729)but mostly with vector instructions.
However, I don't think the repeat instructions will do any better. Only rep movsb has been optimized not the others.
That's dependable from hardware, so good style of programming is to have set of macroses for common and specal CPU instructions - what client will request.
Test is also will give variable results for etalon, special, server, hi-end, pc, notebook.
Here is a simple testbed for you :thup:
include \masm32\include\masm32rt.inc
.code
start:
mov esi, InputFile("\Masm32\include\Windows.inc")
mov ebx, ecx ; #bytes
push 9
.Repeat
lea edi, [esi+4000] ; skip the first S.INC
push rv(GetTickCount)
mov ecx, ebx
mov al, "S"
; int 3
.Repeat
repne scasb
.Until dword ptr [edi]=="CNI." ; .INC
invoke GetTickCount
pop ecx
sub eax, ecx
print str$(eax), " ticks", 9
print left$(edi, 40), 13, 10
dec dword ptr [esp]
.Until Sign?
inkey "ok?"
exit
end start
They are old junk that live in microcode, don't waste your time on them.
It's actually surprisingly fast on my old Core i5 (source attached, no MasmBasic installation required):
1030 ticks repne scasb .INC be modified but
1092 ticks find$() .INC be modified but
1014 ticks CRT strstr .INC be modified but
Timings are for 1000x find S.INC at the end of Windows.inc
Thanks JJ ... thanks for all your effort .. i wouldn't have been able to do anything nearly as comprehensive ..ill try it on my machine and report back but it wont be for a few days ... many thanks again ..guessing that they wouldn't be that dissimilar is OK but you generally Cant Beat real Evidence
regards Mike B
PS why are you doing graphical plots of Life Expectancy in Different Countries ??
Quote from: mikeburr on December 13, 2019, 04:25:12 AM
Thanks JJ ... thanks for all your effort .. i wouldn't have been able to do anything nearly as comprehensive ..ill try it on my machine and report back but it wont be for a few days ... many thanks again ..guessing that they wouldn't be that dissimilar is OK but you generally Cant Beat real Evidence
regards Mike B
PS why are you doing graphical plots of Life Expectancy in Different Countries ??
I think JJ wants to show that the OIL industry has doubled our life expectancy over the last 150 years. :biggrin:
Quote from: mikeburr on December 13, 2019, 04:25:12 AM
PS why are you doing graphical plots of Life Expectancy in Different Countries ??
Universe 25 ; A Mice Utopia (paradise).
Quote from: mikeburr on December 13, 2019, 04:25:12 AMPS why are you doing graphical plots of Life Expectancy in Different Countries ??
Data plots and presentation are my hobby (see also GDI+ (http://masm32.com/board/index.php?topic=94.msg55559#msg55559)), and life expectancy is perhaps the most interesting data set readily available on the web. I also like playing with Excel (http://masm32.com/board/index.php?topic=94.msg55596#msg55596).
> I think JJ wants to show that the OIL industry has doubled our life expectancy over the last 150 years.
Humerous part is that the oil industry probably has helped extend human life spans due to heating, electricity, transport and lubrication. I am sure they did so for purely altruistic reasons. :tongue:
Quote from: jj2007 on December 13, 2019, 12:34:06 PM
Quote from: mikeburr on December 13, 2019, 04:25:12 AMPS why are you doing graphical plots of Life Expectancy in Different Countries ??
Data plots and presentation are my hobby (see also GDI+ (http://masm32.com/board/index.php?topic=94.msg55559#msg55559)), and life expectancy is perhaps the most interesting data set readily available on the web. I also like playing with Excel (http://masm32.com/board/index.php?topic=94.msg55596#msg55596).
Also seen map drawing,why don't add a. Fun quiz to geography and country stats on different things?
Quote from: daydreamer on December 14, 2019, 12:00:52 PMAlso seen map drawing,why don't add a Fun quiz to geography and country stats on different things?
Good idea, but I don't want to hijack this thread, so I posted the answer here (http://masm32.com/board/index.php?topic=6483.msg90149#msg90149) :thup: