Re: [cc65] Literal cast to pointer generating unnecessary code with [].

From: Groepaz <groepaz1gmx.net>
Date: 2012-10-17 22:52:44
On Wednesday 17 October 2012, you wrote:
> > Thanks for the report! There are quite some cases where cc65 does
> > generate bad code. These cases are not easy to fix because of the
> > internal structure of the compiler. So while I will try to keep it in
> > mind, I cannot promise anything. At least you know how to have the
> > compiler generate better code:-)
> 
> It is easy to work around this particular case now that I know about
> it. I just figured you might want to know in case the same mechanism
> that does this is doing it somewhere else more important. Thanks!
> 
> By the way, I discovered this because I was trying to use it on the
> NES to write to the memory mapped register at 0x2007, which increments
> an internal write address on every read or write. Apparently the
> 6502's STA (zp), Y instruction issues a dummy read before the write, I
> was getting quite unexpected results when the address was
> double-incremented! There are very few registers on the NES that have
> read/write side effects anyway, so it's not really a problem in the
> general case. It's a very rare case where replacing an absolute
> address with an indirect indexed one isn't functionally the same
> (aside from the timing, of course).

you probably should write this kind of stuff in assembler anyway - eg 
something like

*(unsigned char*)0xdead = 0;
*(unsigned char*)0xdead = 0;

will not generate two writes either (but one)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

Weil die Klügeren ständig nachgeben regieren die Dummen diese Welt.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Oct 17 22:51:03 2012

This archive was generated by hypermail 2.1.8 : 2012-10-17 22:51:07 CEST