c++ to assembly

Joined
Sep 7, 2004
Messages
3,021
Can someone please give me the equivalent in assembly language?

for (int index = 0; index < 5; ++index)
{
if (index > 1 && index < 4)
{
cout << "hello" << endl;
}
else if (index <= 1)
{
cout << "bye" << endl;
}
cout << "done" << endl;
}
 
Run it through a compiler but don't have it link it. Or, better yet, read the policy on "do my homework" threads.
 
This program prints "bye done bye done hello done hello done hello done done".

Do you want an assembly program that generates the same output, or has the same loops? Do you need all the semantics in cout, and the exception handlers, and so on?

If you have a C++ compiler, perhaps you're best off asking the compiler to show its assembly output.
 
P.P.: this is like asking "please translate english."


and then you ask: "into which language"

and then i say: "just translate it."
 
Nevermind..i decided to get off my lazy ass and finish my Assembly language final myself. Thanks anyway

>INCLUDE Irvine32.inc
>
>.data
>string1 BYTE "hello",0
>string2 BYTE "bye",0
>string3 BYTE "done",0
>index1 BYTE 1
>index2 BYTE 4
>
>.code
>main PROC
>L0:
> mov ax,0
> mov ecx,5
>L1:
> cmp ax,1
> jle L3
>L2:
> cmp ax, 4
> jge L4
> mov edx,offset string1
> call Writestring
> call Crlf
> mov edx,offset string3
> call Writestring
> call Crlf
> inc ax
> loop L1
>L3:
> mov edx,offset string2
> call Writestring
> call Crlf
>L4:
> mov edx,offset string3
> call Writestring
> call Crlf
> inc ax
> loop L1
>
> exit
>main ENDP
>END main
 
Whoa, I didn't notice that. That was your final? Calling a bunch of someone else's library routines and writing a couple of loops?
 
i think admitting to the fact that you asked someone to do a question on your final without disclosing that it was your final is worth being banned.
 
Jeez, I had to write a clone of the old Mac game "Artillery" for my assembly final. It was like 5,000 lines of code - and it generated random terrain for each game. Of course, I had half of the semester.
 
He seems pretty relaxed to me, especially considering what he's just seen.
 
You my friend need to take a step back and breathe deeply and relax

Considering that I (and likely he) have way too many people in our industry that can only copy/paste code... he seems pretty laid back to me.

If you want to work on fun, exciting, groundbreaking stuff, you're going about it the wrong way. If you only want to write stuff like yet another for-internal-use vacation approval app written in VB with an Access backend... keep it up.

It's amazing how much word-of-mouth means. I got hired on following a short phone-interview from my current manager that was mostly him telling me about the project. He'd already learned most of what he wanted to know about me from other hires they had that came from my uni. Guess what happens when they were looking to hire people from that uni for the next couple years. Yep. I was answering questions like... Hey, do you know this guy? How'd you like to work with him?

Amazingly I don't like to work with people that don't do thier own work.
 
Back
Top