News:

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

Discussion on instructions

Started by jj2007, August 10, 2008, 02:01:21 PM

Previous topic - Next topic

jj2007

Quote from: Mark_Larson on August 27, 2008, 02:29:47 PM
Quote from: jj2007 on August 27, 2008, 08:06:53 AM
Bring me evidence (timings, lab tests, proof that CPU temperature is rising, and calculations how that would increase energy consumption if applied to all Google servers in the World) that there is a significant difference between .if eax and test eax, eax

Quote
When I was at Dell the hardware guys had to do thermal testing of the processors.  They had a program that ran different kinds of code.  It started out with ALU code, FP code, MMX code, and finally SSE2 coded.  When it hit the SSE2 code, the temperature was at it's hottest. :thumbu

I hope you are not seriously suggesting that using SSE2 is bad programming practice?

Please contact your old friends at Dell. We'll put up a serious test: How much % extra energy consumption when using .if eax (aka or eax, eax) instead of test eax, eax while booting Vista? Since they are building notebooks, they must be concerned about battery life issues.

Mark_Larson

Quote from: jj2007 on August 27, 2008, 02:41:23 PM
Quote from: Mark_Larson on August 27, 2008, 02:29:47 PM
Quote from: jj2007 on August 27, 2008, 08:06:53 AM
Bring me evidence (timings, lab tests, proof that CPU temperature is rising, and calculations how that would increase energy consumption if applied to all Google servers in the World) that there is a significant difference between .if eax and test eax, eax

Quote
When I was at Dell the hardware guys had to do thermal testing of the processors.  They had a program that ran different kinds of code.  It started out with ALU code, FP code, MMX code, and finally SSE2 coded.  When it hit the SSE2 code, the temperature was at it's hottest. :thumbu

I hope you are not seriously suggesting that using SSE2 is bad programming practice?

Please contact your old friends at Dell. We'll put up a serious test: How much % extra energy consumption when using .if eax (aka or eax, eax) instead of test eax, eax while booting Vista? Since they are building notebooks, they must be concerned about battery life issues.

they are right, you don't want to admit you are wrong.

you said you wanted proof of it using more resources.  done.  and done posting since it's obviously a waste of time.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Rockoon

Quote from: jj2007 on August 27, 2008, 08:06:53 AM
As an economist, I am truly concerned about resource use. Bring me evidence (timings, lab tests, proof that CPU temperature is rising, and calculations how that would increase energy consumption if applied to all Google servers in the World) that there is a significant difference between .if eax and test eax, eax, and I will fall on my knees, praise Rockoon The Genius and quote you the rest of my life.

The first, obvious significant difference:

'.if eax' produces 2 instructions while 'test eax, eax' is a single instruction.

Now i'm sure that you are cursing yourself for not including a conditional branch with the test instruction.. so I am going to give you a pass on that..

.if eax produces 2 instructions right next to each other which you cannot seperate. You cannot place an instruction in between these two when it is sometimes advantageous from a performance standpoint to do so.

Further, it is non-trivial to make the second instruction a target of a branch which is sometimes advantageous from a performance perspective (why perform a cmp/test/whatever when the flags already have the information?)

And finally, my point about .if wasnt even performance related. I said exactly what my point was, but you convieniently ignored that point in order to have a leg to stand upon.

My point was related to you suggesting that newbie assembly language programers should use it. No, they shouldn't. They need to learn about the flags register and about which instructions effect them, as well as which instruction effect only some of them. The flags are the core of program flow, and are key to many big optimizations which avoid changing program flow. Directives such as '.if' are shackles.

When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

hutch--

The area of "newbie" programming is one I have a reasonable amount of mileage in and the assumption that learner programmers should have to start with bare mnemonic decision making is a serious mistake that is still being flogged by some. My generation grew up with bare mnemonic coding and many held that prejudice well past its necessity through habit and conservatism.

A field of programming like assembler is abstract enough to start with and this is where learners have the greatest difficulty even though many have programming experience in other languages. The old approach saw assembler programming collapse through lack of interest while having a eputation of being unreadable, unlearnable and un-necessary. The new approach of using everything that was available including pseudo high level constructs, RC style resources, macros, libraries, modular programming techniques, algorithm design, complex data structures and anything else that was in the rangle of conventional programming techniques put assembler programming back on the map as a viable language for high performance applications.

