{"action":"created","comment":{"url":"https://api.github.com/repos/cc65/cc65/pulls/comments/225123708","pull_request_review_id":164652976,"id":225123708,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNTEyMzcwOA==","diff_hunk":"@@ -613,7 +613,115 @@ static unsigned OptStackPtrOps (CodeSeg* S)\n     return Changes;\n }\n \n+static unsigned OptGotoSPAdj (CodeSeg* S)\n+/* Optimize SP adjustment for forward 'goto' */\n+{\n+    unsigned Changes = 0;\n+    unsigned I;\n+\n+    /* Walk over the entries */\n+    I = 0;\n+    while (I < CS_GetEntryCount (S)) {\n+\n+        CodeEntry* L[10], *X;\n+        unsigned short adjustment;\n+        const char* Arg;\n \n+        /* Get next entry */\n+        L[0] = CS_GetEntry (S, I);\n+\n+        /* Check for the sequence generated by g_lateadjustSP */\n+        if (L[0]->OPC == OP65_PHA            &&\n+            CS_GetEntries (S, L+1, I+1, 9)   &&\n+            L[1]->OPC == OP65_LDA            &&\n+            L[1]->AM == AM65_ABS             &&\n+            L[2]->OPC == OP65_CLC            &&\n+            L[3]->OPC == OP65_ADC            &&\n+            strcmp (L[3]->Arg, \"sp\") == 0    &&\n+            L[6]->OPC == OP65_ADC            &&\n+            strcmp (L[6]->Arg, \"sp+1\") == 0  &&\n+            L[9]->OPC == OP65_JMP) {\n+            adjustment = FindSPAdjustment (L[1]->Arg);\n+\n+            if (adjustment == 0) {\n+            /* No SP adjustment needed, remove the whole sequence */\n+                CS_DelEntries (S, I, 9);\n+            }\n+            else if (adjustment >= 65536 - 8) {\n+            /* If adjustment is in range [-8, 0) we use decsp* calls */\n+                char Buf[20];\n+                adjustment = 65536 - adjustment;\n+                xsprintf (Buf, sizeof (Buf), \"decsp%u\", adjustment);\n+                X = NewCodeEntry (OP65_JSR, AM65_ABS, Buf, 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 9);\n+\n+                /* Delete the old code */\n+                CS_DelEntries (S, I, 9);\n+            }\n+            else if (adjustment >= 65536 - 255) {\n+            /* For range [-255, -8) we have ldy #, jsr subysp */\n+                adjustment = 65536 - adjustment;\n+                Arg = MakeHexArg (adjustment);\n+                X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 9);\n+                X = NewCodeEntry (OP65_JSR, AM65_ABS, \"subysp\", 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 10);\n+\n+                /* Delete the old code */\n+                CS_DelEntries (S, I, 9);\n+            }\n+            else if (adjustment > 255) {\n+            /* For ranges [-32768, 255) and (255, 32767) the only modification\n+            ** is to replace the absolute with immediate addressing */\n+                Arg = MakeHexArg (adjustment & 0xff);\n+                X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 1);\n+                Arg = MakeHexArg (adjustment >> 8);\n+                X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, L[5]->LI);\n+                CS_InsertEntry (S, X, I + 6);\n+\n+                /* Delete the old code */\n+                CS_DelEntry (S, I + 2);\n+                CS_DelEntry (S, I + 6);\n+            }\n+            else if (adjustment > 8) {\n+            /* For range (8, 255] we have ldy #, jsr addysp */\n+                Arg = MakeHexArg (adjustment & 0xff);\n+                X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 9);\n+                X = NewCodeEntry (OP65_JSR, AM65_ABS, \"addysp\", 0, L[1]->LI);\n+                CS_InsertEntry (S, X, I + 10);\n+\n+                /* Delete the old code */\n+                CS_DelEntries (S, I, 9);\n+            }\n+            else {\n+            /* If adjustment is in range (0, 8] we use incsp* calls */","path":"src/cc65/codeopt.c","position":96,"original_position":96,"commit_id":"6791920c1b6c79e97ac6faa3f0e1ddc8706995c4","original_commit_id":"6791920c1b6c79e97ac6faa3f0e1ddc8706995c4","user":{"login":"oliverschmidt","id":2664009,"node_id":"MDQ6VXNlcjI2NjQwMDk=","avatar_url":"https://avatars0.githubusercontent.com/u/2664009?v=4","gravatar_id":"","url":"https://api.github.com/users/oliverschmidt","html_url":"https://github.com/oliverschmidt","followers_url":"https://api.github.com/users/oliverschmidt/followers","following_url":"https://api.github.com/users/oliverschmidt/following{/other_user}","gists_url":"https://api.github.com/users/oliverschmidt/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverschmidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverschmidt/subscriptions","organizations_url":"https://api.github.com/users/oliverschmidt/orgs","repos_url":"https://api.github.com/users/oliverschmidt/repos","events_url":"https://api.github.com/users/oliverschmidt/events{/privacy}","received_events_url":"https://api.github.com/users/oliverschmidt/received_events","type":"User","site_admin":false},"body":"Please align the comment with the actual code.","created_at":"2018-10-15T11:04:31Z","updated_at":"2018-10-15T11:04:31Z","html_url":"https://github.com/cc65/cc65/pull/773#discussion_r225123708","pull_request_url":"https://api.github.com/repos/cc65/cc65/pulls/773","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/cc65/cc65/pulls/comments/225123708"},"html":{"href":"https://github.com/cc65/cc65/pull/773#discussion_r225123708"},"pull_request":{"href":"https://api.github.com/repos/cc65/cc65/pulls/773"}}},"pull_request":{"url":"https://api.github.com/repos/cc65/cc65/pulls/773","id":222700223,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNzAwMjIz","html_url":"https://github.com/cc65/cc65/pull/773","diff_url":"https://github.com/cc65/cc65/pull/773.diff","patch_url":"https://github.com/cc65/cc65/pull/773.patch","issue_url":"https://api.github.com/repos/cc65/cc65/issues/773","number":773,"state":"open","locked":false,"title":"Optimization of SP adjustment code after forward gotos.","user":{"login":"laubzega","id":5245003,"node_id":"MDQ6VXNlcjUyNDUwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/5245003?v=4","gravatar_id":"","url":"https://api.github.com/users/laubzega","html_url":"https://github.com/laubzega","followers_url":"https://api.github.com/users/laubzega/followers","following_url":"https://api.github.com/users/laubzega/following{/other_user}","gists_url":"https://api.github.com/users/laubzega/gists{/gist_id}","starred_url":"https://api.github.com/users/laubzega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laubzega/subscriptions","organizations_url":"https://api.github.com/users/laubzega/orgs","repos_url":"https://api.github.com/users/laubzega/repos","events_url":"https://api.github.com/users/laubzega/events{/privacy}","received_events_url":"https://api.github.com/users/laubzega/received_events","type":"User","site_admin":false},"body":"A fix for issue #769.","created_at":"2018-10-14T08:12:18Z","updated_at":"2018-10-15T11:04:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5bc499847411e2492fdaf232cf23b420200babb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cc65/cc65/pulls/773/commits","review_comments_url":"https://api.github.com/repos/cc65/cc65/pulls/773/comments","review_comment_url":"https://api.github.com/repos/cc65/cc65/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cc65/cc65/issues/773/comments","statuses_url":"https://api.github.com/repos/cc65/cc65/statuses/6791920c1b6c79e97ac6faa3f0e1ddc8706995c4","head":{"label":"laubzega:goto-opt","ref":"goto-opt","sha":"6791920c1b6c79e97ac6faa3f0e1ddc8706995c4","user":{"login":"laubzega","id":5245003,"node_id":"MDQ6VXNlcjUyNDUwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/5245003?v=4","gravatar_id":"","url":"https://api.github.com/users/laubzega","html_url":"https://github.com/laubzega","followers_url":"https://api.github.com/users/laubzega/followers","following_url":"https://api.github.com/users/laubzega/following{/other_user}","gists_url":"https://api.github.com/users/laubzega/gists{/gist_id}","starred_url":"https://api.github.com/users/laubzega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laubzega/subscriptions","organizations_url":"https://api.github.com/users/laubzega/orgs","repos_url":"https://api.github.com/users/laubzega/repos","events_url":"https://api.github.com/users/laubzega/events{/privacy}","received_events_url":"https://api.github.com/users/laubzega/received_events","type":"User","site_admin":false},"repo":{"id":145889830,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU4ODk4MzA=","name":"cc65","full_name":"laubzega/cc65","private":false,"owner":{"login":"laubzega","id":5245003,"node_id":"MDQ6VXNlcjUyNDUwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/5245003?v=4","gravatar_id":"","url":"https://api.github.com/users/laubzega","html_url":"https://github.com/laubzega","followers_url":"https://api.github.com/users/laubzega/followers","following_url":"https://api.github.com/users/laubzega/following{/other_user}","gists_url":"https://api.github.com/users/laubzega/gists{/gist_id}","starred_url":"https://api.github.com/users/laubzega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laubzega/subscriptions","organizations_url":"https://api.github.com/users/laubzega/orgs","repos_url":"https://api.github.com/users/laubzega/repos","events_url":"https://api.github.com/users/laubzega/events{/privacy}","received_events_url":"https://api.github.com/users/laubzega/received_events","type":"User","site_admin":false},"html_url":"https://github.com/laubzega/cc65","description":"cc65 - a freeware C compiler for 6502 based systems —","fork":true,"url":"https://api.github.com/repos/laubzega/cc65","forks_url":"https://api.github.com/repos/laubzega/cc65/forks","keys_url":"https://api.github.com/repos/laubzega/cc65/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laubzega/cc65/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laubzega/cc65/teams","hooks_url":"https://api.github.com/repos/laubzega/cc65/hooks","issue_events_url":"https://api.github.com/repos/laubzega/cc65/issues/events{/number}","events_url":"https://api.github.com/repos/laubzega/cc65/events","assignees_url":"https://api.github.com/repos/laubzega/cc65/assignees{/user}","branches_url":"https://api.github.com/repos/laubzega/cc65/branches{/branch}","tags_url":"https://api.github.com/repos/laubzega/cc65/tags","blobs_url":"https://api.github.com/repos/laubzega/cc65/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laubzega/cc65/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laubzega/cc65/git/refs{/sha}","trees_url":"https://api.github.com/repos/laubzega/cc65/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laubzega/cc65/statuses/{sha}","languages_url":"https://api.github.com/repos/laubzega/cc65/languages","stargazers_url":"https://api.github.com/repos/laubzega/cc65/stargazers","contributors_url":"https://api.github.com/repos/laubzega/cc65/contributors","subscribers_url":"https://api.github.com/repos/laubzega/cc65/subscribers","subscription_url":"https://api.github.com/repos/laubzega/cc65/subscription","commits_url":"https://api.github.com/repos/laubzega/cc65/commits{/sha}","git_commits_url":"https://api.github.com/repos/laubzega/cc65/git/commits{/sha}","comments_url":"https://api.github.com/repos/laubzega/cc65/comments{/number}","issue_comment_url":"https://api.github.com/repos/laubzega/cc65/issues/comments{/number}","contents_url":"https://api.github.com/repos/laubzega/cc65/contents/{+path}","compare_url":"https://api.github.com/repos/laubzega/cc65/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laubzega/cc65/merges","archive_url":"https://api.github.com/repos/laubzega/cc65/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laubzega/cc65/downloads","issues_url":"https://api.github.com/repos/laubzega/cc65/issues{/number}","pulls_url":"https://api.github.com/repos/laubzega/cc65/pulls{/number}","milestones_url":"https://api.github.com/repos/laubzega/cc65/milestones{/number}","notifications_url":"https://api.github.com/repos/laubzega/cc65/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laubzega/cc65/labels{/name}","releases_url":"https://api.github.com/repos/laubzega/cc65/releases{/id}","deployments_url":"https://api.github.com/repos/laubzega/cc65/deployments","created_at":"2018-08-23T18:02:38Z","updated_at":"2018-10-12T04:41:05Z","pushed_at":"2018-10-14T21:11:41Z","git_url":"git://github.com/laubzega/cc65.git","ssh_url":"git@github.com:laubzega/cc65.git","clone_url":"https://github.com/laubzega/cc65.git","svn_url":"https://github.com/laubzega/cc65","homepage":"http://cc65.github.io/cc65","size":21889,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"zlib","name":"zlib License","spdx_id":"Zlib","url":"https://api.github.com/licenses/zlib","node_id":"MDc6TGljZW5zZTI3"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cc65:master","ref":"master","sha":"03e43d1fbfc281f05026e4466c5e73e2cdac0dcb","user":{"login":"cc65","id":6959645,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk2NDU=","avatar_url":"https://avatars2.githubusercontent.com/u/6959645?v=4","gravatar_id":"","url":"https://api.github.com/users/cc65","html_url":"https://github.com/cc65","followers_url":"https://api.github.com/users/cc65/followers","following_url":"https://api.github.com/users/cc65/following{/other_user}","gists_url":"https://api.github.com/users/cc65/gists{/gist_id}","starred_url":"https://api.github.com/users/cc65/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cc65/subscriptions","organizations_url":"https://api.github.com/users/cc65/orgs","repos_url":"https://api.github.com/users/cc65/repos","events_url":"https://api.github.com/users/cc65/events{/privacy}","received_events_url":"https://api.github.com/users/cc65/received_events","type":"Organization","site_admin":false},"repo":{"id":8932489,"node_id":"MDEwOlJlcG9zaXRvcnk4OTMyNDg5","name":"cc65","full_name":"cc65/cc65","private":false,"owner":{"login":"cc65","id":6959645,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk2NDU=","avatar_url":"https://avatars2.githubusercontent.com/u/6959645?v=4","gravatar_id":"","url":"https://api.github.com/users/cc65","html_url":"https://github.com/cc65","followers_url":"https://api.github.com/users/cc65/followers","following_url":"https://api.github.com/users/cc65/following{/other_user}","gists_url":"https://api.github.com/users/cc65/gists{/gist_id}","starred_url":"https://api.github.com/users/cc65/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cc65/subscriptions","organizations_url":"https://api.github.com/users/cc65/orgs","repos_url":"https://api.github.com/users/cc65/repos","events_url":"https://api.github.com/users/cc65/events{/privacy}","received_events_url":"https://api.github.com/users/cc65/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cc65/cc65","description":"cc65 - a freeware C compiler for 6502 based systems —","fork":false,"url":"https://api.github.com/repos/cc65/cc65","forks_url":"https://api.github.com/repos/cc65/cc65/forks","keys_url":"https://api.github.com/repos/cc65/cc65/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cc65/cc65/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cc65/cc65/teams","hooks_url":"https://api.github.com/repos/cc65/cc65/hooks","issue_events_url":"https://api.github.com/repos/cc65/cc65/issues/events{/number}","events_url":"https://api.github.com/repos/cc65/cc65/events","assignees_url":"https://api.github.com/repos/cc65/cc65/assignees{/user}","branches_url":"https://api.github.com/repos/cc65/cc65/branches{/branch}","tags_url":"https://api.github.com/repos/cc65/cc65/tags","blobs_url":"https://api.github.com/repos/cc65/cc65/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cc65/cc65/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cc65/cc65/git/refs{/sha}","trees_url":"https://api.github.com/repos/cc65/cc65/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cc65/cc65/statuses/{sha}","languages_url":"https://api.github.com/repos/cc65/cc65/languages","stargazers_url":"https://api.github.com/repos/cc65/cc65/stargazers","contributors_url":"https://api.github.com/repos/cc65/cc65/contributors","subscribers_url":"https://api.github.com/repos/cc65/cc65/subscribers","subscription_url":"https://api.github.com/repos/cc65/cc65/subscription","commits_url":"https://api.github.com/repos/cc65/cc65/commits{/sha}","git_commits_url":"https://api.github.com/repos/cc65/cc65/git/commits{/sha}","comments_url":"https://api.github.com/repos/cc65/cc65/comments{/number}","issue_comment_url":"https://api.github.com/repos/cc65/cc65/issues/comments{/number}","contents_url":"https://api.github.com/repos/cc65/cc65/contents/{+path}","compare_url":"https://api.github.com/repos/cc65/cc65/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cc65/cc65/merges","archive_url":"https://api.github.com/repos/cc65/cc65/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cc65/cc65/downloads","issues_url":"https://api.github.com/repos/cc65/cc65/issues{/number}","pulls_url":"https://api.github.com/repos/cc65/cc65/pulls{/number}","milestones_url":"https://api.github.com/repos/cc65/cc65/milestones{/number}","notifications_url":"https://api.github.com/repos/cc65/cc65/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cc65/cc65/labels{/name}","releases_url":"https://api.github.com/repos/cc65/cc65/releases{/id}","deployments_url":"https://api.github.com/repos/cc65/cc65/deployments","created_at":"2013-03-21T15:56:48Z","updated_at":"2018-10-15T02:04:28Z","pushed_at":"2018-10-14T21:11:43Z","git_url":"git://github.com/cc65/cc65.git","ssh_url":"git@github.com:cc65/cc65.git","clone_url":"https://github.com/cc65/cc65.git","svn_url":"https://github.com/cc65/cc65","homepage":"https://cc65.github.io","size":21863,"stargazers_count":696,"watchers_count":696,"language":"C","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":160,"mirror_url":null,"archived":false,"open_issues_count":82,"license":{"key":"zlib","name":"zlib License","spdx_id":"Zlib","url":"https://api.github.com/licenses/zlib","node_id":"MDc6TGljZW5zZTI3"},"forks":160,"open_issues":82,"watchers":696,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cc65/cc65/pulls/773"},"html":{"href":"https://github.com/cc65/cc65/pull/773"},"issue":{"href":"https://api.github.com/repos/cc65/cc65/issues/773"},"comments":{"href":"https://api.github.com/repos/cc65/cc65/issues/773/comments"},"review_comments":{"href":"https://api.github.com/repos/cc65/cc65/pulls/773/comments"},"review_comment":{"href":"https://api.github.com/repos/cc65/cc65/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cc65/cc65/pulls/773/commits"},"statuses":{"href":"https://api.github.com/repos/cc65/cc65/statuses/6791920c1b6c79e97ac6faa3f0e1ddc8706995c4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"oliverschmidt"}}