Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!tcom!creed!arden From: arden@creed.tcom.stc.co.uk (Bruce Arden) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Segment & offset of pointers in MS C v4.0 Message-ID: <247@creed.tcom.stc.co.uk> Date: Tue, 17-Mar-87 14:35:30 EST Article-I.D.: creed.247 Posted: Tue Mar 17 14:35:30 1987 Date-Received: Thu, 19-Mar-87 05:11:29 EST Organization: STC Telecommunications, London N11, UK Lines: 24 Keywords: C pointers Xref: mnetor comp.sys.ibm.pc:2564 comp.lang.c:1277 I want to have two macros P_SEG(p) and P_OFF(p) (cf FP_SEG & FP_OFF) that will let me get the segment and offset of p independant of the memory model. Here is an example of their intended use: char scr[SCRSIZE]; movedata(0xB000, 0x0000, P_SEG(scr), P_OFF(scr), sizeof scr); I thought I had the answer to this question: #define P_SEG(p) (unsigned)((long)( (char far *)(p) ) >> 16) #define P_OFF(p) (unsigned)((long)( (char far *)(p) )) This appeared to give the correct result (although it did generate some redundant code) with data pointers. However it gave register DS as the segment of a near code pointer. Has anyone solved this problem? Thanks in advance -- Bruce Arden arden@creed.tcom.stc.co.uk