harrow@exodus.DEC (Jeff Harrow NCSE TWO/E92 DTN=247-3134) (04/19/85)
FYI... Microsoft has published a document called: "Microsoft BASIC for the Macintosh, Building Machine Language Libraries" which is available for no charge just by calling Microsoft. The abstract states: "This document describes how to construct libraries of machine language routines which can be bound to BASIC dynamically at runtime. The reader should know how to create a Macintosh application using assembly language before proceeding with this document." It's an excellent document which describes the process and provides a step by step example. Here's your chance to speed up your BASIC programs and access otherwise inaccessible ROM routines... Jeff Work address: ARPAnet: HARROW%EXODUS.DEC@decwrl.ARPA Usenet: {allegra,Shasta,decvax}!decwrl!dec-rhea!dec-exodus!harrow Easynet: EXODUS::HARROW Telephone: (617)858-3134 USPS: Digital Equipment Corp. Mail stop: TWO/E92 1925 Andover St. Tewksbury, MA 01876
db@cbosgd.UUCP (Dave Bursik) (04/24/85)
In addition to the documentation available from Microsoft (undoubtably the "right way" to do it), the quick-and-dirty approach to calling user-supplied machine language routines from BASIC V2.0 as described in the manual (putting the binary into an array and CALLing it) works fairly well once you realize that the parenthesis in the middle of the calling- sequence example is supposed to be a comma and that the VARPTR value for the entry point MUST be stored as a 4-byte quantity. However, should you run into problems and get the bomb box in your ML routine, I don't know of any straightforward way to get more information using BASIC alone. I recently acquired Aztec C (commercial version) and was pleasantly surprised to get a register dump from the shell when my BASIC program bombed. At first, I suspected that I might be seeing the interpreter's registers (which wouldn't do me much good), but, having made a little more progress, I became convinced that I was getting the Right Stuff. So far, I have found that Aztec package and MS-BASIC V2.0 complement one another fairly well. I haven't done much with the compiler itself, but the assembler, shell, and Z (vi) editor are all pretty nice to use, and have relieved most of my occasional frustrations with the Finder (e.g., waiting for the desktop to appear, not being able to grep or diff files, etc.). Getting the hex off the assembly listing is infinitely preferable to hand-assembly, which I've found to be rather error-prone. My only complaint about using the Aztec assembler to get the hex to insert in BASIC programs is that it seems to always generate the long form of the branch instruction and doesn't fill in the displacement, even though the target address is within the same source module and well within the short branch range. Perhaps there's a way to force the assembler to optimize a bit (:-)), but I haven't tumbled to it yet. Dave Bursik/..cbosgd!db [The Disclaimer: I have no financial interest in any of these companies above and beyond the dollars I shelled out for their products.]