Related articles |
---|
Subtraction + comparison in one asm instruction? vincent+news@vinc17.org (Vincent Lefevre) (2002-08-10) |
Re: Subtraction + comparison in one asm instruction? Peter-Lawrence.Montgomery@cwi.nl (Peter L. Montgomery) (2002-08-14) |
Re: Subtraction + comparison in one asm instruction? iddw@hotmail.com (Dave Hansen) (2002-08-14) |
Re: Subtraction + comparison in one asm instruction? walter@bytecraft.com (Walter Banks) (2002-08-23) |
Re: Subtraction + comparison in one asm instruction? vincent+news@vinc17.org (Vincent Lefevre) (2002-08-23) |
Re: Subtraction + comparison in one asm instruction? gdr@soliton.integrable-solutions.net (Gabriel Dos Reis) (2002-09-03) |
Re: Subtraction + comparison in one asm instruction? vincent+news@vinc17.org (Vincent Lefevre) (2002-09-08) |
Re: Subtraction + comparison in one asm instruction? gdr@integrable-solutions.net (Gabriel Dos Reis) (2002-09-12) |
Re: Subtraction + comparison in one asm instruction? vbdis@aol.com (VBDis) (2002-09-12) |
[10 later articles] |
From: | "Dave Hansen" <iddw@hotmail.com> |
Newsgroups: | comp.compilers |
Date: | 14 Aug 2002 02:21:53 -0400 |
Organization: | Compilers Central |
References: | 02-08-033 |
Keywords: | architecture, arithmetic |
Posted-Date: | 14 Aug 2002 02:21:52 EDT |
On 10 Aug 2002 02:12:44 -0400, "Vincent Lefevre"
<vincent+news@vinc17.org> wrote:
[...]
>
> while (--c > 0)
> { ... }
>
>(where c is a signed integer).
>
>Are there compilers that do the subtraction and the comparison in
>the same asm instruction (for the processors for which there is a
>difference)? For the other compilers, have there been discussions,
>plans to add such an optimization, etc?
I have one example.
The CCS PIC C compiler (Not Quite C for a tiny 8-bit microcontroller)
generated the following code for a project I worked on some time ago:
.................... do
.................... {
[... loop stuff ...]
....................
.................... } while (--bit_ctr);
00D8: DECFSZ 72,F
00D9: GOTO 0D0
The DECFSZ decrements a memory location (72 in this case, the ",F"
indicates the result should be stored back in memory instead of into
the W or "Working" register), and skips the next instruction if the
result is zero. The "GOTO" instruction is a jump back to the top of
the loop. The variable (bit_ctr) is an 8-bit unsigned value.
See www.ccsinfo.com for more info on the compiler, and
www.microchip.com for more info on the processor.
Regards,
-=Dave
--
Change is inevitable, progress is not.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.