Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!cs.dal.ca!aucs!880716a From: 880716a@aucs.uucp (Dave Astels) Newsgroups: comp.lang.c++ Subject: Re: calling Zortech C++ methods from assembly Message-ID: <1990Aug20.121745.1815@aucs.uucp> Date: 20 Aug 90 12:17:45 GMT References: <1990Aug17.142520.5402@aucs.uucp> <1394@proto.COM> Reply-To: 880716a@aucs.UUCP (Dave Astels) Organization: School of Computer Science, Acadia Univ., Nova Scotia Lines: 47 In article <1394@proto.COM> joe@proto.COM (Joe Huffman) writes: >In article <1990Aug17.142520.5402@aucs.uucp>, 880716a@aucs.uucp >(Dave Astels) writes: >>[...] invoke C++ methods from assembly. > >The reason it isn't documented is because it can be a real nightmare. Most really powerfull things are. >The names are mangled for type safe linking, No problem. I've read the sections on name mangling and it is simple enough. >there are hidden parameters ('this') Again no problem. Just an extra push or two. >and virtual functions are really function pointers (that may change >their location between compiler versions). This can be a problem. However, if I need to invoke a virtual method, I can have a non-virtual one to invoke which will take care of invoking the virtual one. >Basically, don't do it. If you REALLY want to do it, call the function >from a C++ function, compile with -gl (line numbers turned on), then >run OBJTOASM on the resultant .OBJ file. This will generate the assembly >code from the object code the compiler generated. This will show you >the mangled function name, how it's done with the current version of the >compiler and with that particular function. I had hoped not to have to resort to this again (this is how I taught myself the C calling convention. I've done this (asm->C++) successfully using Turbo Pascal 5.5, so the tricks (implicit parameter, etc) aren't new to me. Borland outlines ALL calling conventions fully in the TP5.5 manuals. I do wish Zortech would give full information in their manuals, for those of us who enjoy getting our hands dirty. -- "I liked him better before he died" - McCoy, ST V =============================================================================== Dave Astels | Internet: 880716a@AcadiaU.CA PO Box 835, Wolfville, | Bitnet: 880716a@Acadia