flat assembler
Message board for the users of flat assembler.
Index
> Windows > mov eax, [variable] |
Author |
|
revolution 26 Feb 2018, 22:54
What do you consider to be "working"?
After the instruction has executed EAX contains 0x6c6c6548, but you'll need and override to get that: Code: mov eax,dword[text] Code: mov eax,text |
|||
26 Feb 2018, 22:54 |
|
Mikl___ 27 Feb 2018, 02:08
Salut, mino!
Code: test db 'Hello',0 ... mov eax, dword [text]; eax=0x6C6C6548='lleH' |
|||
27 Feb 2018, 02:08 |
|
DimonSoft 27 Feb 2018, 07:14
Mino wrote: eax is not a registry with enough size to contain a type db You should also stop thinking in terms of types. DB is not a type but a directive that just makes an assembler put some data into output file as a sequence of bytes. EAX is definitely large enough to hold a byte. Even four of them. revolution and Mikl___ gave you two possible solutions. I’ll give you one more. Which one suits you depends on what you need and we can suggest hundreds of such solutions. To let us know that you need to express your wishes in terms of bytes and pointers. Code: movzx eax, [text] copies the first character (byte) of the string into eax (zero-extending it). Code: mov eax, dword [text] copies four characters of the string into eax. Which is not particularly useful for processing the string character-by-character, but as we don’t know what you actually need it might work as well. Code: mov eax, text puts the address (offset) of the string into eax. |
|||
27 Feb 2018, 07:14 |
|
Mino 27 Feb 2018, 07:29
Thank you very much for your answers!
Actually, I'm trying to do that: Code: write: cinvoke printf, eax ret main: push eax mov eax, ecx mov eax, dword [text] ; I tried that solution there. push eax call write invoke ExitProcess, 0 But it still doesn't work... I imagine you understand the purpose of Code: mov eax [text] _________________ The best way to predict the future is to invent it. |
|||
27 Feb 2018, 07:29 |
|
DimonSoft 27 Feb 2018, 13:29
Mino wrote: Thank you very much for your answers! You should pass the address of the string. See my explanation of the meaning of the three solutions you’ve been supplied with and choose the one that suits this need. |
|||
27 Feb 2018, 13:29 |
|
Mino 27 Feb 2018, 15:09
Thank you for your answers. Indeed, I had tested several times the code that met my needs:
Code:
mov eax, text
And it works perfectly! I just have one last question: how useful this solution is: Quote:
You said it would copy the first 4 characters, but I don't know what it's for. Would you enlighten me ? _________________ The best way to predict the future is to invent it. |
|||
27 Feb 2018, 15:09 |
|
DimonSoft 27 Feb 2018, 21:21
Mino wrote: You said it would copy the first 4 characters, but I don't know what it's for. Would you enlighten me ? The first thing a can think of is some kind of copying or maybe certain cases when you’re not interested in the contents of the string itself but want to treat it as a set of bytes and perform some transformations (calculate a hash, for example). In case the string is Unicode (Windows-style) I can imagine this as one of possible solutions to exchange characters in pairs: the first with the second, the 3rd with the 4th, etc. Code: ... mov eax, dword [str] rol eax, 16 mov dword [str], eax ... Something like that, although in this case string-handling instructions could be a better idea. |
|||
27 Feb 2018, 21:21 |
|
Mino 28 Feb 2018, 16:08
Thank you, I can see better what it is now!
|
|||
28 Feb 2018, 16:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.