flat assembler
Message board for the users of flat assembler.
Index
> Main > The most useless instruction Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next |
Author |
|
Overflowz 13 Jul 2011, 06:38
CPUID maybe ?
|
|||
13 Jul 2011, 06:38 |
|
MazeGen 13 Jul 2011, 07:26
revolution wrote: Well I can guess what you mean here, but actually the opcode is the same. There is a special short form binary encoding though. Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2A: Instruction Set Reference, A-M wrote: 1.3.3 Instruction Operands Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2A: Instruction Set Reference, A-M wrote: 2.1.2 Opcodes |
|||
13 Jul 2011, 07:26 |
|
Overflowz 23 Jul 2011, 10:07
I think NEG is useless. I really don't know why to use it. I'm using NOT instead.
|
|||
23 Jul 2011, 10:07 |
|
ouadji 23 Jul 2011, 10:23
Quote:
NEG != NOT, NEG == NOT + 1 how can you use "NOT" instead of "NEG" The result is not the same for both (I don't understand) |
|||
23 Jul 2011, 10:23 |
|
AsmGuru62 23 Jul 2011, 11:42
NEG is needed in some cases.
Example 1: you need to write a formatting routine, which will produce a string from a number in register. First, you write a routine which formats an unsigned value. Then the function for signed values (like -93267467) will detect if value has a sign and if it has - you call NEG on that register and then write a minus sign into the output string buffer. Then simply call the 1st routine for unsigned values. Example 2: a short routine for finding a string length of an ASCIIZ text. It may look like this: Code: ; ; EDI = ASCIIZ text ; xor eax, eax or ecx, -1 repne scasb neg ecx sub ecx, 2 ; ; ECX = strlen (EDI) ; |
|||
23 Jul 2011, 11:42 |
|
Overflowz 23 Jul 2011, 12:39
ouadji
I know that NEG == NOT + 1, but I'm just starter of assembly language so, if I need negative value, simply, I'm typing NOT and then DEC. AsmGuru62 Isn't this better one ? Code: xor eax,eax or ecx,-1 repne scasb not ecx dec ecx |
|||
23 Jul 2011, 12:39 |
|
edfed 23 Jul 2011, 13:28
i use neg in many cases.
and asciiz size is found with this: Code: .snippet: xor ecx,ecx @@: cmp byte[esi+ecx],0 je @f inc ecx jmp @b @@: ret i've made a little test application just to see the results. both asmguru and overflows solution don't works at all in my test program. then, i made my version with elementary operations. and now, i have a better idea of what can be a cool contest with fasm, then, return to the 2011 compo topic in main. |
|||
23 Jul 2011, 13:28 |
|
Overflowz 23 Jul 2011, 13:54
edfed
Not works ? Why ? I'm using it everytime and works fine! also, repne scasb is more faster than loop routine right ? and what the point of using neg or not same time ? one from them are really useless. edit: Oh, NEG modifies flags and NOT only does it's job without modifying flags. That's the reason |
|||
23 Jul 2011, 13:54 |
|
Teehee 07 Aug 2011, 12:24
i think i found the most useless instruction: JE. It works as JZ so one of them can get out
_________________ Sorry if bad english. |
|||
07 Aug 2011, 12:24 |
|
yoshimitsu 07 Aug 2011, 19:11
Quote: 74 cb JE rel8 it's just a synonym and up to your personal favor |
|||
07 Aug 2011, 19:11 |
|
Teehee 07 Aug 2011, 20:04
oh
|
|||
07 Aug 2011, 20:04 |
|
xleelz 07 Aug 2011, 20:59
most useless instruction: lz2f
why? because it's not an actual instruction |
|||
07 Aug 2011, 20:59 |
|
typedef 07 Aug 2011, 21:05
xleelz wrote: most useless instruction: lz2f xleelz is useless too. At least typedef is used in C/C++ |
|||
07 Aug 2011, 21:05 |
|
typedef 17 Aug 2011, 04:58
|
|||
17 Aug 2011, 04:58 |
|
16bitPM 29 Mar 2012, 09:48
yoshimitsu wrote: I guess by "useless" instructions you mean those, which actually consist of two operations and were implemented to provide some higher level of code to draw simplicity but ended up being much slower and are therefore negatively connotated Don't agree at all! usually these instructions are slower but also shorter. INC and ADD are NOT the same, they have a different impact on flags. A good assembly coder knows the difference and he knows when to use the right one for the job. [/QUOTE] For me, a useless instrucion is one that was explicitely implemented but failed to find any use at all. In this regard, I always considered INTO the real winner I doubt it was ever used. The only possible use I can think of is catch the exception in some higher language and use it to get out of (I)MUL overflow situations. |
|||
29 Mar 2012, 09:48 |
|
16bitPM 29 Mar 2012, 09:54
Teehee wrote: LOOP ?everybody say it is slow and should be replaced by Jcc instr. .. Quote: jecxz ? LOOP and J(E)CXZ are shorter so they can be used to make size-efficient code. Quote: xchg ebp,ebp OK but you can quote tons of nop equivalents. Consider LEA EDX,[EDX] for example. Tyler wrote: lea is pretty pointless. LEA has been quoted as one of the most useful instructions ever AND is recommended on x86 platform for replacing IMULs. Quote:
On some platforms such as windows this wil couse a page fault, because the first page of your process is marked as not-present. Similarly, on older Windowses (or perhaps even the recent ones), the 4Gb page is actually EXPAND-DOWN, which also makes the bottom 4k unusable since it would trigger a general protection fault. [quote="revolution"]FFREE I saw this one used once or twice... cod3b453 wrote: I'd go for ud2 Nah, UD2 has been explicitely added on request. For example when you want to trigger exception 6 on all intel processors ever made. bitshifter wrote: What about esc Aren't the ESC opcodes usurped by floating point opcodes? [quote="MazeGen"]My random favorites: Quote: FNOP Quote: ARPL - have anyone ever used it? My guess: it has been used in OS/2 2.0, which ran in 286 protected mode. This instruction is made for protected segmentation But I'm at least intrigued by it. Quote: INVLPG[/url] in real mode - cool, but what for? Well there you say it: it's useless in real mode... but not when PG/PE are on! Then again.... I can't see any use for SGDT in real mode vid wrote: CD03 behaves bit differently from CC. I don't recall exact details, but you should be able to find them in manuals. CC: return stack contains address of CC instruction. CD 03: return stack contains address of intruction FOLLOWING CD 03. Last edited by 16bitPM on 21 Sep 2012, 14:27; edited 2 times in total |
|||
29 Mar 2012, 09:54 |
|
revolution 29 Mar 2012, 11:49
16bitPM wrote: [quote="revolution"]FFREE |
|||
29 Mar 2012, 11:49 |
|
yoshimitsu 29 Mar 2012, 14:46
@16bitPM:
I actually thought that one would understand due to the "I guess by..." that this isn't my opinion. In fact I like these high level opcodes and use them whenever I can. I was just trying to elaborate on what I thought OP might mean with "useless instructions" as Intel wouldn't explicitely implement such. Everything got implemented for a reason. |
|||
29 Mar 2012, 14:46 |
|
16bitPM 29 Mar 2012, 19:13
yoshimitsu wrote: @16bitPM: Ha I didn't mean it personally man Just venting my own opinion. You're 100% entitled to your own, of course! What about SHL reg,1? ADD reg,reg has same number of bytes but executes faster on most processors (if not all?). Only difference is setting the A flag I think. Yet yoshimitsu, it doesn't follow my own definition of "useless instruction" (since probably most people use SHL). |
|||
29 Mar 2012, 19:13 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.