Re: [cc65] optimizer or me?

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2004-07-15 16:48:35
On Thu, Jul 15, 2004 at 04:35:07PM +0200, Groepaz wrote:
> it should also be added that inserting some more instructions in between
> those two isnt a proper fix that can be expected to work for all future
> versions of the compiler (maybe someday it will be able to reorder
> instructions :)) and it will also fail on other compilers (not that much
> of a problem maybe, but its always good to write portable code).

Good point. To make the code portable, and compatible with other compilers and
future cc65 versions, it should be changed to use the volatile modifier:

    *(volatile unsigned char*)0xD104  = 1;
    if ((*(volatile unsigned char*)0xD104) == 1) {
        ...
    } else {
        ...
    }

Once cc65 honors this modifier, the code will work without hiding anything
from the optimizer.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jul 15 16:48:39 2004

This archive was generated by hypermail 2.1.8 : 2004-07-15 16:48:47 CEST