News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Pairs of macros

Started by jj2007, July 01, 2009, 08:14:47 PM

Previous topic - Next topic

jj2007

Some days ago DednDave was a bit down because he saw no chance to beat the 20 cycles of drizz' qword to ascii routine:

Qword to Ascii algos:
666     cycles for Asc64
20      cycles for U64ToStr


Very unfair, and very stupid of me:
counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
push offset AscBuf2
push dword ptr MyQword[4]
push dword ptr MyQword[0]
call U64ToStr
print str$(eax), 9, "cycles for U64ToStr"


Just in case you have not seen within some 1,000 cycles where Ze Bug is, here is a technique that might help to avoid such errors:

include \masm32\include\masm32rt.inc

MacStart macro
  .if 1
mov eax, 123
ENDM

MacEnd macro
shr eax, 1
  .endif
ENDM

.code
start:
MacStart
MsgBox 0, "Test", "Hi", MB_OK
MacEnd

exit ; short form of invoke ExitProcess, 0

end start


It will assemble fine - but try again with MacEnd commented out :bg

dedndave

well - at least i know the easy way to get mine down to 20 cycles   :dance:
i wasn't really down at all
that routine is "the baseline" standard multiple-precision division method
i didn't really expect it to be super fast
but, 108:1 ratio was a bit of a shock - lol
when i looked at Drizz's code and saw there were more than 20 instructions (lol), i figured there was something for me to learn from
i do know that my routine always returns the correct string
i am writing a little test program to run the others through the numbers
it would be nice to know if Paul Dixon's and Lingo's mod of Paul's provide proper results in all cases
they are a bit large, however, and i don't think Drizz and I are done improving ours yet
i like Drizz's latest version - no branches - if he can squeeze some clocks out of it, it will be a good one