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 


Can someone check my assembly code?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
tbonge
How do I cheat?
Reputation: 0

Joined: 25 Apr 2018
Posts: 4

PostPosted: Sun Apr 29, 2018 7:54 am    Post subject: Can someone check my assembly code? Reply with quote

Can someone please check my code for any obvious mistakes or better ways of doing this. I have no idea what I'm doing and just put this together by googling opcodes. The floating point stuff really through me off.

Code:

// Double damage to mobs and half damage to player
// Parameters set by game are:
// xmm1 is attack damage (as a nagative number)
// xmm0 is new HP (original HP plus attack damage)
// Negative HP will make the mob invincible in the game

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000,"game.exe"+3F8F6F)

label(code)
label(return)
label(exit)
label(isPlayer)
label(resist)
label(finalBlow)
label(zero)

newmem:
  pushfq
  cmp rdx,3           // rdx is 3 if player (2 if mob)
  je isPlayer
  subss xmm0,xmm1     // Add back the attack damage (damage is negative)
  mulss xmm1,[resist] // Multiply attack damage by 2
  addss xmm0,xmm1     // Subtract attack damage
  comiss xmm0,[zero]  // Check that HP is not negative
  jbe finalBlow
  exit:
    popfq

code:
  movss [rcx+000000CC],xmm0 // Original game code, sets after attack HP
  jmp return

isPlayer:             // Damage to player
  subss xmm0,xmm1     // Add back the attack damage (damage is negative)
  divss xmm1,[resist] // Divide attack damage by 2
  addss xmm0,xmm1     // Subtract attack damage
  jmp exit

finalBlow:
  movss xmm0,[zero] //Kill mob if after attack HP was negative
  jmp exit

resist:
  dd (float)2
zero:
  dd (float)0

address:
  jmp newmem
  nop
  nop
  nop
return:

[DISABLE]

address:
  db bytes
  // movss [rcx+000000CC],xmm0

dealloc(newmem)
[/code]
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 14

Joined: 24 Feb 2017
Posts: 435
Location: 'Merica

PostPosted: Sun Apr 29, 2018 8:08 am    Post subject: Reply with quote

It looks good to me, the only thing would be to remove the repeated code.
Code:

// Double damage to mobs and half damage to player
// Parameters set by game are:
// xmm1 is attack damage (as a nagative number)
// xmm0 is new HP (original HP plus attack damage)
// Negative HP will make the mob invincible in the game

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000,"game.exe"+3F8F6F)

label(code)
label(return)
label(exit)
label(isPlayer)
label(resist)
label(finalBlow)
label(zero)

newmem:
  pushfq
  cmp rdx,3           // rdx is 3 if player (2 if mob)
  subss xmm0,xmm1     // Add back the attack damage (damage is negative)
  mulss xmm1,[resist] // Multiply attack damage by 2
  addss xmm0,xmm1     // Subtract attack damage
  je exit
  comiss xmm0,[zero]  // Check that HP is not negative
  jbe finalBlow
  exit:
    popfq

code:
  movss [rcx+000000CC],xmm0 // Original game code, sets after attack HP
  jmp return

finalBlow:
  movss xmm0,[zero] //Kill mob if after attack HP was negative
  jmp exit

resist:
  dd (float)2
zero:
  dd (float)0

address:
  jmp newmem
  nop
  nop
  nop
return:

[DISABLE]

address:
  db bytes
  // movss [rcx+000000CC],xmm0

dealloc(newmem)

_________________
A: What manner of man are you that can summon up fire without flint or tinder?
T: I... am an enchanter.
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