I am trying to convert a sample c++
code to .asm
(intel fornat for x86) in windows with g++(installed by MinGW).
My C++ code is
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World";
return 0;
}
The following prints hello world in emu8086(intel based x86 processor is been used) and this file is saved in .asm
format
; print "hello world"
; first byte is ascii code, second byte is color code.
mov [02h], 'H'
mov [04h], 'e'
mov [06h], 'l'
mov [08h], 'l'
mov [0ah], 'o'
mov [0ch], ','
mov [0eh], 'W'
mov [10h], 'o'
mov [12h], 'r'
mov [14h], 'l'
mov [16h], 'd'
mov [18h], '!'
; wait for any key press:
mov ah, 0
int 16h
ret
i want to generate a code similar to the above(in a .asm file) with g++,I am using windows10 with minGW for g++.
What i tried
g++ -S hello.cpp
but this generates a .s
file, is there any way to convert the hello.cpp
file to .asm
using g++ on windows.
EDIT: More Things I have Tried that didn't work
g++ -o abc.asm hello. cpp
This generated a file abc.asm
which i can run from cmd with command abc.asm
but the file has no human readable code/text in it(i want the code/text in intel syntax assembly)
I also tried
g++ -S -masm=intel hello.cpp
but this also didn't work.
I am a beginner to g++ so please ignore any thing wrong i did.