Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!sdd.hp.com!usc!ucselx!bionet!agate!agate!hughes From: hughes@locusts.Berkeley.EDU (Eric Hughes) Newsgroups: comp.os.msdos.programmer Subject: Re: Int 10H Function 13H - How Do I access BP from C ? Message-ID: Date: 20 Nov 90 19:45:08 GMT References: <1990Oct19.202013.28397@nada.kth.se> <1990Oct21.204236.22011@nada.kth.se> Sender: usenet@agate.berkeley.edu (USENET Administrator) Organization: ucb Lines: 30 In-Reply-To: d87-vik@dront.nada.kth.se's message of 21 Oct 90 20:42:36 GMT In article <1990Oct21.204236.22011@nada.kth.se> d87-vik@dront.nada.kth.se (Ville K{rkk{inen) writes: >My problem is that Int10h - Func13h requires the offset of my data to >be stored in BP,that is, the BasePointer. Note this,BP is a pointer, >not a register defined in the REGS union. BP is the base pointer from which all auto variables are referenced and which saves the value of SP. If you change the value of BP, you must change it back again before the C function returns. The only code which changes BP in compiled code (for MS C 5.1, the compiler in question) are the function prolog and epilog, which set up the stack frame. Really, the easiest way to get at the BIOS service you want is to wrap it in some assembly language which uses the C calling convention. See the mixed model programming guide on how to do this. Now you *can*, through some total deviousness, get a copy of the string you want to print in the location pointed by BP and safely return from that function, but once you've done that, you need to invoke the interrupt without changing stack frames. I don't know of a way to trick MS C 5.1 into generating an int 10h instruction without using self-modifying code. (Take a pointer to a function which contains a dummy instruction, calculate an offset based on an assembly code listing, make sure you write into the code segment somehow, and poke in the instruction by hand.) The upshot of this is that assembly is pretty much required. Eric Hughes hughes@ocf.berkeley.edu