Good time of the day everybody!

Is anybody know where can I find sources of translator from C++ to asm?
Or may be BASIC to asm?

And may be somebody knows how to translate objects (OOP in C++)?

I'm trying to make translator from my own language to asm (to compile it with MASM32) and I have real troubles with OOP ...

I hope you help me ;)
Posted on 2002-12-18 01:40:41 by gaidar
Gaidar,

You can use the switch "generate asm listing" of your C/C++ compiler.

http://www.asmcommunity.net/board/index.php?topic=9074

An example:




#include <stdio.h>
void main()
{
char *friend="amigo";
printf("Hello %s",friend);
}




CL.exe /I\Vc6\include /c /Ogtyb2 /Gs /G6 /Gz /Zp1 /FAs /Fa%1.asm /Fo%1.OBJ %1.C
\masm32\bin\link /ENTRY:main /SUBSYSTEM:CONSOLE /LIBPATH:c:\masm32\lib %1.obj msvcrt.lib

After compiling your C source file,you get an EXE of 2560 bytes! No bloatware!

Result:




TITLE console.C
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
_DATA SEGMENT
$SG338 DB 'amigo', 00H
ORG $+2
$SG339 DB 'Hello %s', 00H
_DATA ENDS
PUBLIC _main
EXTRN _printf:NEAR
_TEXT SEGMENT
_main PROC NEAR

; 4 : char *friend="amigo";
; 5 : printf("Hello %s",friend);

push OFFSET FLAT:$SG338
push OFFSET FLAT:$SG339
call _printf
add esp, 8

; 6 : }

ret 0
_main ENDP
_TEXT ENDS
END



Regards,

Vortex
Posted on 2002-12-18 05:09:00 by Vortex
For Visual Basic,I don't know the exact method/compiler switch;
but if you can get a .obj file from the VB compiler,you can use the obj2asm tool.
This utility produces asm code from .obj files.

ftp://ftp.digitalmars.com/obj2asm.exe

or from:

http://hussainweb0.tripod.com/download/disasm/obj2asm.exe

Regards,

Vortex
Posted on 2002-12-18 05:25:14 by Vortex
It was so many days ago :) But now I've done something and I wanna tell you thanks :)
Posted on 2003-03-31 06:07:46 by gaidar

Is anybody know where can I find sources of translator from C++ to asm?
Hopefully this may help:

http://www.asmcommunity.net/board/index.php?topic=9074
Posted on 2003-03-31 06:31:53 by Maverick
Thanks, but it's not so helpful.
Posted on 2003-03-31 06:43:03 by gaidar

Neverminds, I thought you wanted to translate from C++ to asm (a.k.a. "compile to ASM source"). ;)
Posted on 2003-03-31 07:23:35 by Maverick
No I don't.

But still thanks :)
Posted on 2003-03-31 07:29:27 by gaidar