Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!oberon!sdcrdcf!markb From: markb@sdcrdcf.UUCP (Mark Biggar) Newsgroups: comp.lang.c Subject: Re: Types Message-ID: <4779@sdcrdcf.UUCP> Date: Thu, 3-Sep-87 13:32:43 EDT Article-I.D.: sdcrdcf.4779 Posted: Thu Sep 3 13:32:43 1987 Date-Received: Sat, 5-Sep-87 15:22:09 EDT References: <7264@brl-adm.ARPA> <734@sdchema.sdchem.UUCP> <293@osupyr.UUCP> <296@swlabs.UUCP> <613@sugar.UUCP> Reply-To: markb@sdcrdcf.UUCP (Mark Biggar) Organization: Unisys - System Development Group, Santa Monica Lines: 30 In article <613@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: >> [ description of how to make an assembler that handles long/short branches ] >But that doesn't resolve the problem of how to deal with near and far >cals to seperately compiled code. If the calling sequence of the 8086 >was a little more logical, you could have 2 entry points for the routine: >near and far. The near would just push the segment and fall through to >the far. Unfortunately, segment is not the top of the stack in a far >call. See Kernighan's April column in Computer Language. No the offest is on the top of the stack, so you can do the following: When generating the op for a near or far sub call the compiler inserts a nop before the call if necessary so that a far call always pushes an odd offset onto the stack and a near call always pushes an even offset. now the subroutine looks something like: label ... ... mov ax,(sp) and ax,1 jz label1 retfar label1 retnear This scheme was developed during a discussion with Robert Dewar of NYU at the last SIGAda meeting the was held in San Diego (3 yrs ago?), about how to compile Ada packages for an 86. Mark Biggar {allegra,burdvax,cbosgd,hplabs,ihnp4,akgua,sdcsvax}!sdcrdcf!markb