Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

You might have mail.


devel / comp.lang.asm.x86 / Two-off code in program that runs in about 0.25 seconds

SubjectAuthor
o Two-off code in program that runs in about 0.25 secondsRobert Prins

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

<u1glo3$2h6pq$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=430&group=comp.lang.asm.x86#430

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: robert@nospicedham.prino.org (Robert Prins)
Newsgroups: comp.lang.asm.x86
Subject: Two-off code in program that runs in about 0.25 seconds
Date: Sun, 16 Apr 2023 14:21:27 +0000
Organization: A noiseless patient Spider
Lines: 26
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <u1glo3$2h6pq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="4268555b5cfb331527b14cec0a33b8fc";
logging-data="2664001"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bi6P7rx6YRQhBb+2yQTB1ioNoKP0t6TI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:EBlN2wRTT5FXkZzvOl17gyIAMPI=
 by: Robert Prins - Sun, 16 Apr 2023 14:21 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor