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 


Auto Assembler: Represent a Byte Value

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

Joined: 20 Dec 2018
Posts: 48

PostPosted: Sat Feb 23, 2019 3:53 pm    Post subject: Auto Assembler: Represent a Byte Value Reply with quote

Please forgive my ignorance, I am learning how memory addresses, opcodes, bytes, etc., all work.

There is an address with the opcode edx that I want to change to 0. But replacing edx with 0 wants to replace a byte with an integer (4 bytes). Can I represent a byte value of 0 instead of an integer so that I do not need to allocate new memory for this operation?

Original opcodes:
Code:
// 3 bytes (89 50 18)
mov [eax+18],edx

Target opcodes:
Code:
// changing the above to this makes it 7 bytes
mov [eax+18],00

In the memory viewer, I see addresses with opcodes like the following:
Code:
// 3 bytes (83 E8 01)
sub eax,01

Not sure why in this case the 01 represents a byte instead of an integer.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4709

PostPosted: Sat Feb 23, 2019 7:12 pm    Post subject: Reply with quote

To zero a register, xor is better than mov:
Code:
xor edx,edx


In the sub instruction, that particular opcode sign-extends the 8-bit immediate operand to 32-bits and then does the subtraction. There's no analogous mov opcode with the same types of operands.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
AntumDeluge
Cheater
Reputation: 0

Joined: 20 Dec 2018
Posts: 48

PostPosted: Sat Feb 23, 2019 9:51 pm    Post subject: Reply with quote

So what would I do if I wanted to change the register value to something other than zero without adding bytes?

For example:
Code:
mov [eax+18],07
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4709

PostPosted: Sat Feb 23, 2019 10:17 pm    Post subject: Reply with quote

You can't. That instruction doesn't exist. There is no mov instruction that extends an 8-bit immediate value (imm8) and moves it into a 32-bit register or memory location (r/m32). mov reference

It's usually possible to optimize other code away to make room for a few more bytes of space.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
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