Put in short form, the olf style failed where the new style succeeded because it was learnable where the old stuff wasn't. A large number of people who started the old way failed and wrote NO ASSEMBLER code, those who start with the new approach get much more writen much more easily and get to see enough assembler code to learn the more complex and abstract lower level formats.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: Rockoon on August 27, 2008, 04:52:38 PM
Quote from: jj2007 on August 27, 2008, 08:06:53 AM
As an economist, I am truly concerned about resource use. Bring me evidence (timings, lab tests, proof that CPU temperature is rising, and calculations how that would increase energy consumption if applied to all Google servers in the World) that there is a significant difference between .if eax and test eax, eax, and I will fall on my knees, praise Rockoon The Genius and quote you the rest of my life.

The first, obvious significant difference:

'.if eax' produces 2 instructions while 'test eax, eax' is a single instruction.
Maybe you should read this post on page 3 of this thread? It's nicely described there, at newbie level.

Quote
Now i'm sure that you are cursing yourself for not including a conditional branch with the test instruction.. so I am going to give you a pass on that..
No, I am not cursing myself; on the contrary, I will drink a glass of wine on your health - it's good to know you can be generous and have a sense of humour :toothy

Quote
.if eax produces 2 instructions right next to each other which you cannot seperate. You cannot place an instruction in between these two when it is sometimes advantageous from a performance standpoint to do so.

Further, it is non-trivial to make the second instruction a target of a branch which is sometimes advantageous from a performance perspective (why perform a cmp/test/whatever when the flags already have the information?)
What you say is absolutely correct. Newbies are bound to discover optimisation after having successfully written their first ten thousand lines of code.

Quote
And finally, my point about .if wasnt even performance related. I said exactly what my point was, but you convieniently ignored that point in order to have a leg to stand upon.
If I understood you well, you wanted to help Al Gore saving The Climate by banning or eax, eax. To which Mark conveniently added that at Dell's they found higher temperatures for SSE2 instructions (which for him is The Proof, although I am just a humble economist unable to follow his line of argument).

Quote
My point was related to you suggesting that newbie assembly language programers should use it. No, they shouldn't. They need to learn about the flags register and about which instructions effect them, as well as which instruction effect only some of them. The flags are the core of program flow, and are key to many big optimizations which avoid changing program flow. Directives such as '.if' are shackles.
Hmmm... I had the good intention to not spoil the excellent post of Sir Hutch right above this one, but I cannot refrain from asking the obvious question: If .if directives are shackles, then for whom did Microsoft write them? For seasoned young programmers like you?

Prost :U

PBrennick

JJ,

QuoteNo, I am not cursing myself; on the contrary, I will drink a glass of wine on your health - it's good to know you can be generous and have a sense of humour

I think, between typing nonsense on the Internet and drinking that wine all day, you have time for little else. How old are you, anyway? This whole conversation thing is beginning to remind me of someone else who used to do this until he hit the age of 18. He used to drive me crazy also. Have you tried Harold's board, they may be more attuned to your way of thinking andf you all can have a very cheery time.

Seriously, JJ, this is not fun any more and you should stop it.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

ChrisLeslie

It is definitely time that this thread got put to sleep. :boohoo:

jj2007

Quote from: ChrisLeslie on August 28, 2008, 05:52:01 AM
It is definitely time that this thread got put to sleep. :boohoo:

.if humour == 0
     .break
.else
    MsgBox 0, "One more game?", " :bg "
.endif

sinsi

Quote from: jj2007 on August 28, 2008, 07:07:48 AM
    MsgBox 0, "One more game?", " :bg "
Game over. Go to bed young man.
Light travels faster than sound, that's why some people seem bright until you hear them.

drizz

.if eax & eax

test eax,eax
.if !zero?

its all about not having to make up labels for every meaningless loop/branch...

PS: didn't read all the posts
The truth cannot be learned ... it can only be recognized.

jj2007

Good point, drizz, your examples are certainly not as evil as the simple .if eax :U

      .if eax & eax
         nop
      .endif
;test eax, eax
;je short ..
;nop

      test eax,eax
      .if !zero?
         nop
      .endif
;test eax, eax
;je short ..
;nop

      .if eax
         nop
      .endif
;or eax, eax
;je short ..
;nop

      .if eax !=0
         nop
      .endif
;or eax, eax
;je short ..
;nop

      .if !eax==0
         nop
      .endif
;or eax, eax
;jne short ..
;nop

hutch--

 :bg

> its all about not having to make up labels for every meaningless loop/branch...


  @@:
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php