Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two-off code in program that runs in about 0.25 seconds

14 views
Skip to first unread message

Robert Prins

unread,
Apr 16, 2023, 7:23:01 AM4/16/23
to
Current code, simplified:

mov ecx, 10
cdq
div ecx
cdq
div ecx

Equivalent faster, but longer code:

imul eax, 0xcccd
shr eax, 19
imul eax, 0xcccd
shr eax, 19

And yes, as EAX is guaranteed to be small (<= 200) it is equivalent!

Should I really care, or not? And what would a modern compiler generate?

Robert
--
Robert AH Prins
robert(a)prino(d)org
The hitchhiking grandfather - https://prino.neocities.org/
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

0 new messages