Re: [cc65] How to force a read from a memory mapped register w/o volatile

From: Dave Dribin <ddribin1gmail.com>
Date: 2010-12-06 15:48:57
On Mon, Dec 6, 2010 at 2:40 AM, thefox xofeht <thefox@aspekt.fi> wrote:
> Read the value to a dummy variable. If there's a better way, I'd like
> to know also.

That does cause the read to happen, but now the optimizer is not being
smart enough.  It doesn't realize the dummy variable is never used and
it is unnecessarily pushed/popped to the parameter stack:


000000r 1               .proc	_foo: near
000000r 1
000000r 1               .segment	"CODE"
000000r 1
000000r 1               ;
000000r 1               ; uint8_t dummy = IO_Read8(0x2002);
000000r 1               ;
000000r 1  AD 02 20     	lda     $2002
000003r 1  20 rr rr     	jsr     pusha
000006r 1               ;
000006r 1               ; IO_Write8(0x2006, 0x20);
000006r 1               ;
000006r 1  A9 20        	lda     #$20
000008r 1  8D 06 20     	sta     $2006
00000Br 1               ;
00000Br 1               ; IO_Write8(0x2006, 0x00);
00000Br 1               ;
00000Br 1  A9 00        	lda     #$00
00000Dr 1  8D 06 20     	sta     $2006
000010r 1               ;
000010r 1               ; }
000010r 1               ;
000010r 1  4C rr rr     	jmp     incsp1
000013r 1
000013r 1               .endproc

-Dave
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Dec 6 15:49:04 2010

This archive was generated by hypermail 2.1.8 : 2010-12-06 15:49:07 CET