View previous topic :: View next topic |
Author |
Message |
sbryzl Master Cheater Reputation: 6
Joined: 25 Jul 2016 Posts: 252
|
Posted: Sun May 07, 2017 10:10 am Post subject: Assembler Data Type Issue |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25252 Location: The netherlands
|
Posted: Mon May 08, 2017 3:42 am Post subject: |
|
|
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 |
|
|
sbryzl Master Cheater Reputation: 6
Joined: 25 Jul 2016 Posts: 252
|
Posted: Mon May 08, 2017 7:14 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25252 Location: The netherlands
|
Posted: Mon May 08, 2017 8:23 am Post subject: |
|
|
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 |
|
|
sbryzl Master Cheater Reputation: 6
Joined: 25 Jul 2016 Posts: 252
|
Posted: Mon May 08, 2017 8:41 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25252 Location: The netherlands
|
Posted: Mon May 08, 2017 8:46 am Post subject: |
|
|
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 |
|
|
sbryzl Master Cheater Reputation: 6
Joined: 25 Jul 2016 Posts: 252
|
Posted: Mon May 08, 2017 8:55 am Post subject: |
|
|
Thanks Dark Byte. I see now it's working correctly. I didn't understand how opcode 83 worked.
|
|
Back to top |
|
|
|