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 


Assembler Data Type Issue

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
sbryzl
Expert Cheater
Reputation: 5

Joined: 25 Jul 2016
Posts: 163

PostPosted: Sun May 07, 2017 10:10 am    Post subject: Assembler Data Type Issue Reply with quote

When I enter the following into auto assembler I get the correct output using hexadecimal notation on the value.

Code:
autoassembler script:
cmp dword ptr [rdx],0x0

assembled code:
81 3A 00000000        - cmp [rdx],00000000 { 0 }


When I don't use hexadecimal notation on the value and still specify a dword pointer the assembler uses a byte data type.
Code:
autoassembler script:
cmp dword ptr [rdx],0000000

assembled code:
83 3A 00              - cmp dword ptr [rdx],00 { 0 }


Shouldn't the assembler compare a dword value if I specify a dword pointer regardless of whether I use hexadecimal notation on the value?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Mon May 08, 2017 3:42 am    Post subject: Reply with quote

your example is wrong

Code:

script: cmp dword ptr [rdx],0000000
output: 81 3A 00000000        - cmp [rdx],00000000 { 0 }

script: cmp dword ptr [rdx],0x0
output: 81 3A 00000000        - cmp [rdx],00000000 { 0 }

script: cmp dword ptr [rdx],0
output: 83 3A 00              - cmp dword ptr [rdx],00 { 0 }

script: cmp [rdx],0
output: 83 3A 00              - cmp dword ptr [rdx],00 { 0 }

script: cmp [rdx],7f
output: 83 3A 7F              - cmp dword ptr [rdx],7F { 127 }

script: cmp [rdx],80
output: 81 3A 80000000        - cmp [rdx],00000080 { 128 }

script: cmp byte ptr [rdx],0
output:


As you see, when you assemble using 8 0's, it picks the long cmp [rdx],00000000 version

and if you assemble using just a single 0, it picks the sign extended cmp [rdx],0 version (the sign extended version is NOT the same as the byte version)

(it will pick the small version as long as the value is under 0x80, above that and there's some ambiguity that it's either a negative value or not)

_________________
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
sbryzl
Expert Cheater
Reputation: 5

Joined: 25 Jul 2016
Posts: 163

PostPosted: Mon May 08, 2017 7:14 am    Post subject: Reply with quote

Dark Byte wrote:
Code:
script: cmp dword ptr [rdx],0
output: 83 3A 00              - cmp dword ptr [rdx],00 { 0 }


This output still looks incorrect. If a dword is specified then the assembled output should be a dword I think. Otherwise why should we bother using any specifiers? Then a single digit on hexadecimal notation should also be taken as a byte but that can be specified as a dword correctly.

Code:
script: cmp dword ptr [rdx],0x0
output: 81 3A 00000000        - cmp [rdx],00000000 { 0 }
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Mon May 08, 2017 8:23 am    Post subject: Reply with quote

hexadecimal notation is just a bug because the size optimizer then counts 3 digits instead of 2 so doesn't even bother parsing it for the small size version.

if I fix this, then
Code:

script: cmp dword ptr [rdx],0x0
output: 83 3A 00        - cmp dword ptr [rdx],00 { 0 }


perhaps your issue is with the disassembler instead of the assembler ? and you'd rather have it show a bunch of 0's of F's in front of the value ? (depending on the most significant bit)

_________________
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
sbryzl
Expert Cheater
Reputation: 5

Joined: 25 Jul 2016
Posts: 163

PostPosted: Mon May 08, 2017 8:41 am    Post subject: Reply with quote

The issue is with the outputted opcode which should be 81 instead of 83 for a dword compare and then of course the entire opstring needs to coincide.

I don't understand why I would specify a compare to a dword pointer and instead be presented with a compare to a byte pointer.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Mon May 08, 2017 8:46 am    Post subject: This post has 1 review(s) Reply with quote

both 81 and 83 are a dword compare. One just uses less bytes

e.g compare if an 4 byte address is 1 can be done by
Code:

83 3A 01              - cmp dword ptr [rdx],01 { 1 }

now if the 4 byte value at [rdx] contains the value 00000001 then the result will be true, BUT if the value at [rdx] is 01000001 then the result will be false

as you see, it does compare the full dword and acts exactly the same , but takes less bytes then
Code:

81 3A 01000000        - cmp [rdx],00000001 { 1 }

_________________
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
sbryzl
Expert Cheater
Reputation: 5

Joined: 25 Jul 2016
Posts: 163

PostPosted: Mon May 08, 2017 8:55 am    Post subject: Reply with quote

Thanks Dark Byte. I see now it's working correctly. I didn't understand how opcode 83 worked.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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