From: "Rob van der Heij" <[email protected]>
Sent: Tuesday, June 03, 2014 1:00 AM


I've been reading about it, but mostly ignored it as not too important for
what I do. But...

More recently I've been working on porting Linux gcc object code to CMS,
and now that I needed a nice checksum routine, I figured I might take a
popular open source checksum routine http://en.wikipedia.org/wiki/Adler-32
and let gcc compile and optimize it. Since the generated assembler source
wasn't that obvious to me, I was getting interested to know why.

My simplistic implementation was like this (for each byte, so wrapped in a
loop)


*  IC        R4,0(R6)  AR        R2,R4     AR        R3,R2   *


Must have muissed something here.
A 3-instruction loop to sum bytes.

        LA 6,X+offset (last byte of area to be summed)
        SR 2,2
        SR 4,4
Loop IC 4,0(0,6)
        AR 2,4
        BCT 6,Loop

And you can use BCTR to save a few µS.


---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

Reply via email to