GitHub PullRequestEvent at 2014-10-06 21:48:23
Repository: 6502-rs
Actor: amw-zero
Payload: {"action":"closed","number":9,"pull_request":{"url":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9","id":22248044,"html_url":"https://github.com/amw-zero/6502-rs/pull/9","diff_url":"https://github.com/amw-zero/6502-rs/pull/9.diff","patch_url":"https://github.com/amw-zero/6502-rs/pull/9.patch","issue_url":"https://api.github.com/repos/amw-zero/6502-rs/issues/9","number":9,"state":"closed","locked":false,"title":"Orthogonal AddressingMode handling; implement all addressing modes for ADC, LDA, LDX, LDY","user":{"login":"typelist","id":6258344,"avatar_url":"https://avatars.githubusercontent.com/u/6258344?v=2","gravatar_id":"","url":"https://api.github.com/users/typelist","html_url":"https://github.com/typelist","followers_url":"https://api.github.com/users/typelist/followers","following_url":"https://api.github.com/users/typelist/following{/other_user}","gists_url":"https://api.github.com/users/typelist/gists{/gist_id}","starred_url":"https://api.github.com/users/typelist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typelist/subscriptions","organizations_url":"https://api.github.com/users/typelist/orgs","repos_url":"https://api.github.com/users/typelist/repos","events_url":"https://api.github.com/users/typelist/events{/privacy}","received_events_url":"https://api.github.com/users/typelist/received_events","type":"User","site_admin":false},"body":"We can factor out the addressing-mode-processing code that's common to all instructions by letting the addressing modes have different kinds of output.\r\n\r\n```rust\r\npub enum AMOut /* poorly named, sorry */ {\r\n    UseImplied,\r\n    UseImmediate(u8),\r\n    UseRelative(i8),\r\n    UseAddress(Address),\r\n}\r\n\r\nimpl AddressingMode {\r\n    pub fn process(self, machine: &Machine, arr: &[u8]) -> AMOut {\r\n        // ...\r\n    }\r\n}\r\n```\r\n\r\nThis means we only need to handle 2 cases for ADC when executing the instruction. Either it operates on an address (no matter how we got that address--that's the AddressingMode's job), or it operates on an immediate value:\r\n\r\n```rust\r\nimpl Machine {\r\n    pub fn execute_instruction(&mut self, decoded_instr: DecodedInstr) {\r\n        match decoded_instr {\r\n            (ADC, UseImmediate(val)) => {\r\n                self.add_with_carry(val as i8);\r\n            },\r\n            (ADC, UseAddress(addr)) => {\r\n                let val = self.memory.get_byte(addr) as i8;\r\n                self.add_with_carry(val);\r\n            },\r\n\r\n            (LDA, UseImmediate(val)) => {\r\n                self.load_accumulator(val as i8);\r\n            },\r\n            (LDA, UseAddress(addr)) => {\r\n                let val = self.memory.get_byte(addr);\r\n                self.load_accumulator(val as i8);\r\n            },\r\n\r\n            (_, _) => {\r\n                // could fail! here\r\n            }\r\n        }\r\n    }\r\n\r\n    // ...\r\n}\r\n```\r\n\r\nThe logic that's common to LDA and ADC could be factored out more, but it's a start.\r\n","created_at":"2014-10-04T21:09:53Z","updated_at":"2014-10-06T21:48:23Z","closed_at":"2014-10-06T21:48:23Z","merged_at":"2014-10-06T21:48:23Z","merge_commit_sha":"6c4f3aea475a60e9052eb558a64b6e8eb5198899","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9/commits","review_comments_url":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9/comments","review_comment_url":"https://api.github.com/repos/amw-zero/6502-rs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/amw-zero/6502-rs/issues/9/comments","statuses_url":"https://api.github.com/repos/amw-zero/6502-rs/statuses/7556071edbba3dbd74ad3f5ed45f32f6c473c287","head":{"label":"typelist:big-old-table","ref":"big-old-table","sha":"7556071edbba3dbd74ad3f5ed45f32f6c473c287","user":{"login":"typelist","id":6258344,"avatar_url":"https://avatars.githubusercontent.com/u/6258344?v=2","gravatar_id":"","url":"https://api.github.com/users/typelist","html_url":"https://github.com/typelist","followers_url":"https://api.github.com/users/typelist/followers","following_url":"https://api.github.com/users/typelist/following{/other_user}","gists_url":"https://api.github.com/users/typelist/gists{/gist_id}","starred_url":"https://api.github.com/users/typelist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typelist/subscriptions","organizations_url":"https://api.github.com/users/typelist/orgs","repos_url":"https://api.github.com/users/typelist/repos","events_url":"https://api.github.com/users/typelist/events{/privacy}","received_events_url":"https://api.github.com/users/typelist/received_events","type":"User","site_admin":false},"repo":{"id":24479152,"name":"6502-rs","full_name":"typelist/6502-rs","owner":{"login":"typelist","id":6258344,"avatar_url":"https://avatars.githubusercontent.com/u/6258344?v=2","gravatar_id":"","url":"https://api.github.com/users/typelist","html_url":"https://github.com/typelist","followers_url":"https://api.github.com/users/typelist/followers","following_url":"https://api.github.com/users/typelist/following{/other_user}","gists_url":"https://api.github.com/users/typelist/gists{/gist_id}","starred_url":"https://api.github.com/users/typelist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typelist/subscriptions","organizations_url":"https://api.github.com/users/typelist/orgs","repos_url":"https://api.github.com/users/typelist/repos","events_url":"https://api.github.com/users/typelist/events{/privacy}","received_events_url":"https://api.github.com/users/typelist/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/typelist/6502-rs","description":"6502 Emulator in Rust","fork":true,"url":"https://api.github.com/repos/typelist/6502-rs","forks_url":"https://api.github.com/repos/typelist/6502-rs/forks","keys_url":"https://api.github.com/repos/typelist/6502-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/typelist/6502-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/typelist/6502-rs/teams","hooks_url":"https://api.github.com/repos/typelist/6502-rs/hooks","issue_events_url":"https://api.github.com/repos/typelist/6502-rs/issues/events{/number}","events_url":"https://api.github.com/repos/typelist/6502-rs/events","assignees_url":"https://api.github.com/repos/typelist/6502-rs/assignees{/user}","branches_url":"https://api.github.com/repos/typelist/6502-rs/branches{/branch}","tags_url":"https://api.github.com/repos/typelist/6502-rs/tags","blobs_url":"https://api.github.com/repos/typelist/6502-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/typelist/6502-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/typelist/6502-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/typelist/6502-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/typelist/6502-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/typelist/6502-rs/languages","stargazers_url":"https://api.github.com/repos/typelist/6502-rs/stargazers","contributors_url":"https://api.github.com/repos/typelist/6502-rs/contributors","subscribers_url":"https://api.github.com/repos/typelist/6502-rs/subscribers","subscription_url":"https://api.github.com/repos/typelist/6502-rs/subscription","commits_url":"https://api.github.com/repos/typelist/6502-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/typelist/6502-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/typelist/6502-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/typelist/6502-rs/issues/comments/{number}","contents_url":"https://api.github.com/repos/typelist/6502-rs/contents/{+path}","compare_url":"https://api.github.com/repos/typelist/6502-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/typelist/6502-rs/merges","archive_url":"https://api.github.com/repos/typelist/6502-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/typelist/6502-rs/downloads","issues_url":"https://api.github.com/repos/typelist/6502-rs/issues{/number}","pulls_url":"https://api.github.com/repos/typelist/6502-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/typelist/6502-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/typelist/6502-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/typelist/6502-rs/labels{/name}","releases_url":"https://api.github.com/repos/typelist/6502-rs/releases{/id}","created_at":"2014-09-25T23:41:18Z","updated_at":"2014-09-26T06:31:48Z","pushed_at":"2014-10-04T21:48:06Z","git_url":"git://github.com/typelist/6502-rs.git","ssh_url":"git@github.com:typelist/6502-rs.git","clone_url":"https://github.com/typelist/6502-rs.git","svn_url":"https://github.com/typelist/6502-rs","homepage":null,"size":198,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"amw-zero:master","ref":"master","sha":"b0ff12ac33dbb846ac05cddf5c306a3ca560e93d","user":{"login":"amw-zero","id":4043433,"avatar_url":"https://avatars.githubusercontent.com/u/4043433?v=2","gravatar_id":"","url":"https://api.github.com/users/amw-zero","html_url":"https://github.com/amw-zero","followers_url":"https://api.github.com/users/amw-zero/followers","following_url":"https://api.github.com/users/amw-zero/following{/other_user}","gists_url":"https://api.github.com/users/amw-zero/gists{/gist_id}","starred_url":"https://api.github.com/users/amw-zero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amw-zero/subscriptions","organizations_url":"https://api.github.com/users/amw-zero/orgs","repos_url":"https://api.github.com/users/amw-zero/repos","events_url":"https://api.github.com/users/amw-zero/events{/privacy}","received_events_url":"https://api.github.com/users/amw-zero/received_events","type":"User","site_admin":false},"repo":{"id":24478631,"name":"6502-rs","full_name":"amw-zero/6502-rs","owner":{"login":"amw-zero","id":4043433,"avatar_url":"https://avatars.githubusercontent.com/u/4043433?v=2","gravatar_id":"","url":"https://api.github.com/users/amw-zero","html_url":"https://github.com/amw-zero","followers_url":"https://api.github.com/users/amw-zero/followers","following_url":"https://api.github.com/users/amw-zero/following{/other_user}","gists_url":"https://api.github.com/users/amw-zero/gists{/gist_id}","starred_url":"https://api.github.com/users/amw-zero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amw-zero/subscriptions","organizations_url":"https://api.github.com/users/amw-zero/orgs","repos_url":"https://api.github.com/users/amw-zero/repos","events_url":"https://api.github.com/users/amw-zero/events{/privacy}","received_events_url":"https://api.github.com/users/amw-zero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amw-zero/6502-rs","description":"6502 Emulator in Rust","fork":false,"url":"https://api.github.com/repos/amw-zero/6502-rs","forks_url":"https://api.github.com/repos/amw-zero/6502-rs/forks","keys_url":"https://api.github.com/repos/amw-zero/6502-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amw-zero/6502-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amw-zero/6502-rs/teams","hooks_url":"https://api.github.com/repos/amw-zero/6502-rs/hooks","issue_events_url":"https://api.github.com/repos/amw-zero/6502-rs/issues/events{/number}","events_url":"https://api.github.com/repos/amw-zero/6502-rs/events","assignees_url":"https://api.github.com/repos/amw-zero/6502-rs/assignees{/user}","branches_url":"https://api.github.com/repos/amw-zero/6502-rs/branches{/branch}","tags_url":"https://api.github.com/repos/amw-zero/6502-rs/tags","blobs_url":"https://api.github.com/repos/amw-zero/6502-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amw-zero/6502-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amw-zero/6502-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/amw-zero/6502-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amw-zero/6502-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/amw-zero/6502-rs/languages","stargazers_url":"https://api.github.com/repos/amw-zero/6502-rs/stargazers","contributors_url":"https://api.github.com/repos/amw-zero/6502-rs/contributors","subscribers_url":"https://api.github.com/repos/amw-zero/6502-rs/subscribers","subscription_url":"https://api.github.com/repos/amw-zero/6502-rs/subscription","commits_url":"https://api.github.com/repos/amw-zero/6502-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/amw-zero/6502-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/amw-zero/6502-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/amw-zero/6502-rs/issues/comments/{number}","contents_url":"https://api.github.com/repos/amw-zero/6502-rs/contents/{+path}","compare_url":"https://api.github.com/repos/amw-zero/6502-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amw-zero/6502-rs/merges","archive_url":"https://api.github.com/repos/amw-zero/6502-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amw-zero/6502-rs/downloads","issues_url":"https://api.github.com/repos/amw-zero/6502-rs/issues{/number}","pulls_url":"https://api.github.com/repos/amw-zero/6502-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/amw-zero/6502-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/amw-zero/6502-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amw-zero/6502-rs/labels{/name}","releases_url":"https://api.github.com/repos/amw-zero/6502-rs/releases{/id}","created_at":"2014-09-25T23:15:20Z","updated_at":"2014-09-26T15:09:44Z","pushed_at":"2014-10-06T21:48:23Z","git_url":"git://github.com/amw-zero/6502-rs.git","ssh_url":"git@github.com:amw-zero/6502-rs.git","clone_url":"https://github.com/amw-zero/6502-rs.git","svn_url":"https://github.com/amw-zero/6502-rs","homepage":null,"size":449,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9"},"html":{"href":"https://github.com/amw-zero/6502-rs/pull/9"},"issue":{"href":"https://api.github.com/repos/amw-zero/6502-rs/issues/9"},"comments":{"href":"https://api.github.com/repos/amw-zero/6502-rs/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/amw-zero/6502-rs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/amw-zero/6502-rs/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/amw-zero/6502-rs/statuses/7556071edbba3dbd74ad3f5ed45f32f6c473c287"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"amw-zero","id":4043433,"avatar_url":"https://avatars.githubusercontent.com/u/4043433?v=2","gravatar_id":"","url":"https://api.github.com/users/amw-zero","html_url":"https://github.com/amw-zero","followers_url":"https://api.github.com/users/amw-zero/followers","following_url":"https://api.github.com/users/amw-zero/following{/other_user}","gists_url":"https://api.github.com/users/amw-zero/gists{/gist_id}","starred_url":"https://api.github.com/users/amw-zero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amw-zero/subscriptions","organizations_url":"https://api.github.com/users/amw-zero/orgs","repos_url":"https://api.github.com/users/amw-zero/repos","events_url":"https://api.github.com/users/amw-zero/events{/privacy}","received_events_url":"https://api.github.com/users/amw-zero/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":3,"additions":699,"deletions":81,"changed_files":6}}