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 


Math in MASM
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Jun 18, 2007 2:10 pm    Post subject: Math in MASM Reply with quote

In MASM how do you do like +, -, *, /

is it just like in c++

or do i have to do a command like mov or something

Code:

include \masm32\include\masm32rt.inc
 
.data
MsgBoxCaption db "Addition Test",0
MsgBoxText    db 6 + 5,0

.code
start:
invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK

push 1000
call Sleep
invoke ExitProcess,NULL
end start


when i "db 6 + 5" i get like the male sex symbol

lmao?

_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon Jun 18, 2007 2:14 pm    Post subject: Reply with quote

add, sub, mul, div
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Mon Jun 18, 2007 2:15 pm    Post subject: Reply with quote

quotation marks...

@appalsap...
i think he just wants the + character to show up.

_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Jun 18, 2007 2:18 pm    Post subject: Reply with quote

no i want 11 to show up lol

i dont get how i would do this

add 6,5?

what lol

if you have aim

steveskate1000

_________________
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Mon Jun 18, 2007 2:21 pm    Post subject: Reply with quote

Code:

mov eax,5
add eax,6

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Jun 18, 2007 2:25 pm    Post subject: Reply with quote

but now how do i get a variable to equal that?

im so fucking confused >;{

Code:

include \masm32\include\masm32rt.inc
 
.data
text        db "I want eax to be displayed here" ,0
Caption     db "MessageBox"                      ,0

.code
start:

mov eax,5
add eax,6

invoke MessageBox, NULL, addr text , addr Caption, MB_OK

push 500
call Sleep

invoke ExitProcess, NULL
end start


i want text to be eax o.o in the invoke MessageBox or variable declare

_________________
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Mon Jun 18, 2007 2:30 pm    Post subject: Reply with quote

high6 wrote:
DeltaFlyer wrote:
Code:

mov eax,5
add eax,6


sub 10,4;6
div 10,2;5
inc 10;11
dec 20;19
mul 5,5;25

etc


Can't do operations on two immediate values. For commands such as mul and div, specific registers must be used.

blankrider wrote:
but now how do i get a variable to equal that?

im so fucking confused >;{

Your registers are your temp variables. They are the things that can be used to do operations. For longer storage, use the memory.
You really should go read a tutorial to learn ASM basics before trying these things.

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon Jun 18, 2007 2:31 pm    Post subject: Reply with quote

1. You can use registers in function calls
2. MessageBox wants a string, don't give it a number
3. You can convert a number to string with "itoa" in msvcrt.dll
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Mon Jun 18, 2007 2:38 pm    Post subject: Reply with quote

high6 wrote:
I was giving the syntax not working examples using regs.


Even the most basic syntax is wrong. There is no MUL command that takes two operands. The destination is implied and varies according to the source. Similar for DIV.

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon Jun 18, 2007 2:38 pm    Post subject: Reply with quote

Code:

.386
.model flat, stdcall
option casemap: none

includelib \masm32\lib\user32.lib
includelib \masm32\lib\msvcrt.lib


c_msvcrt typedef PROTO C :VARARG
externdef _imp___itoa:PTR c_msvcrt
crt__itoa equ <_imp___itoa>
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
Number  dd 0 ;only 4 bytes so number cannot exceed 3 digits
Caption db 'my caption', 0

.code
start:

mov ebx, 5
add ebx, 6

invoke crt__itoa, ebx, addr Number, 10 ;base 10
invoke MessageBoxA, 0, addr Number, addr Caption, 0
ret

end start


Last edited by appalsap on Mon Jun 18, 2007 3:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Jun 18, 2007 2:40 pm    Post subject: Reply with quote

thank you i get this now

im gonna go read more about registers now Very Happy

_________________
Back to top
View user's profile Send private message
Uzeil
Moderator
Reputation: 6

Joined: 21 Oct 2006
Posts: 2411

PostPosted: Mon Jun 18, 2007 2:57 pm    Post subject: Reply with quote

DeltaFlyer wrote:
high6 wrote:
I was giving the syntax not working examples using regs.


Even the most basic syntax is wrong. There is no MUL command that takes two operands. The destination is implied and varies according to the source. Similar for DIV.

IMUL can take 3 if I remember correctly. And yet at the same time I can't remember if IMUL is the signed or unsigned version of multiplication.

Easier math: LEA !

Code:
lea eax,[eax*4]
Bah hah!

Code:
lea eax,]eax+ecx*4+12345678]
Pure beauty. Does all that and doesn't even effect any EFlags Smile


Thread starter: This isn't going to be much like any other language you've dealt with. Those high level (high level doesn't mean advanced / of high standard, it means... easy/simplified really Confused ) languages hide assembly from you as it's completely different. A line like "myvar=(myvar+32)/8;" would use registers to temporarily store all the information for that math, then shove the outcome into the memory we refer to as 'myvar' here, then they would be used for your next line if needed, etc.

_________________


Mini Engine v3.0
Mipla v1.0

Reposted old threads out of the MS section.
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Mon Jun 18, 2007 3:13 pm    Post subject: Reply with quote

Ya... I specified MUL though. IMUL should be the signed version, since MUL is the unsigned.

As for the inline multiplication, I thought it was only valid for multiples of 2?

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
Uzeil
Moderator
Reputation: 6

Joined: 21 Oct 2006
Posts: 2411

PostPosted: Mon Jun 18, 2007 3:22 pm    Post subject: Reply with quote

If that's true, it's easy to get around.

Take... eax*5 for example-
Code:
lea eax,[eax+eax*4]


Some may be harder to get to than others (and I think you mean exponential something or others of 2), like eax*7 for example probably needs 2 lines if this 2 rule is true (I'll test momentarily through Olly) -
Code:
lea eax,[eax+eax*4]
lea eax,[eax+eax] ;I know I could do mul 2 here since I'm using eax for my example, but that would mess with edx.  See why I love lea?

_________________


Mini Engine v3.0
Mipla v1.0

Reposted old threads out of the MS section.
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Mon Jun 18, 2007 3:34 pm    Post subject: Reply with quote

Yes, I did mean powers of 2... thought about one thing typed another...

I'm not sure if such exception exists or not though. I might have confused it with the shifts, which only does multiplications and divisions by powers of 2.

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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