{"action":"opened","issue":{"url":"https://api.github.com/repos/cc65/cc65/issues/218","labels_url":"https://api.github.com/repos/cc65/cc65/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/cc65/cc65/issues/218/comments","events_url":"https://api.github.com/repos/cc65/cc65/issues/218/events","html_url":"https://github.com/cc65/cc65/issues/218","id":109871048,"number":218,"title":"Possible compiler bug with pointer variable vs direct pointer","user":{"login":"clbr","id":790333,"avatar_url":"https://avatars.githubusercontent.com/u/790333?v=3","gravatar_id":"","url":"https://api.github.com/users/clbr","html_url":"https://github.com/clbr","followers_url":"https://api.github.com/users/clbr/followers","following_url":"https://api.github.com/users/clbr/following{/other_user}","gists_url":"https://api.github.com/users/clbr/gists{/gist_id}","starred_url":"https://api.github.com/users/clbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clbr/subscriptions","organizations_url":"https://api.github.com/users/clbr/orgs","repos_url":"https://api.github.com/users/clbr/repos","events_url":"https://api.github.com/users/clbr/events{/privacy}","received_events_url":"https://api.github.com/users/clbr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-05T19:41:03Z","updated_at":"2015-10-05T19:41:03Z","closed_at":null,"body":"This file:\r\n```\r\n#include <nes.h>\r\n\r\nint main() {\r\n\r\n        unsigned char *ppuaddr = (unsigned char *) 0x2006;\r\n        unsigned char *ppudata = (unsigned char *) 0x2007;\r\n        unsigned char *ppuctrl = (unsigned char *) 0x2000;\r\n        unsigned char *ppumask = (unsigned char *) 0x2001;\r\n        unsigned char *ppuscroll = (unsigned char *) 0x2005;\r\n\r\n        waitvblank();\r\n\r\n        *((unsigned char*)0x2006) = 0x3F;\r\n        *((unsigned char*)0x2006) = 0x00;\r\n//      *((unsigned char*)0x2007) = 1;\r\n        *ppudata = 1; // uncomment the above and comment this -> it works\r\n\r\n        *ppuscroll = 0;\r\n        *ppuscroll = 0;\r\n\r\n        *ppumask = 8;\r\n\r\n        while (1);\r\n        return 0;\r\n}\r\n```\r\n\r\nfails when run - the background color is grey. If I comment the *ppudata assignment and uncomment the direct pointer assignment, it works - the bg color is blue.\r\n\r\nI don't speak enough asm to say why the pointer-var fails and direct pointer works. Here is the diff of the assemblies:\r\n```\r\n--- wrong.s     2015-10-05 22:33:49.000000000 +0300\r\n+++ right.s     2015-10-05 22:33:43.000000000 +0300\r\n@@ -46,13 +46,9 @@\r\n        ldx     #$00\r\n        lda     #$00\r\n        sta     $2006\r\n-       ldy     #$07\r\n-       jsr     ldaxysp\r\n-       jsr     pushax\r\n        ldx     #$00\r\n        lda     #$01\r\n-       ldy     #$00\r\n-       jsr     staspidx\r\n+       sta     $2007\r\n        ldy     #$01\r\n        jsr     ldaxysp\r\n        jsr     pushax\r\n\r\n```"}}