flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
ManOfSteel 25 Jun 2010, 09:19
You expect a single mov instruction to copy 11 characters all at once? Check the movsb instruction (<- first Google result I got), and use it with the rep instruction after setting up the esi, edi and ecx registers properly.
But you'd better do this with a procedure/subroutine instead of a macro. Or maybe just use Code: invoke MessageBox,0,"My message text","My title caption",MB_OK and fasm will do the rest, i.e. what you're trying to do with your copy macro. |
|||
![]() |
|
pearlz 25 Jun 2010, 10:20
Thank's
but i want copy const string to other varible string please tell me, how to I do it? |
|||
![]() |
|
bitshifter 25 Jun 2010, 10:24
macro is for assembly time, code is for run time...
Code: mov esi,_src_block mov edi,_dst_block mov ecx,_block_size cld rep movsb |
|||
![]() |
|
pearlz 25 Jun 2010, 10:35
this code can copy values from varible to varible
i want copy value of const string to varible string can do it? |
|||
![]() |
|
bitshifter 25 Jun 2010, 10:39
It copies n bytes from ds:esi to es:edi
|
|||
![]() |
|
bitshifter 25 Jun 2010, 10:47
Also WINAPI has lstrcpy function...
Code: format pe gui 4.0 entry WinMain include 'win32a.inc' section '.code' code readable executable WinMain: invoke lstrcpy,_buffer,_message invoke MessageBox,0,_buffer,_caption,MB_OK invoke ExitProcess,0 section 'data' data readable writeable _message db 'Hello World!',0 _caption db 'Notice...',0 _buffer rb 256 section '.idata' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll' include 'api/kernel32.inc' include 'api/user32.inc' |
|||
![]() |
|
pearlz 25 Jun 2010, 11:01
ok, walkaway, actually I want declare any varible, and no give them any values then i copy value of const to them
because i declare Code: buffer rb 4*1024*1024 ' 4MB exam db ? ...................... if exam have any value output file win contain size of buffer Therefore size of output file will >= 4M |
|||
![]() |
|
baldr 25 Jun 2010, 15:07
pearlz,
Looks like you're as crazy as I am. Such big buffers are have to be dynamically allocated. |
|||
![]() |
|
LocoDelAssembly 25 Jun 2010, 18:32
baldr, I don't see why, if he knows that will use 4MB then why not allocating it in the uninitialized area of a section? It may be a little selfish with the rest of the applications if those 4MB are unused most of the time though, but still, 4 MB seems to be very little nowadays.
pearlz, are you aware that in assembly the concept of constants barely exists here? (only achievable by marking the section containing them read-only) Just make sure to store initialized data before any uninitialized data inside the containing section. bitshifter example could be rewritten as this: Code: format pe gui 4.0 entry WinMain include 'win32a.inc' section '.code' code readable executable WinMain: invoke lstrcpy,_buffer,_message invoke MessageBox,0,_buffer,_caption,MB_OK invoke ExitProcess,0 ; Now these are real constants (also executable though but there is no chance of that happening here) _message db 'Hello World!',0 _caption db 'Notice...',0 section 'data' data readable writeable _buffer rb 1024*1024*4 ; EXE file will still weight 1536 bytes section '.idata' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll' include 'api/kernel32.inc' include 'api/user32.inc' |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.