• sxeraverx (unregistered) in reply to normal

    Unfortunately, not. With two calls to random, it's even more random!

  • Daniel (unregistered) in reply to joost
    joost:
    I can also confirm that any coder worth his salt uses the XOR version.
    Syarzhuk:
    I remember wondering every time I saw that - do savings of one byte justify the loss of about half-second needed to understand what it's doing?
    Actually, it does. Assembly is rarely written by hand these days and compiler output is full of idioms of this sort. The XOR clearing in particular is nearly universal. See also the Intel Architecture Optimization Reference Manual -- General Optimization Guidelines: "Use appropriate instructions that support dependency breaking (PXOR, SUB, XOR instructions)."

    Avoiding partial register stalls is another reason to use XOR -- it is recognized as a zeroing instruction since at least the early Pentium era.

    The real problem arises when people are trying to outsmart the compiler and code stuff in assembler without doing any measurements. I've seen this a lot in the Delphi System unit code, for example: "Tricks" like storing two independent byte variables in the same register (e.g. AL and AH), in a failed attempt to be clever and enhance register space. If you do that in a tight loop it can seriously impact performance (the Pentium III was particularly vulnerable).

    Thus, when doing assembler, you really need to RTFM. Repeatedly.

    (Oh, and it's a 3-byte difference in 32-bit code. As for Jed, I think he was just trying to be humorous.)

  • NerfedCharPlayer (unregistered)

    // if the auto-breakout feature hasn't kicked in yet then "there is a serious problem"...

    where? lets randomly choose if the problem is in the programmer.

  • tharpa (unregistered)

    When I read most of the comments of people, I'm impressed by their shallowness. I mean like, so what? If a programmer uses a little bit of imagination, so what? I've maintained different people's code, and they have different styles and are dealing with different situations. Everyone thinks their style is best. A lot of things are like the old Word vs. WordPerfect debates. Users of each would think theirs was better.

    I'd rather work with a person who knows how to think for himself than someone who just accepts popular opinion without question.

  • smoogalhead (unregistered) in reply to Jake Heidt

    Are you being sarcastic? I can only guess so.

    I think his absurdly long functions are a joke about people using these functions instead of the basic syntactical operators such as "=" or "==".

    You need a lesson in such humour.

    Anyway, the point of the article is that he had time to do that when he should have been working.

  • TonyTwoTones (unregistered)
    It has some 'goto optimization' in it to speed up the slow parts.

    Oh yes, I am quite sure your code has been optimized to the fullest!

Leave a comment on “Happy (Belated) Jed Day!”

Log In or post as a guest

Replying to comment #:

« Return to Article