{"action":"opened","number":16,"pull_request":{"url":"https://api.github.com/repos/kstenerud/Musashi/pulls/16","id":62141530,"html_url":"https://github.com/kstenerud/Musashi/pull/16","diff_url":"https://github.com/kstenerud/Musashi/pull/16.diff","patch_url":"https://github.com/kstenerud/Musashi/pull/16.patch","issue_url":"https://api.github.com/repos/kstenerud/Musashi/issues/16","number":16,"state":"open","locked":false,"title":"Don't let USE_ALL_CYCLES overspend cycles","user":{"login":"marhel","id":2725205,"avatar_url":"https://avatars.githubusercontent.com/u/2725205?v=3","gravatar_id":"","url":"https://api.github.com/users/marhel","html_url":"https://github.com/marhel","followers_url":"https://api.github.com/users/marhel/followers","following_url":"https://api.github.com/users/marhel/following{/other_user}","gists_url":"https://api.github.com/users/marhel/gists{/gist_id}","starred_url":"https://api.github.com/users/marhel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marhel/subscriptions","organizations_url":"https://api.github.com/users/marhel/orgs","repos_url":"https://api.github.com/users/marhel/repos","events_url":"https://api.github.com/users/marhel/events{/privacy}","received_events_url":"https://api.github.com/users/marhel/received_events","type":"User","site_admin":false},"body":"Ok so this PR is perhaps a bit pedantic. But when running tests comparing instructions in [r68k](https://github.com/marhel/r68k), Musashi sometimes reported consuming an odd number of cycles for jump instructions!\r\n\r\nAfter some investigation this was explained by the following;\r\n\r\nWhen an branch/jump instruction is jumping back to itself,\r\nUSE_ALL_CYCLES should not set m68ki_remaining_cycles to zero, because\r\nthat optimization reports more cycles spent than would have been\r\nconsumed without the optimization. If the jump takes N cycles, and\r\nm68ki_remaining_cycles is not an multiple of N, then we want to spend\r\njust a multiple of N and leave the remainder (m68ki_remaining_cycles % N\r\ncycles). Setting to zero spends extra cycles corresponding to the\r\nremainder.\r\n\r\nAfter executing the jump, m68k_execute will then deduct N from\r\nm68ki_remaining_cycles, consuming the remaining cycles (and some) ending\r\nthe execution loop, returning initial_cycles - remaining_cycles as\r\nconsumed.\r\n\r\nWhen spending the remainder, what's effectively being returned as\r\nconsumed is initial_cycles + N, instead of initial_cycles - remainder +\r\nN.\r\n\r\nWhat we saw, when single-stepping with m68k_execute(1) was 1 + 8 = 9 cycles for a AI-\r\njump for example, instead of 1 - 1 + 8 = 8.\r\n","created_at":"2016-03-08T21:44:29Z","updated_at":"2016-03-08T21:44:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kstenerud/Musashi/pulls/16/commits","review_comments_url":"https://api.github.com/repos/kstenerud/Musashi/pulls/16/comments","review_comment_url":"https://api.github.com/repos/kstenerud/Musashi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kstenerud/Musashi/issues/16/comments","statuses_url":"https://api.github.com/repos/kstenerud/Musashi/statuses/415fc94580e08c8f00fd8a1c22f51d8c51c9da24","head":{"label":"marhel:use-all-cycles","ref":"use-all-cycles","sha":"415fc94580e08c8f00fd8a1c22f51d8c51c9da24","user":{"login":"marhel","id":2725205,"avatar_url":"https://avatars.githubusercontent.com/u/2725205?v=3","gravatar_id":"","url":"https://api.github.com/users/marhel","html_url":"https://github.com/marhel","followers_url":"https://api.github.com/users/marhel/followers","following_url":"https://api.github.com/users/marhel/following{/other_user}","gists_url":"https://api.github.com/users/marhel/gists{/gist_id}","starred_url":"https://api.github.com/users/marhel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marhel/subscriptions","organizations_url":"https://api.github.com/users/marhel/orgs","repos_url":"https://api.github.com/users/marhel/repos","events_url":"https://api.github.com/users/marhel/events{/privacy}","received_events_url":"https://api.github.com/users/marhel/received_events","type":"User","site_admin":false},"repo":{"id":49947861,"name":"Musashi","full_name":"marhel/Musashi","owner":{"login":"marhel","id":2725205,"avatar_url":"https://avatars.githubusercontent.com/u/2725205?v=3","gravatar_id":"","url":"https://api.github.com/users/marhel","html_url":"https://github.com/marhel","followers_url":"https://api.github.com/users/marhel/followers","following_url":"https://api.github.com/users/marhel/following{/other_user}","gists_url":"https://api.github.com/users/marhel/gists{/gist_id}","starred_url":"https://api.github.com/users/marhel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marhel/subscriptions","organizations_url":"https://api.github.com/users/marhel/orgs","repos_url":"https://api.github.com/users/marhel/repos","events_url":"https://api.github.com/users/marhel/events{/privacy}","received_events_url":"https://api.github.com/users/marhel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marhel/Musashi","description":"Motorola 680x0 emulator written in C","fork":true,"url":"https://api.github.com/repos/marhel/Musashi","forks_url":"https://api.github.com/repos/marhel/Musashi/forks","keys_url":"https://api.github.com/repos/marhel/Musashi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marhel/Musashi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marhel/Musashi/teams","hooks_url":"https://api.github.com/repos/marhel/Musashi/hooks","issue_events_url":"https://api.github.com/repos/marhel/Musashi/issues/events{/number}","events_url":"https://api.github.com/repos/marhel/Musashi/events","assignees_url":"https://api.github.com/repos/marhel/Musashi/assignees{/user}","branches_url":"https://api.github.com/repos/marhel/Musashi/branches{/branch}","tags_url":"https://api.github.com/repos/marhel/Musashi/tags","blobs_url":"https://api.github.com/repos/marhel/Musashi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marhel/Musashi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marhel/Musashi/git/refs{/sha}","trees_url":"https://api.github.com/repos/marhel/Musashi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marhel/Musashi/statuses/{sha}","languages_url":"https://api.github.com/repos/marhel/Musashi/languages","stargazers_url":"https://api.github.com/repos/marhel/Musashi/stargazers","contributors_url":"https://api.github.com/repos/marhel/Musashi/contributors","subscribers_url":"https://api.github.com/repos/marhel/Musashi/subscribers","subscription_url":"https://api.github.com/repos/marhel/Musashi/subscription","commits_url":"https://api.github.com/repos/marhel/Musashi/commits{/sha}","git_commits_url":"https://api.github.com/repos/marhel/Musashi/git/commits{/sha}","comments_url":"https://api.github.com/repos/marhel/Musashi/comments{/number}","issue_comment_url":"https://api.github.com/repos/marhel/Musashi/issues/comments{/number}","contents_url":"https://api.github.com/repos/marhel/Musashi/contents/{+path}","compare_url":"https://api.github.com/repos/marhel/Musashi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marhel/Musashi/merges","archive_url":"https://api.github.com/repos/marhel/Musashi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marhel/Musashi/downloads","issues_url":"https://api.github.com/repos/marhel/Musashi/issues{/number}","pulls_url":"https://api.github.com/repos/marhel/Musashi/pulls{/number}","milestones_url":"https://api.github.com/repos/marhel/Musashi/milestones{/number}","notifications_url":"https://api.github.com/repos/marhel/Musashi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marhel/Musashi/labels{/name}","releases_url":"https://api.github.com/repos/marhel/Musashi/releases{/id}","deployments_url":"https://api.github.com/repos/marhel/Musashi/deployments","created_at":"2016-01-19T11:21:27Z","updated_at":"2016-01-19T11:21:27Z","pushed_at":"2016-03-08T21:37:15Z","git_url":"git://github.com/marhel/Musashi.git","ssh_url":"git@github.com:marhel/Musashi.git","clone_url":"https://github.com/marhel/Musashi.git","svn_url":"https://github.com/marhel/Musashi","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kstenerud:master","ref":"master","sha":"0c55d50af289055ebb371c2f46a54e5ae936ea84","user":{"login":"kstenerud","id":245857,"avatar_url":"https://avatars.githubusercontent.com/u/245857?v=3","gravatar_id":"","url":"https://api.github.com/users/kstenerud","html_url":"https://github.com/kstenerud","followers_url":"https://api.github.com/users/kstenerud/followers","following_url":"https://api.github.com/users/kstenerud/following{/other_user}","gists_url":"https://api.github.com/users/kstenerud/gists{/gist_id}","starred_url":"https://api.github.com/users/kstenerud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstenerud/subscriptions","organizations_url":"https://api.github.com/users/kstenerud/orgs","repos_url":"https://api.github.com/users/kstenerud/repos","events_url":"https://api.github.com/users/kstenerud/events{/privacy}","received_events_url":"https://api.github.com/users/kstenerud/received_events","type":"User","site_admin":false},"repo":{"id":11435547,"name":"Musashi","full_name":"kstenerud/Musashi","owner":{"login":"kstenerud","id":245857,"avatar_url":"https://avatars.githubusercontent.com/u/245857?v=3","gravatar_id":"","url":"https://api.github.com/users/kstenerud","html_url":"https://github.com/kstenerud","followers_url":"https://api.github.com/users/kstenerud/followers","following_url":"https://api.github.com/users/kstenerud/following{/other_user}","gists_url":"https://api.github.com/users/kstenerud/gists{/gist_id}","starred_url":"https://api.github.com/users/kstenerud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstenerud/subscriptions","organizations_url":"https://api.github.com/users/kstenerud/orgs","repos_url":"https://api.github.com/users/kstenerud/repos","events_url":"https://api.github.com/users/kstenerud/events{/privacy}","received_events_url":"https://api.github.com/users/kstenerud/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kstenerud/Musashi","description":"Motorola 680x0 emulator written in C","fork":false,"url":"https://api.github.com/repos/kstenerud/Musashi","forks_url":"https://api.github.com/repos/kstenerud/Musashi/forks","keys_url":"https://api.github.com/repos/kstenerud/Musashi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kstenerud/Musashi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kstenerud/Musashi/teams","hooks_url":"https://api.github.com/repos/kstenerud/Musashi/hooks","issue_events_url":"https://api.github.com/repos/kstenerud/Musashi/issues/events{/number}","events_url":"https://api.github.com/repos/kstenerud/Musashi/events","assignees_url":"https://api.github.com/repos/kstenerud/Musashi/assignees{/user}","branches_url":"https://api.github.com/repos/kstenerud/Musashi/branches{/branch}","tags_url":"https://api.github.com/repos/kstenerud/Musashi/tags","blobs_url":"https://api.github.com/repos/kstenerud/Musashi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kstenerud/Musashi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kstenerud/Musashi/git/refs{/sha}","trees_url":"https://api.github.com/repos/kstenerud/Musashi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kstenerud/Musashi/statuses/{sha}","languages_url":"https://api.github.com/repos/kstenerud/Musashi/languages","stargazers_url":"https://api.github.com/repos/kstenerud/Musashi/stargazers","contributors_url":"https://api.github.com/repos/kstenerud/Musashi/contributors","subscribers_url":"https://api.github.com/repos/kstenerud/Musashi/subscribers","subscription_url":"https://api.github.com/repos/kstenerud/Musashi/subscription","commits_url":"https://api.github.com/repos/kstenerud/Musashi/commits{/sha}","git_commits_url":"https://api.github.com/repos/kstenerud/Musashi/git/commits{/sha}","comments_url":"https://api.github.com/repos/kstenerud/Musashi/comments{/number}","issue_comment_url":"https://api.github.com/repos/kstenerud/Musashi/issues/comments{/number}","contents_url":"https://api.github.com/repos/kstenerud/Musashi/contents/{+path}","compare_url":"https://api.github.com/repos/kstenerud/Musashi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kstenerud/Musashi/merges","archive_url":"https://api.github.com/repos/kstenerud/Musashi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kstenerud/Musashi/downloads","issues_url":"https://api.github.com/repos/kstenerud/Musashi/issues{/number}","pulls_url":"https://api.github.com/repos/kstenerud/Musashi/pulls{/number}","milestones_url":"https://api.github.com/repos/kstenerud/Musashi/milestones{/number}","notifications_url":"https://api.github.com/repos/kstenerud/Musashi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kstenerud/Musashi/labels{/name}","releases_url":"https://api.github.com/repos/kstenerud/Musashi/releases{/id}","deployments_url":"https://api.github.com/repos/kstenerud/Musashi/deployments","created_at":"2013-07-15T22:47:17Z","updated_at":"2016-02-28T01:23:42Z","pushed_at":"2016-03-08T21:07:40Z","git_url":"git://github.com/kstenerud/Musashi.git","ssh_url":"git@github.com:kstenerud/Musashi.git","clone_url":"https://github.com/kstenerud/Musashi.git","svn_url":"https://github.com/kstenerud/Musashi","homepage":null,"size":236,"stargazers_count":32,"watchers_count":32,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":6,"forks":11,"open_issues":6,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kstenerud/Musashi/pulls/16"},"html":{"href":"https://github.com/kstenerud/Musashi/pull/16"},"issue":{"href":"https://api.github.com/repos/kstenerud/Musashi/issues/16"},"comments":{"href":"https://api.github.com/repos/kstenerud/Musashi/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/kstenerud/Musashi/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/kstenerud/Musashi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kstenerud/Musashi/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/kstenerud/Musashi/statuses/415fc94580e08c8f00fd8a1c22f51d8c51c9da24"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1,"deletions":1,"changed_files":1}}