flat assembler
Message board for the users of flat assembler.

Index > Heap > my first time


Have You ever used cmovle?
yes
13%
 13%  [ 3 ]
no
86%
 86%  [ 20 ]
Total Votes : 23

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
Have You ever used cmovle?

its my first time: Wink

Code:
include '%fasminc%\win32ax.inc'

.data
    bufor rb 20
.code
start:
    mov eax,10
    mov ebx,20
    cmp eax,ebx
    cmovle eax,ebx
cinvoke wsprintf,bufor,"eax holds: %d",eax
invoke MessageBox,0,bufor,"info",0
invoke ExitProcess,0
.end start
    

_________________
Microsoft: brings power of yesterday to computers of today.
Post 14 Feb 2005, 14:26
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i quess it is pretty slow compared to code that does same job. Also it may cause some code readability problems because most coders aren't familiar with these new pentium instruction.
And third thing, windoze PE file should run under 386, otherwise it should check processor and throw error if it doesn't have needed instruction. Now you see why these instruction aren't used so widely.
Post 14 Feb 2005, 15:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
Actually, I'm very familiar with those (and some MMX/SSE instructions too) because I also do a lot of speed optimizations for newer CPUs. But I guess most Fasm users rather tend to do size optimizations and call speed optimized code "sloppy" and "unoptimized".
Post 14 Feb 2005, 19:52
View user's profile Send private message Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
I have terrible head ache :
Code:
Opcodes:
aaa aad aam aas adc 
add addpd addps addsd addss 
and andnpd andnps andpd andps 
arpl bound bsf bsr bswap 
bt btc btr bts call 
cbw cdq clc cld clflush 
cli clts cmc cmova cmovae 
cmovb cmovbe cmovc cmove cmovg 
cmovge cmovl cmovle cmovna cmovnae 
cmovnb cmovnbe cmovnc cmovne cmovng 
cmovnge cmovnl cmovnle cmovno cmovnp 
cmovns cmovnz cmovo cmovp cmovpe 
cmovpo cmovs cmovz cmp cmppd 
cmpps cmps cmpsb cmpsd cmpss 
cmpsw cmpxch8b cmpxchg comisd comiss 
cpuid cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi 
cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd 
cvtps2pi cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss 
cvtss2sd cvtss2si cvttpd2dq cvttpd2pi cvttps2dq 
cvttps2pi cvttsd2si cvttss2si cwd cwde 
da daa das db dd 
de dec df di div 
divpd divps divsd divss dl 
dq ds dt dw emms 
enter f2xm1 fabs fadd faddp 
fbld fbstp fchs fclex fcmovb 
fcmovbe fcmove fcmovnb fcmovnbe fcmovne 
fcmovnu fcmovu fcom fcomi fcomip 
fcomp fcompp fcos fdecstp fdisi 
fdiv fdivp fdivr fdivrp feni 
ffree fiadd ficom ficomp fidiv 
fidivr fild fimul fincstp finit 
fist fistp fisub fisubr fld 
fld1 fldcw fldenv fldl2e fldl2t 
fldlg2 fldln2 fldpi fldz fmul 
fmulp fnclex fndisi fneni fninit 
fnop fnsave fnstcw fnstenv fnstsw 
fpatan fprem fprem1 fptan frndint 
frstor fsave fscale fsetpm fsin 
fsincos fsqrt fst fstcw fstenv 
fstp fstsw fsub fsubp fsubr 
fsubrp ftst fucom fucomi fucomip 
fucomp fucompp fwait fxam fxch 
fxrstor fxsave fxtract fyl2x fyl2xp1 
hlt idiv imul in inc 
ins insb insd insw int 
into invd invlpg iret iretd 
ja jae jb jbe jc 
jcxz je jecxz jg jge 
jl jle jmp jna jnae 
jnb jnbe jnc jne jng 
jnge jnl jnle jno jnp 
jns jnz jo jp jpe 
jpo js jz lahf lar 
ldmxcsr lds lea leave les 
lfence lfs lgdt lgs lidt 
lldt lmsw lock lods lodsb 
lodsd lodsw loop loope loopne 
loopnz loopz lsl lss ltr 
maskmovdqu maskmovq maxpd maxps maxsd 
maxss mfence minpd minps minsd 
minss mov movapd movaps movd 
movdq2q movdqa movdqu movhlps movhpd 
movhps movlhps movlpd movlps movmskpd 
movmskps movntdq movnti movntpd movntps 
movntq movq movq2dq movs movsb 
movsd movss movsw movsx movupd 
movups movzx mul mulpd mulps 
mulsd mulss neg nop not 
or orpd orps out outs 
outsb outsd outsw packssdw packsswb 
packuswb paddb paddd paddq paddsb 
paddsw paddusb paddusw paddw pand 
pandn pavgb pavgw pcmpeqb pcmpeqd 
pcmpeqw pcmpgtb pcmpgtd pcmpgtw pextrw 
pinsrw pmaddwd pmaxsw pmaxub pminsw 
pminub pmovmskb pmulhuw pmulhw pmullw 
pmuludq pop popa popad popf 
popfd por prefetchnta prefetcht0 prefetcht1 
prefetcht2 psadbw pshufd pshufhw pshuflw 
pshufw pslld pslldq psllq psllw 
psrad psraw psrld psrldq psrlq 
psrlw psubb psubd psubq psubsb 
psubsw psubusb psubusw psubw punpckhbw 
punpckhdq punpckhqdq punpckhwd punpcklbw punpckldq 
punpcklqdq punpcklwd push pusha pushad 
pushf pushfd pxor rcl rcpps 
rcpss rcr rdmsr rdpmc rdtsc 
rep repe repne repnz repz 
ret retf rol ror rsm 
rsqrtps rsqrtss sahf sal sar 
sbb scas scasb scasd scasw 
seta setae setb setbe setc 
sete setg setge setl setle 
setna setnae setnb setnbe setnc 
setne setng setnge setnl setnle 
setno setnp setns setnz seto 
setp setpe setpo sets setz 
sfence sgdt shl shld shr 
shrd shufpd shufps sidt sldt 
smsw sqrtpd sqrtps sqrtsd sqrtss 
stc std sti stmxcsr stos 
stosb stosd stosw str sub 
subpd subps subsd subss sysenter 
sysexit test ucomisd ucomiss ud2 
unpckhpd unpckhps unpcklpd unpcklps verr 
verw wait wbinvd wrmsr xadd 
xchg xlat xlatb xor xorpd 
xorps    

