•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 403,298 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,851 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 940 | Replies: 10
![]() |
I'm trying to translate the following code from C++ into Asembly language but am having trouble. I know that I have to make a cmp and one or more jmp. If any1 has sugguestions or tips thats great. Here's the C++ coding:
int x = 1 * 2;
int y = 3 * 4;
cout << "x = " << x << endl;
cout << "y = " << y << endl;
if (x == y)
cout << "x and y are the same." << endl;
else
cout << "x and y are not the same." << endl;
return 0; Is there anything wrong with the output of
Use it as a guide for your own attempt.
g++ -S prog.cpp
Use it as a guide for your own attempt.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
•
•
Join Date: May 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 1
asm Syntax (Toggle Plain Text)
include /masm32/include/masm32rt.inc ;compile with masm32 console link & compile .data x dd 1*2 y dd 3*4 .code start: print "x=" print str$(x),13,10 print "y=" print str$(y),13,10 invoke cmpmem,addr x,addr y,sizeof x .if (eax!=0) print "equal",13,10 .else print "not equal",13,10 .endif exit end start
probably not what u expected ;-) but using a HL Macro Assembler, the difference to other languages ( c) is not so big as one would assume ....
> I'm using the Kip Irvine files.
And now you're only telling us this?
> I forgot to mention we can't use .IF statements lol.
More restrictions on the solution, is there anything else you should be telling us?
Post YOUR attempt.
And now you're only telling us this?
> I forgot to mention we can't use .IF statements lol.
More restrictions on the solution, is there anything else you should be telling us?
Post YOUR attempt.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
•
•
Join Date: May 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 1
my code is for the original masm32 package, u can find some download links here
http://www.masm32.com/masmdl.htm
make sure to install in top level of ur drive, otherwise the standard include paths won't work.
there are two files: build.bat and buildc.bat in the /bin directory, the later is the correct one for console apps.
the print macro is a very useful macro, located in include file: /macros/macros.asm, see description in
help file: /help/hlhelp.hlp - Console Mode Macros - print
the cmpmem is a routine located in /include/masm32.inc and the corresponding library is
/lib/masm32.lib ,
see description in /help/masmlib.hlp - Memory Functions - cmpmem
( both functions/macros are available through the line only )
it might be a good idea to check some step by step assembly tutorials first, before getting too deep into some programming tasks to early.
though i don't think that assembler is much more difficult than other programming languages, it sure is different and the learning curve in the beginning takes more time than with other languages.
its better to spend more time with the basics in the beginning, than wasting too much time with error fixing when u take the second step before the first...
http://www.masm32.com/masmdl.htm
make sure to install in top level of ur drive, otherwise the standard include paths won't work.
there are two files: build.bat and buildc.bat in the /bin directory, the later is the correct one for console apps.
the print macro is a very useful macro, located in include file: /macros/macros.asm, see description in
help file: /help/hlhelp.hlp - Console Mode Macros - print
the cmpmem is a routine located in /include/masm32.inc and the corresponding library is
/lib/masm32.lib ,
see description in /help/masmlib.hlp - Memory Functions - cmpmem
( both functions/macros are available through the
•
•
•
•
include /masm32/include/masm32rt.inc
it might be a good idea to check some step by step assembly tutorials first, before getting too deep into some programming tasks to early.
though i don't think that assembler is much more difficult than other programming languages, it sure is different and the learning curve in the beginning takes more time than with other languages.
its better to spend more time with the basics in the beginning, than wasting too much time with error fixing when u take the second step before the first...
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Computer Architecture Reference (Computer Science and Software Design)
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- MC68000/..332 Calculator (Assembly)
- multiplication in assembly mips (Assembly)
- help (Assembly)
- urgent help needed !!! (Assembly)
- Unsigned Division (Assembly)
- Just bought an assembly book and having problems with basic stuff. (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: Can you help me to write this program?
- Next Thread: Bubble Sort/Random Numbers



Linear Mode