Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how to copy string

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Wed Apr 11, 2012 12:21 pm    Post subject: how to copy string Reply with quote

How to do this

Code:
mov [ebx],"hello"


Where is [ebx] is string[8]

I tried

mov byte ptr [ebx+0],'h'
mov byte ptr [ebx+1],'e'
mov byte ptr [ebx+2],'l'
mov byte ptr [ebx+3],'l'
mov byte ptr [ebx+4],'o'
mov byte ptr [ebx+5],0

but having problems also tried using hex values

_________________
Back to top
View user's profile Send private message Send e-mail
Kavvman
Master Cheater
Reputation: 2

Joined: 17 Apr 2004
Posts: 316

PostPosted: Wed Apr 11, 2012 1:31 pm    Post subject: This post has 1 review(s) Reply with quote

use the ascii code to store each letter. something like this

mov byte ptr [ebx], 43h

You can also use the rep instruction to perform string operations...read more here
http://faydoc.tripod.com/cpu/rep.htm

_________________
...
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Apr 11, 2012 6:05 pm    Post subject: Reply with quote

Kavvman wrote:
use the ascii code to store each letter. something like this

mov byte ptr [ebx], 43h

You can also use the rep instruction to perform string operations...read more here
http://faydoc.tripod.com/cpu/rep.htm

The rep instruction is useless in this case since he is not copying a string. Copying byte by byte is also wasteful and will result in slow and redundantly verbose code. A DWORD can be copied instead.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25788
Location: The netherlands

PostPosted: Wed Apr 11, 2012 6:29 pm    Post subject: Reply with quote

Quote:

mov byte ptr [ebx+0],'h'
mov byte ptr [ebx+1],'e'
mov byte ptr [ebx+2],'l'
mov byte ptr [ebx+3],'l'
mov byte ptr [ebx+4],'o'
mov byte ptr [ebx+5],0

works fine. What is the problem ?

rep is also an option:
Code:

hellostr:
db 'hello',0

...
cld //clear the direction flag (else edi/esi might go backwards)
mov edi,ebx //set destination
mov esi,teststr //set origin
mov ecx,6 //set number of bytes to copy
rep movsb //repeat movsb ecx times

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Kavvman
Master Cheater
Reputation: 2

Joined: 17 Apr 2004
Posts: 316

PostPosted: Wed Apr 11, 2012 6:46 pm    Post subject: Reply with quote

Slugsnack wrote:
Kavvman wrote:
use the ascii code to store each letter. something like this

mov byte ptr [ebx], 43h

You can also use the rep instruction to perform string operations...read more here
http://faydoc.tripod.com/cpu/rep.htm

The rep instruction is useless in this case since he is not copying a string. Copying byte by byte is also wasteful and will result in slow and redundantly verbose code. A DWORD can be copied instead.


Keep your crap existence to the useless section.

The OP had trouble with strings operation, his thread title is "how to copy string". A helpful reply would be to show the different ways he can solve the problem and if he is copying a string the reps instruction is the best he can use. The thread isn't about performance anyway.

@DB: small correction

Quote:
hellostr:
db 'hello',0

...
cld //clear the direction flag (else edi/esi might go backwards)
mov edi,ebx //set destination
mov esi,teststr //set origin :> should be hellostr
mov ecx,6 //set number of bytes to copy
rep movsb //repeat movsb ecx times

_________________
...
Back to top
View user's profile Send private message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Wed Apr 11, 2012 6:57 pm    Post subject: Reply with quote

Dark Byte wrote:
Quote:

mov byte ptr [ebx+0],'h'
mov byte ptr [ebx+1],'e'
mov byte ptr [ebx+2],'l'
mov byte ptr [ebx+3],'l'
mov byte ptr [ebx+4],'o'
mov byte ptr [ebx+5],0

works fine. What is the problem ?

rep is also an option:
Code:

hellostr:
db 'hello',0

...
cld //clear the direction flag (else edi/esi might go backwards)
mov edi,ebx //set destination
mov esi,teststr //set origin
mov ecx,6 //set number of bytes to copy
rep movsb //repeat movsb ecx times


yes that was not the problem. I messed up the pointers and you helped me out.

_________________
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites