flat assembler
Message board for the users of flat assembler.
Index
> Main > lea esi,[esi+ecx*8] |
Author |
|
arigity 28 Jun 2009, 23:16
yes that is a legitimate use of the lea instruction and is not a macro, you should see the intel developers manuals for more information on questions like these.
|
|||
28 Jun 2009, 23:16 |
|
Borsuc 29 Jun 2009, 00:22
There is no multiplication involved with lea. It is shift left. That is, multiplication by power of 2.
2, 4, 8, 16, 32, 64, 128... and so on, are powers of 2. You can't use lea to multiply by some other value. EDIT: what's the point of: Code: lea esi, [esi] |
|||
29 Jun 2009, 00:22 |
|
eskizo 29 Jun 2009, 01:28
thanks arigity & Borsuc.
Borsuc, forget my mistake. |
|||
29 Jun 2009, 01:28 |
|
revolution 29 Jun 2009, 14:45
Also the push/pop of esi will nullify your result completely. The only change from the code you posted is that the flags are altered. In a real lea instruction no flage are altered. Maybe this?
Code: pushfd push ecx mul ecx, 8 add esi, ecx pop ecx popfd |
|||
29 Jun 2009, 14:45 |
|
Tomasz Grysztar 29 Jun 2009, 14:52
You mean "imul ecx,8", don't you?
|
|||
29 Jun 2009, 14:52 |
|
manfred 29 Jun 2009, 14:56
Actually "shl ecx, 3". Multiplication in addressing is left shift by scale field in opcode's SIB byte.
_________________ Sorry for my English... |
|||
29 Jun 2009, 14:56 |
|
revolution 29 Jun 2009, 15:01
Code: pushfd rept 8 {add esi, ecx} popfd |
|||
29 Jun 2009, 15:01 |
|
Tomasz Grysztar 29 Jun 2009, 15:07
manfred wrote: Actually "shl ecx, 3". Multiplication in addressing is left shift by scale field in opcode's SIB byte. And why not "sal ecx,3"? revolution: good one. But I'd prefer: Code: times 8: add esi,ecx Last edited by Tomasz Grysztar on 29 Jun 2009, 15:08; edited 1 time in total |
|||
29 Jun 2009, 15:07 |
|
manfred 29 Jun 2009, 15:07
revolution wrote:
Code: pushfd times 8 dw 0CE01h popfd @up: Because SAL is same opcode as SHL. _________________ Sorry for my English... |
|||
29 Jun 2009, 15:07 |
|
revolution 30 Jun 2009, 00:56
Code: pushfd rept 2{rept 2\{rept 2\\{add esi,ecx\\}\}} popfd |
|||
30 Jun 2009, 00:56 |
|
LocoDelAssembly 30 Jun 2009, 01:16
No?
Code: times 2 times 2 times 2 add esi, ecx |
|||
30 Jun 2009, 01:16 |
|
revolution 30 Jun 2009, 01:30
Can it be mixed?
Code: times 2 rept 4{add esi,ecx} |
|||
30 Jun 2009, 01:30 |
|
Borsuc 30 Jun 2009, 02:23
eskizo wrote: thanks arigity & Borsuc. @revolution: times is assembly-time directive, rept is macroinstruction... rept will make multiple "add esi,ecx" during assembly stage as if you wrote them multiple times. |
|||
30 Jun 2009, 02:23 |
|
Tomasz Grysztar 30 Jun 2009, 06:50
manfred wrote: Because SAL is same opcode as SHL. It may be the same opcode, but you've got the assembly language so that you can verbalize you ideas better than just with opcodes. |
|||
30 Jun 2009, 06:50 |
|
manfred 30 Jun 2009, 13:43
revolution wrote: Can it be mixed? Code: rept 4 { times 2 add esi, ecx } _________________ Sorry for my English... |
|||
30 Jun 2009, 13:43 |
|
revolution 30 Jun 2009, 14:04
manfred passes the test, well done.
|
|||
30 Jun 2009, 14:04 |
|
Borsuc 30 Jun 2009, 15:31
The reason it works is because at assembly time this is what fasm will see:
Code: times 2 add esi, ecx times 2 add esi, ecx times 2 add esi, ecx times 2 add esi, ecx _________________ Previously known as The_Grey_Beast |
|||
30 Jun 2009, 15:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.