Date: Mon, 8 Sep 1997 21:30:15 -0700 (PDT) Message-Id: <199709090430.VAA27713@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Djgpp inline asm/graphics (hline) question Precedence: bulk At 01:38 9/7/1997 -0700, you wrote: >Jesse Legg wrote: >> testl $1, %%edi ; test for odd number address (help!?? :) > >Erm... why not try dividing by two? If you get a result that has a >fraction, not even, if not, even...? That would require using floating point arithmetic, making things MUCH slower and more complicated. Using IDIV might work, but has problems including divide-by-zero errors when the dividend is too big, needing different registers and more of them, and being slower. IMHO, `testl $1, %edi' is the way to go. > >> shr $1, %%ecx ; from my real mode tutorial; what is this? :) > >I think this means divide by two. Shr ecx,1 (Intel format?) shifts the >bits in ecx one step to the right, this dividing the number in ecx by >two. If you shr ecx,2 for instance, you divide by four, then ecx,3 >divides by 8, etc. Shl (if I am not cofusing two) multiplies by powers >of 2 in the the same manner. That's correct. >> adc $0, %%ecx ; ditto > >I have no idea what this does... why not look in an asm ref? adc = ADd with Carry. It adds the first operand to the second, and adds one more if the carry flag was set. Frequently you see this when adding 64-bit numbers, since the carry out of the low dword (from an `add' instruction') can be figured in. Nate Eldredge eldredge AT ap DOT net