flat assembler
Message board for the users of flat assembler.
Index
> Main > pointer or what? Goto page 1, 2 Next |
Author |
|
beppe85 27 Dec 2004, 20:32
The invoke macro has a trick that allocates space for string arguments. You cannot do this with a mov or lea because they treats strings as number, not data.
Tip: See the listing for the generated code. You can replicate the code like this: Code: .code mov edi, Text mov [edi], byte 0 mov esi, Hello call ConcatNullTerminatedString mov esi, World call ConcatNullTerminatedString .data Hello db 'Hello', 0 World db ' World!', 0 Text rb 1000 |
|||
27 Dec 2004, 20:32 |
|
gumletis 27 Dec 2004, 20:50
i don't understand it, i shall have it to not be a pointer. So i used this
Code: xor edi,edi mov edi, hello mov esi, hello invoke lstrcat,edi,' World' invoke MessageBox,0,edi,0,0 .data hello db 'hello ',0 but its just shows "hello world", its should't... and if i use this Code: xor edi,edi mov edi, hello mov esi, hello mov edi,byte 0 invoke lstrcat,edi,' World' invoke MessageBox,0,edi,0,0 it will display ' world'.... _________________ LOOOL |
|||
27 Dec 2004, 20:50 |
|
beppe85 27 Dec 2004, 21:05
I think I could not help you too much, because I'm not a C library fan, but read on...
Code: xor edi,edi ; no effect, edi overwritten by next instruction mov edi, hello ; edi points to 'hello ' mov esi, hello ; esi points to 'hello ' mov edi,byte 0 ; DON'T WORK invoke lstrcat,edi,' World' ; puts ' World' from the first null found invoke MessageBox,0,edi,0,0 The instruction I noted as not working is because edi is 32 bits and byte 0 is 8 bits. If you mean "mov [edi], byte 0", then the string would be "0, 'ello', 0". So the lstrcat overwrites this string as there's is a null at first position. Maybe you should write your own strng handling functions, the C ones are too slow. |
|||
27 Dec 2004, 21:05 |
|
gumletis 27 Dec 2004, 21:09
okay, i also didn't understand it, but how do i get hello to two registry, without being a pointer... ps what you mean with writng my own handling functions with c?
|
|||
27 Dec 2004, 21:09 |
|
beppe85 27 Dec 2004, 21:36
That's OK, I didn't understand you too.
My last attempt: you wanna copy a asciiz to another place. Code: mov esi, source string is here mov edi, destination buffer of appropriate size .move: movsb cmp [esi-1], 0 jne .move |
|||
27 Dec 2004, 21:36 |
|
gumletis 28 Dec 2004, 09:53
I don't understand movsb. The thing i wanna do is some sort of this i will replace with registry
Code: include 'win32ax.inc' .data sysdir rb 100 me rb 100 .code start: invoke GetModuleFileName,0,me,100 invoke GetSystemDirectory,sysdir,100 invoke lstrcat,sysdir," = systemdir..." invoke lstrcat,me," = me EXE name..." invoke MessageBox,0,sysdir,"system dir",MB_OK invoke MessageBox,0,me,"My file name",MB_OK .end start i would replace with some sort of this Code: include 'win32ax.inc' .data duck rb 100 .code start: invoke GetModuleFileName,0,duck,100 mov edi,duck invoke GetSystemDirectory,duck,100 mov esi,duck invoke lstrcat,edi," = systemdir..." invoke lstrcat,esi," = Me EXEname..." invoke MessageBox,0,esi,"system dir",MB_OK invoke MessageBox,0,edi,"My file name",MB_OK .end start I wanna do this becuase registry doesn't use so much bytes. Example 1 fills like 2000 byte, the other one like 1.500 byte... And with another example i try do it, its only fills like 2000 byte, instead of 15.000 bytes... do you understand now? _________________ LOOOL |
|||
28 Dec 2004, 09:53 |
|
gumletis 28 Dec 2004, 17:14
any one?
|
|||
28 Dec 2004, 17:14 |
|
vid 28 Dec 2004, 21:02
gumletis: try to explain what you want again, and as clearly a you can, seems nobody is understanding you (or at least i am not).
|
|||
28 Dec 2004, 21:02 |
|
gumletis 29 Dec 2004, 09:39
okay, when i use the mov instuction, its only do a pointer to the registry(or variable), So if edit one of them registr(or variable) it will change in every one... like when you do this is MASM
mov edi,offset esi ; This give a pointer, that i don't wont mov ebx,eax ; THIS IS WHAT I WONT, this doesn't give a pointer that was in MASM, i want to translate it to FASM understand...? |
|||
29 Dec 2004, 09:39 |
|
gumletis 29 Dec 2004, 13:57
do somebody understand me?
|
|||
29 Dec 2004, 13:57 |
|
JohnFound 29 Dec 2004, 14:03
Well, I will try (but you definately need to understand what actually you want to know. )
1. Registers don't have address and because of that you can't write "mov eax, offset esi" not in MASM neither on any assembler. 2. In FASM you have following syntax: Code: SomeLabel dd 1234, 5678 ; some variable defined. mov eax, SomeLabel ; loads the address (offset, whatever you call it) of "SomeLabel" in eax. mov eax, [SomeLabel] ; loads the content of memory at SomeLabel to eax. Regards |
|||
29 Dec 2004, 14:03 |
|
vid 29 Dec 2004, 14:44
also "registry" is name of windoze's control variables. Things like eax, ebx, esi are called "registers", or "register" in singular.
|
|||
29 Dec 2004, 14:44 |
|
vbVeryBeginner 29 Dec 2004, 16:17
gumletis wrote:
hi, i try to understand u :-p Code: line 3333 label1 dd 88 line 3337 mov eax,[label1] ; woudl move the value 88 into eax line 3340 mov eax,label1 ;would move the value 3333 into eax hopefully u got it :-p |
|||
29 Dec 2004, 16:17 |
|
vbVeryBeginner 29 Dec 2004, 16:29
btw, the line is not the line in your notepad or zibu
it is the line in your pc memory |
|||
29 Dec 2004, 16:29 |
|
vid 29 Dec 2004, 17:20
Quote: hopefully u got it :-p yes. Quote: btw, the line is not the line in your notepad or zibu yes, but it's called "address" or more exactly "offset". |
|||
29 Dec 2004, 17:20 |
|
vbVeryBeginner 30 Dec 2004, 05:39
offset :-[p
yup, inside 16 bits :-p i thought we shift to 32 bits already :0 :-p btw, don't get serious, i try to joke, hopefully u laugh |
|||
30 Dec 2004, 05:39 |
|
gumletis 31 Dec 2004, 10:11
thanks... but when i do this
.data state rb 100 .code invoke GetModuleFileName,0,state,100 mov eax,[state] its says error with 'mov eax,[state]' says wrong size... register |
|||
31 Dec 2004, 10:11 |
|
JohnFound 31 Dec 2004, 10:25
gumletis wrote: its says error with 'mov eax,[state]' says wrong size... register Right, there is an error. "state" is byte array but eax is dword register. You have several options (depending on what you want to do): 1. Using byte register (al, ah, bl, bh, etc.): "mov al, [state]" - will load the first character from [state] into register al. 2. Using dword register (eax, ebx, ecx, etc.) with type casting: "mov eax, dword [state]" - will load the first 4 characters from [state] into eax register. Regards. |
|||
31 Dec 2004, 10:25 |
|
gumletis 31 Dec 2004, 10:35
okay, but what shall i do, if i shall use it for at msgbox api, becuase i have tryed the
mov eax,dword[state] invoke MessageBox,0,eax,eax,MB_OK it will just assemble, but it will crash when i start it |
|||
31 Dec 2004, 10:35 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.