Jump to content
Tuts 4 You

simple math issue


FastLife

Recommended Posts

Posted

hello tuts4you, i got a simple math question.


 


when a lenght of a string divisible by 36, the counter should be added by 10.So i got this working but i bet there is a better/cleaner way to do this.


 


 


this is what i got and it works, but could someone help me to improve my function?



invoke lstrlen, Addr szString
.if eax <= 36
push 10
.elseif eax <= 72 ; + 36
push 20 ; + 10
.elseif eax <= 108 ; + 36
push 30 ; + 10 etc..
.elseif eax<= 144
push 40
.elseif eax <= 180
push 50
.elseif eax <= 216
push 60
.elseif eax <= 252
push 70
.else
push 80
.endif

Posted

Modulo operation


 


ASM DIV look EDX == 0?


  • Like 1
Posted
// -- divide length by 36, add one

CDQ

MOV ECX,24h

DIV ECX

INC EAX

// -- if result is more than 8, set it to 8

CMP EAX,8

JBE @F

MOV EAX,8

@@:

// -- multiply result by 10, in EAX will be the value we need

MOV ECX,0Ah

MUL ECX

  • Like 1
Posted

again tuts4you helped me out, a LOT of thanks kao and Aguila, problem solved :D


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...