flat assembler
Message board for the users of flat assembler.
Index
> Main > "virtual at" and "struct" problem |
Author |
|
revolution 10 Dec 2014, 08:47
You can try with this:
Code: cinvoke strcpy, addr m.a, text ; <- works now Code: push eax+m.a ;no such instruction exists Code: lea edx,[eax+m.a] push edx |
|||
10 Dec 2014, 08:47 |
|
felsario 10 Dec 2014, 08:49
Ah yes.. thank you very much!
|
|||
10 Dec 2014, 08:49 |
|
JohnFound 10 Dec 2014, 13:15
IMO, hidden usage of EDX register is very bad practice. I would suggest explicit use:
Code: lea edx, [m.a] cinvoke ctrcpy, edx, text It will make the code much more readable and will prevent obscure bugs. One step further is to not use virtual: Code: cinvoke malloc, sizeof.MY lea edx, [eax+MY.a] cinvoke strcpy, edx, text P.S. The above examples are important when the offset inside the structure is no zero. But in the discussed code MY.a is zero, so the most simple code is without using additional register at all: Code: cinvoke malloc, sizeof.MY cinvoke strcpy, eax, text |
|||
10 Dec 2014, 13:15 |
|
revolution 10 Dec 2014, 13:49
JohnFound wrote: P.S. The above examples are important when the offset inside the structure is no zero. But in the discussed code MY.a is zero, so the most simple code is without using additional register at all: Code: assert MY.a = 0 Code: if MY.a = 0 cinvoke strcpy, eax, text else cinvoke strcpy, addr eax+MY.a, text end if |
|||
10 Dec 2014, 13:49 |
|
JohnFound 10 Dec 2014, 17:29
You are right, generally, but premature optimizations are not so bad in assembly language as in HLLs. There are very rare problems with them and as a rule easy to find and solve. Hidden use of register is much, much more dangerous IMHO.
|
|||
10 Dec 2014, 17:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.