AMD Opcodes:
pavgusb pf2id pfacc pfadd pfcmpeq 
pfcmpge pfcmpgt pfmax pfmin pfmul 
pfnacc pfpnacc pfrcp pfrcpit1 pfrcpit2 
pfrsqit1 pfrsqrt pfsub pfsubr pi2fd 
pmulhrw pswapd 
    


is't it to many opcodes?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 15 Feb 2005, 08:37
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
Hi Harry Turtle, you could post your garbage in my "having fun with assembly language" thread in the Heap section Wink
Post 15 Feb 2005, 08:41
View user's profile Send private message Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
could anyone move this topic onto heap? please.

_________________
Microsoft: brings power of yesterday to computers of today.
Post 15 Feb 2005, 09:50
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
WARNING: Unexplained regular expressions!
It's all about seeing the patterns Smile (some easier than others, uhm, well, most things are hard untill one understands them, oddly enought Wink)

Opcodes:
/aa[adms]/ = "ASCII Adjust for (add|divide|multiply|substract)"
add = "uhm? add?" Razz (also the other basic ones, sub, /[ i]?mul/, /[i ]?div/ )
adc = add + carry
/add[ps][sd]/ = "Add (Packed|Scalar) (Single|Double) precission FP Values"
...
and, or, xor, neg, not - the "basic" bit operations Smile
...
/bt[crs]?/ = bit test ( (with (compliment|reset)) |(and set) )

