Path: utzoo!attcan!uunet!wuarchive!uwm.edu!rutgers!rochester!pt.cs.cmu.edu!b.gp.cs.cmu.edu!Ralf.Brown@B.GP.CS.CMU.EDU From: Ralf.Brown@B.GP.CS.CMU.EDU Newsgroups: comp.os.msdos.programmer Subject: Re: Int 10H Function 13H - How Do I access BP from C ? Message-ID: <27288847@ralf> Date: 26 Oct 90 19:02:31 GMT Sender: ralf@b.gp.cs.cmu.edu Organization: Carnegie Mellon University School of Computer Science Lines: 31 In-Reply-To: <685@digigw.digital.co.jp> In article <685@digigw.digital.co.jp>, gday@digigw.digital.co.jp (Gordon Day) wrote: }inline assembler). The value of a specific register cannot be read or changed }from C on the PC which is why the interrupt-type functions provided by the MSC }libraries are implemented in assembly. The reason is that the definition }of the language doesn't support the idea of "named" registers, that is, a }mapping of a special variable name directly to a physical machine register. }There is nothing stopping a compiler implementor from doing this (e.g. the }VAX based BSD4.3 C compiler), but no compilers (to my knowledge) on the PC do, Don't tell Turbo C, which has let you directly manipulate the CPU registers since v1.00. I regularly write code like _AX = 0x2B00 ; _CX = 0x4445 ; _DX = 0x5351 ; geninterrupt(0x21) ; if (_AL != 0xFF) DESQview_version = _BX ; else DESQview_version = 0 ; though it takes some care when putting things other than numeric literals into a register (since many complex assignments clobber other registers). TC will let you mess with BP, DS, SS, and SP, but one does so at one's own peril, since those registers are vital to the continued running of the compiled C code. -- UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=- 412-268-3053 (school) -=- FAX: ask ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: 1:129/3.1 Disclaimer? | I was gratified to be able to answer promptly, and I did. What's that? | I said I didn't know. --Mark Twain