Xref: news2.mv.net comp.os.msdos.djgpp:1736 From: mdm1004 AT cus DOT cam DOT ac DOT uk (M.D. Mackey) Newsgroups: comp.os.msdos.djgpp Subject: Re: Help with assembler in djgpp Date: 8 Mar 1996 13:08:44 GMT Organization: University of Cambridge, England Lines: 28 Message-ID: <4hpbgs$3e1@lyra.csx.cam.ac.uk> References: NNTP-Posting-Host: ursa.cus.cam.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp "Rafael R. Sevilla" writes: >And also another question. When we write an assembler routine in djgpp >that is called by a C function, do the usual BP addressing techniques used >in real mode DOS still work the same way? Does it still follow the large- >model convention of BP+6 pointing to the first parameter after having >pushed the old value of BP? Or must I use EBP to do the same thing, and >therefore EBP+10 (the pushed EBP being 32 bits and all, plus the 48-bits >of CS:EIP...)? This was one crucial issue which was not addressed by the >FAQ at all. I've been writing such low-level interfaces to assembler for >years, and I'd like to know how it's done in this new system. Your first parameter is at %ebp+8 . Since DJGPP uses a flat memory model, all code references are 'near' and hence %cs is not pushed. You thus have %eip then %ebp on the stack when the main bit of your routine gets going. In general, you should not have to use section registers at all in your code except for a few specialised applications (generally those using DOS memory), and hence any real mode code you're trying to port will probably require fairly extensive changes. Also, remember that the default data sizes are 8 or 32 bits in PM, so avoid using 16-bit registers if possible. -- Mark Mackey http://www.ch.cam.ac.uk/MMRG/mdm.html A magical cave, the empire of the ghost of shadows. A young man plays with all his heart and soul upon a bizarre sound machine... - Yello