FastLife Posted July 15, 2014 Share Posted July 15, 2014 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 Link to comment
Aguila Posted July 15, 2014 Share Posted July 15, 2014 Modulo operation ASM DIV look EDX == 0? 1 Link to comment
kao Posted July 15, 2014 Share Posted July 15, 2014 // -- 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 1 Link to comment
FastLife Posted July 19, 2014 Author Share Posted July 19, 2014 again tuts4you helped me out, a LOT of thanks kao and Aguila, problem solved Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now