writing an assembly language program that corresponds to this C++ Program

Sep 19, 2012 at 6:37pm
I am trying to figure this out I am not familar with C++.

#include <iostream>
using namespace std;

int num1;
int num2;
main () {
cin >> num1 >> num2;
cout << num2 << end1 << num1 << endl;
return 0;
}
Sep 19, 2012 at 7:04pm
I was going to suggest use a C++ compiler to generate the assembler code, and then refine it by hand. But frankly, almost the entirety of this program consists of calls to the standard library. Do you propose to use some library, or want to re-write the library code in assembler too?
Sep 19, 2012 at 7:35pm
Thanks Chervil for the quick response

I am thinking it is looking for something similar to this

CHAR0 0x0008, d
CHAR0 0x0007, d
Stop
.ACII “is”
.END
Sep 19, 2012 at 8:00pm
int main()- just main() is not C++.

First of all - WHAT assembly language? There are like a zillion of them out there, which one do you mean? Also, this includes only reading from and writing to some unspecified location (well, stdin and stdout, which could both be almost anything), which will probably involve OS calls (if the platform you're working for even has an OS that is).
Sep 19, 2012 at 8:01pm
Take the code you have above and compile it with any C++ compiler. Then take the executable\binary\PE file that was generated and open it with Olly dbg found here: http://www.ollydbg.de/ This program is meant for low level debugging and it accomplishes this by translating executable programs into assembly.
Sep 19, 2012 at 8:26pm
Thanks Computergeek01 good information i will try it and see


Hanst99
I am taking a Computer systems class using the J. Stanley Warford Computer Systems fourth edition textbook.

The question out of the book states the following. This is all it gives, though I could be missing something i over looked.

Write an assembly language program that corresponds to the following C++ program:

#include <iostream>
using namespace std;

int num1;
int num2;
main () {
cin >> num1 >> num2;
cout << num2 << end1 << num1 << endl;
return 0;
}
Topic archived. No new replies allowed.