Skip to main content
gamedev.net
🔒 Locked

C++ _asm question

Started by nerd_boy 16 replies 1.4k views
Original Post
nerd_boy
nerd_boy
I am having trouble using a C++ class variable in an assembly call:
_asm ADD ball.itsX,ball_xv //ball.itsX+=ball_xv;
And I keep getting error C2415. I am reletively new at _asm programming inside C/C++, and was wondering if anyone could help me, or if you cannot use class variables. I am using Visual C++ .Net Standard Edition. itsX is a public integer for class ball. I appreciate any help
SiCrane
SiCrane
IIRC, the first operand of add needs to be a register. try:

__asm {
mov edx, ball.itsX;
add edx, ball_xv;
mov ball.itsX, edx;
};
nerd_boy
nerd_boy
Thanks SiCrane, it works now.
PlayGGY
PlayGGY
Wow, I should learn assembly...
And the rockets' red glare, the bombs bursting in air,gave proof through the fight that our flag was still there.Oh say, does that star-spangled banner yet waveover the land of the free and the home of the brave?
Ademan555
Ademan555
Anyone have some c++ asm links? because actually just last night i was looking into that (and also, i know that tasm code wont necessarily compile with masm or something like that, but basically its less standardized [thats my understanding] what does c++''s asm resemble the most?)

if that was just incomprehensible rambling, tell me...

thanx

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Extrarius
Extrarius
There really isn''t any such thing as ''c++ asm''. Some compilers let you insert assembly inside the c++ code, but the way you do so is implementation dependant and the instruction set etc depends on the processor.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Ademan555
Ademan555
Well i was referring to asm being used in c++ code, i thought that would be understood because thats what this thread was about, but still if anyone has any links thatd be great, and x86 obviously is the processor (well i think, thats standard pc right?)
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
SiCrane
SiCrane
It''s kind of hard pointing out a link without knowing what compiler your using. For example, showing someone AT&T syntax when their compiler uses Intel syntax is not only pointless, but probably harmful.
Ademan555
Ademan555
Well i guess that was kinda my point, i have MSVC++ .NET (standard) i was wondering what type of asm it resembles the most, and if there are any links for it

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Ademan555
Ademan555
Ok thanx, although i know NO asm what so ever, well i did manage to figure out the syntax for MOV :-D but anyways i needa learn basic asm first btw of masm tasm and all that, which uses intel syntax as well?

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Ademan555
Ademan555
Thanx :-D

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Deebo
Deebo
Check out NASM. I simply add .asm files to my project, set the build option in the settings, and the .asm files compile just like .cpp files. Works perfectly in the debugger as well.
Ademan555
Ademan555
But of course...the syntax is different :-D

btw..can i ask what you were on probation for??

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.