Article View: pl.comp.lang.asm
Article #2034Re: nie widzi stanu flag po “sub”?
From: Bernard
Date: Thu, 24 Sep 2009 17:25
Date: Thu, 24 Sep 2009 17:25
39 lines
1947 bytes
1947 bytes
gupi manʼaʼgo wrote:
> mamy strukturę, której istotny fragment jak niżej:
> ❝
> struct s_t
> { // …
> unsigned n;
> // …
> };
> ❞
> mamy dwie równoważne w efekcie procedury jak niżej:
> ❝
> void
> proc_1( struct s_t *s,
> unsigned count
> )
> { if( s->n >= count )
> s->n -= count;
> else
> s->n = 0;
> }
> void
> proc_2( struct s_t *s,
> unsigned count
> )
> { if(( s->n -= count ) > count )
> s->n = 0;
> }
> ❞
> ⁂
> co zrobić, by kompilator ‟gcc 4.3.2” zauważył, że po odejmowaniu instru-
> kcją “sub” ma flagi, które może wykorzystać zamiast umieszczać instruk-
> cje “cmp”?
> a może ja się mylę?
Mylisz się. SUB ustawia znaczniki stosownie do wyniku odejmowania, a Ty
po odejmowaniu wykonujesz porównanie ze zmienną count, i korzystasz z
wyniku tego porównania.
I strasznie paskudnie formatujesz ten kod w C...
Technical Details
Message-ID:
<h9ga29$2fjh$1@newsread2.aster.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!nf1.ipartners.pl!ipartners.pl!plix.pl!newsfeed1.plix.pl!nntp.aster.pl!newsread2.aster.pl!not-for-mailReferences:
<h9c3fs$bi4$1@adenine.netfront.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!nf1.ipartners.pl!ipartners.pl!plix.pl!newsfeed1.plix.pl!nntp.aster.pl!newsread2.aster.pl!not-for-mail From: Bernard <bernard@earth.net> Newsgroups: pl.comp.lang.c,pl.comp.lang.asm Subject: Re: nie widzi stanu flag po “sub”? Date: Thu, 24 Sep 2009 19:25:06 +0200 Organization: Aster Sp. z o.o. Lines: 40 Message-ID: <h9ga29$2fjh$1@newsread2.aster.pl> References: <h9c3fs$bi4$1@adenine.netfront.net> NNTP-Posting-Host: 187-mo6-2.acn.waw.pl Mime-Version: 1.0 X-Trace: newsread2.aster.pl 1253813129 81521 82.210.165.187 (24 Sep 2009 17:25:29 GMT) X-Complaints-To: abuse@aster.pl NNTP-Posting-Date: Thu, 24 Sep 2009 17:25:29 +0000 (UTC) User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) In-Reply-To: <h9c3fs$bi4$1@adenine.netfront.net> X-Antivirus: avast! (VPS 090923-0, 2009-09-23), Outbound message X-Antivirus-Status: Clean Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit