I 'm a dos assemble programmer and I'm moving to win32 programming one of the techniques I learned. in asm is to use
statment other than to save runtime. Now I want to know how to calculate runtime in windows
Posted on 2001-11-25 06:51:20 by amr
The basic instructions are the same, ADD SUB MUL DIV...

The difference is that you now have access to the 32 bit registers. Just like the "old" 16 bit AX includes the 8 bit AL, the new 32 bit EAX includes AX. All 32 bit regs are prefixed with an E. EAX EBX ECX EDX ESI EDI...

You should always use the 32 bit regs when possible. You can still use the 16 bit regs, but an operand size prefix byte is added to any instruction that does, and this slows things down. Hutch's MASM32 package comes with an optimization .HLP file by Agner Fog that explains this in great detail. An instruction reference .HLP file is also included with MASM32.

The other major difference is the flat memory model. You never need to use (or mess with) the segment registers, which are still 16 bit by the way.

Posted on 2001-11-25 16:10:31 by S/390
After rereading your post, I may have misunderstood the question. If you are talking about instruction times, it varies with the processor. You can get a basic idea by using the /Sc commamd line option on ML. This adds an instruction time to the listing file. The time varies with the processor directive, .386 .486 .586 ...

Since the various Pentium models have different features like pipelines and out-of-order execution, these times aren't really very accurate. In many cases you can execute more than 1 instruction per clock.

Again, Agner Fog's guide explains the differences on each processor. :)
Posted on 2001-11-25 16:43:30 by S/390
Thanks for your replay but acutally I know all you have talked about but what is the difference between .386 .486 ,.... and so on operatives and where I can get my processor runtime details
my processor is athelon amd 800 mhz .
Posted on 2001-11-26 03:40:08 by amr

I can't help you much with the Athelon specs. Have you looked at the AMD site?

As for .386 .486 etc, it tells MASM which instructions are allowed in the program. For example, if you try to use an instruction that is only valid on a Pentium, and you specify .386 or .486, MASM will flag the instruction during assembly. And as I mentioned, it controls the "estimated" instruction times in the listing when you use /Sc.

Posted on 2001-11-26 11:53:02 by S/390

I have looked the amd website but I couldn't find anything in it,
my other question is that What is the differences between pentium and 486 what are the new instructions ?What is mmx?
What is 3dnow support? and thanks for your help
Posted on 2001-11-27 05:51:51 by amr
There weren't (m)any instructions added to the Pentium that I can think of!

The main differences between the 486 & Pentium:
Pentium definitely has an FPU (only the DX 486s had them).
Pentium has better branch prediction.
Some pentiums had trouble counting.
Pentiums have a bigger L1 cache (I think).

By far and away the biggest change in the Pentium was the addition of the second instruction pipeline. Certain instructions can be executed on one or the other pipe, and some can be executed on both. If you choose your instructions carefully, and re-order in places, you can get two instructions to execute in the same clock. There are certain conditions, like the instructions being used can execute on different pipes (some cannot execute in parrallel with other instructions), they cannot access the same registers (mov eax, 1 / add eax, 1 will not execute in parrallel, mov eax, 1/ add ebx, 1 will).

What is mmx?
MMX are a series of added instructions (and register definitions) to aid multi media apps. They are all integer based, and can dramatically improve performance, they share the same register space as the FPU, and so you cannot use mmx and fpu instructions together (unless you store all relevant data somewhere, and then switch modes, which will kill performance). I'm not too well up on the MMX stuff, but others here know a fair bit about it.
Processors which support MMX are the Pentium MMXs (PPlain + MMX instructions), and the K6 (possibly K6-2) from AMD, and all later processors (Celeron, P2, PIII, PIV, K6, Athlon, Duron, Ezra).

3DNow was an effort on AMDs part to bring MMX type improvments to the floating point world. The chips to support 3DNow are the K6-2, K6-3, Athlon, and Duron chips. Support is limited for the instruction set (its not Intel after all), so its kind of out in the cold unless your targeting Athlons, or a specific Athlon patch.
Intel quickly realised 3DNow was a good idea, and made SSE, and later SSE2. SSE support comes from PIII, later Celerons, PIV, and the Athlon XP, Athlon MP, and Athlon 4 (the mobile chipset).
Only the PIV supports SSE2.

You can detect MMX/SSE/SSE2 support with the CPUID instruction.

Posted on 2001-11-27 06:52:56 by Mirno
Thanks All,
I thanks for support but I need a more detailed discribtion for the inside processor circuity to understand how it goes, and other thing that I want to know is these instructions packages.
what are the new instructions supported by 3dnow ? and MMX and how can I use them in my programs.
my concerns really is about code optimization so I am looking for all the ways to optimize my programs to work much faster I know some techniques like using or rather than cmp instruction it really saves time. and others that was for example only .Do you know how to use the interepts in my win32asm programs?
Other thing I'm concerned in is the convertion of C code to assembly code, I changed much code. but I need more and I'm a new win32 programmer, I programmed in dos.
Posted on 2001-11-28 08:47:00 by amr
You may need to be a bit more specific on what "c" code you are trying to port :) As for interupts -- you can't use them in windows assembly -- Thank god... that's a part of assembly I'm glad was left behind

Posted on 2001-11-28 09:25:28 by Sliver
Intel's docs will outline all the new instructions, and how to use them.
They can be found at http://developer.intel.com

As for optimisation, things have changed a lot since DOS, and old optimisations are not necessarily things to do today.
The or vs cmp trick doesn't improve performance on a per-instruction basis, and hasn't from the 386 onwards ("cmp eax, 0", and "or eax, eax" both took two clocks to execute on 386s, 1 clock on 486s, and can both execute alongside other instructions on Pentium and above). The only way it improves the performance is in terms of code density. It'll take less space in the CPU instruction cache, and so you can fit more in it!

If your looking for optimisations, I suggest you read the Agner Fog help file provided in the MASM32 package. Also read the Intel developers manuals (volume 2 & 3 have the most relevant stuff).

Posted on 2001-11-28 10:14:51 by Mirno
C code that I talked about the is mainly math code, logical operators code and hardware control code. Although it is much easier to code hardware in C or Basic, but I code it in assembly to have a detailled look on the inside work of the hardware. That's about C code.
Posted on 2001-11-28 19:45:28 by amr