Xref: utzoo comp.sys.ibm.pc:23354 comp.sys.intel:672 Path: utzoo!attcan!uunet!lll-winken!ames!amdahl!drivax!alexande From: alexande@drivax.DRI (Mark Alexander) Newsgroups: comp.sys.ibm.pc,comp.sys.intel Subject: Re: correct code for pointer subtraction Summary: use 'rcr' not 'shr' Message-ID: <4150@drivax.DRI> Date: 17 Jan 89 03:36:27 GMT References: <597@mks.UUCP> <3845@pt.cs.cmu.edu> <18123@santra.UUCP> <142@bms-at.UUCP> <6604@killer.DALLAS.TX.US> <4121@drivax.UUCP> Reply-To: alexande@drivax.UUCP (Mark Alexander) Organization: Bob-ist Temple of Monterey Lines: 12 In article <4121@drivax.UUCP> I wrote without thinking very hard: : mov BX,offset DGROUP:U0EA60h ; &a[30000] : mov SI,offset DGROUP:U0 ; &a[0] : sub BX,SI ; &a[30000] - &a[0] : sar BX,1 ; convert bytes to words :That last 'sar' instruction should really be a 'shr'. Actually, it should be 'rcr', to handle the case where the first pointer is less than the second. Thanks to Larry Jones (uunet!sdrc!scjones) for pointing this out to me. That darned carry flag always confuses me. -- Mark Alexander (amdahl!drivax!alexande) (no 'r')