cmovxx = as with "jxx"
...
jmp = jump (not ever to be confused with the devils command "GOTO" Razz )
jxx = jump [insert fancy condition] (where condition is something like above, less, a flag (eg "c" for CF (carry flag) )
...
mov = shove bits from A to B (well, rather "copy"/"replicate" - why didn't they name it cpy or something like that?)
mov[z-a0-9]+ = "fancy mov" (eg move and do sign extend (movsx), move quadword (movq), )
move packed single precision FP Low to High (movlhps)
...
nop - nope wont do much Smile
...
I guess you get the idea Wink
And see, it's not all that odd, once you get to know the mnemonics it all becomes as logic as 1,2,3, Smile

(but don't worry, no one learns it all by heart for life ast once (some do, but it's usuaklly a matter of talent and time spent in the dark cellar with the ssh terminal as only light source Wink) - but if you eg do lot's of SIMD code you'll pretty soon read movlhps as "move packed single precision FP Low to High", just as you read "mov" as "move" or jnz as "jump if not zero", but you might have forgotten what CMPXCHG8B is and does and how it works (compare and exchange 8 bytes))

Too many opcodes? Uhm, well, some say yes (RISC people) some say no (CISC people) - matter of design and preference Smile
Post 15 Feb 2005, 22:02
View user's profile Send private message Visit poster's website Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
it is look like I am very RISCy (read risky) Wink

thx a lot for explanation Scientica !
I have a hope the list of opcodes won't be grow... Wink

_________________
Microsoft: brings power of yesterday to computers of today.
Post 15 Feb 2005, 23:17
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
How many people still use a 386? Cave Dwellers? Eskimo's?
just use those instructions if they make you happy, and assume everybody is using at least a pentium ii or better, if your not, TOO BAD!!! I believe those instruction are better on the PIII, and PIV, due to branch predicting on these processors, but that subject is way over my head, woooo, there they are, WAY over my head, way HIGH!!!
MadMatt
Post 15 Feb 2005, 23:44
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Quote:
How many people still use a 386?


I still use a 386 Smile
Post 16 Feb 2005, 01:14
View user's profile Send private message Visit poster's website Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
AFAIK, CMOVxx has no effect on pipeline, so I son't see any other similarity.
Post 16 Feb 2005, 01:31
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
crc: Why? Are you a collector of these old contraptions?

beppe85: No branches are taken ever, so for a PIII or PIV this is good (faster)
Post 16 Feb 2005, 07:11
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
Why don't you appreciate the unquestionable beauty of 386 machine? Wink At least with DOS it's great.
Post 16 Feb 2005, 07:27
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
madmatt: I do have quite a few older computers. The 386 is my personal favorite for various reasons. (Not least of which is the lack of opcodes that I'll never use). That being said, I do use a P4 box for most of my work now; but the fact that my software will run at a good speed on anything from a 386 and up is pretty nice.
Post 16 Feb 2005, 11:17
View user's profile Send private message Visit poster's website Reply with quote
rob.rice



Joined: 20 Dec 2003
Posts: 54
rob.rice
I still use a 486 laptop
unless you just have to run the latest windoze you don't need the latest computer
this is one hidden cost of windoze that windoze lovers and M$ try to hide
people just don't know how much computing power thay have because windoze
eats almost all of it up just running it self
Post 06 Apr 2005, 20:00
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Quote:

unless you just have to run the latest windoze you don't need the latest computer
this is one hidden cost of windoze that windoze lovers and M$ try to hide

You don't do a lot of video editing/compressing or other heavily cpu-intensive tasks, do you? Wink

I'd say assuming at least a pentium is safe these days. I can't see a problem with requiring MMX, although I would test for it's presence before using it.

Whether requiring more than MMX support is fair, depends on your application I guess. If you're working on a realtime codec, requiring SSE support would be fair (from the idea that "processors old enough to not have SSE would be too slow to run the codec anyway"). Same goes for games.

Requiring CMOVcc for regular apps because it's "cuter than branching" probably isn't fair, though - if you don't require much CPU speed to have your application run, you ought to support older processors.

Btw, con't use CMOVcc if you can avoid it - quoting Agner Fog's pentopt:
Quote:

But conditional move instructions have two important disadvantages:

1. they make dependence chains longer
2. they introduce an unnecessary dependence on the operand not chosen

A conditional move is waiting for three operands to be ready before it can be executed: the condition flag and the two move operands. You have to consider if any of these three operands are likely to be delayed by dependence chains or cache misses. If the condition flag is available long before the move operands then you may as well use a branch, because a possible branch misprediction could be resolved while waiting for the move operands. In situations where you have to wait long for a move operand that may not be needed after all, the branch may be faster than the conditional move despite a possible misprediction penalty. The opposite situation is when the condition flag is delayed while both move operands are available early. In this situation the conditional move is preferred over the branch if misprediction is likely.


So, CMOVcc isn't the holy grail Smile
Post 06 Apr 2005, 20:17
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.