 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
SanderE1 How do I cheat?
Reputation: 0
Joined: 04 Apr 2017 Posts: 3
|
Posted: Tue Apr 04, 2017 12:07 pm Post subject: How would i divide in cheat engine? |
|
|
I would like to make a script that would take the amount of damage i take and divide it by 2, how or is it possible? is there a opcode for division?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4695
|
Posted: Tue Apr 04, 2017 12:28 pm Post subject: |
|
|
Look at any mnemonic containing "div" here. Beyond that, you're going to need to be more specific: what data type is it? What instruction is accessing it? What instructions lead up to the write to the address?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
SanderE1 How do I cheat?
Reputation: 0
Joined: 04 Apr 2017 Posts: 3
|
Posted: Tue Apr 04, 2017 12:33 pm Post subject: |
|
|
I'm fairly new to cheat engine i don't quite know what you mean.
sub [edx+00000340],eax
how would i divide "eax" by 2?
Full script(terraria)
define(address,11A80E22)
define(bytes,29 82 40 03 00 00)
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
label(code)
label(return)
newmem:
code:
sub [edx+00000340],eax
jmp return
address:
jmp newmem
nop
return:
[DISABLE]
address:
db bytes
dealloc(newmem)
|
|
Back to top |
|
 |
FreeER Grandmaster Cheater Supreme
Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Tue Apr 04, 2017 12:45 pm Post subject: |
|
|
You'd probably be better off here without more info https://www.google.com/search?q=assembly+divide
but since I'm feeling nice and I don't actually have anything to do right this moment... there are 3 situations I can think of off the top of my head
1. It's an typical 4-byte value / integer
2. It's a floating point (float/double) using the fpu (fld/fst(p))
3. It's a floating point (float/double) using SSE / xmmX registers
1.1 shr eax, 1, Since it's a divide by 2 you can just shift the value right, so if you had 1000 in binary (1*2^3 = 8 ) and shift it right by 1 bit it'll become 0100 (1*2^2 = 4). The same works for any power of 2 (2^0, shift by 0 bits, 2^1 (2) shift by 1 bit, 2^X shift by X bits), left shift will make each bit more meaningful (larger) and thus multiply while right shift will make them smaller and thus divide.
1.2 there are div (unsigned) and idiv (signed) instructions just like there are mul (unsigned) and imul (signed) instructions. Basically these implicitly use edx:eax (edx as top 32 bits, eax as low 32 bits, use cdq to sign extend eax into edx) as the value to be divided and you give it the register/address to divide by with the result going in eax and the remainder in edx but it's kind of confusing if you deal with multiple sizes so see http://www.c-jump.com/CIS77/MLabs/M11arithmetic/M11_0120_idiv_instruction.htm Code: | mov eax, -50000 ; dividend, low
cdq ; sign-extend EAX into EDX
mov ebx, 256 ; divisor
idiv ebx ; quotient EAX = -195, remainder EDX = -80 |
2. FDIV (float divide) FDIVP (float divide and pop) FDIVR (float divide reverse) FDIVRP (float divide reverse and pop). To get a good understanding of these, write a few example and step through them in the debugger with the fpu stack visible and watch what happens
example: https://stackoverflow.com/questions/8804770/how-to-divide-floating-point-number-in-x86-assembly
Code: |
push dword ptr 5; // fild needs a memory location, the trick is
fild [esp]; // to use the stack as a temp. storage
fild [esp]; // now st0 and st1 both contain (float) 5
add esp, 4; // better not screw up the stack
fadd st(0), st(0); // st0 = st0 + st0 = 10
fdivp st(1), st(0); // st0 = st1 / st0 = 5 / 10 = 0.5
sub esp, 4; // again, let's make some room on the stack
fstp [esp]; // store the content of st0 into [esp]
pop eax; // get 0.5 off the stack into return value
add esp, 4; // preserve the stack
|
3. DIVSS xmm1, xmm2/m32 (divide scalar single/float) is probably what you want or maybe DIVSD xmm1, xmm2/m64 for double (divide scalar double)
edit: Code: | sub [edx+00000340],eax | would fall under the 1. category
|
|
Back to top |
|
 |
SanderE1 How do I cheat?
Reputation: 0
Joined: 04 Apr 2017 Posts: 3
|
Posted: Tue Apr 04, 2017 12:52 pm Post subject: |
|
|
Thank you sir! sorry for taking up your time.
|
|
Back to top |
|
 |
|
|
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
|
|