{"action":"created","issue":{"url":"https://api.github.com/repos/herumi/xbyak/issues/38","repository_url":"https://api.github.com/repos/herumi/xbyak","labels_url":"https://api.github.com/repos/herumi/xbyak/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/herumi/xbyak/issues/38/comments","events_url":"https://api.github.com/repos/herumi/xbyak/issues/38/events","html_url":"https://github.com/herumi/xbyak/issues/38","id":190528888,"number":38,"title":"Question: how to use RIP to access \"external\" C structure","user":{"login":"gregory38","id":1569559,"avatar_url":"https://avatars.githubusercontent.com/u/1569559?v=3","gravatar_id":"","url":"https://api.github.com/users/gregory38","html_url":"https://github.com/gregory38","followers_url":"https://api.github.com/users/gregory38/followers","following_url":"https://api.github.com/users/gregory38/following{/other_user}","gists_url":"https://api.github.com/users/gregory38/gists{/gist_id}","starred_url":"https://api.github.com/users/gregory38/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregory38/subscriptions","organizations_url":"https://api.github.com/users/gregory38/orgs","repos_url":"https://api.github.com/users/gregory38/repos","events_url":"https://api.github.com/users/gregory38/events{/privacy}","received_events_url":"https://api.github.com/users/gregory38/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-19T23:53:33Z","updated_at":"2016-11-20T13:07:15Z","closed_at":"2016-11-20T13:07:15Z","body":"Hello,\r\n\r\nI would like to use rip addressing to load/store from/to a C structure. I fail to understand how I can do it. As I need the `rip` value. Did I miss something, how must I write the code? Thanks you\r\n\r\nHere a small example:\r\n```\r\n// In my C++ program\r\nstruct S {\r\n    char[16] v;\r\n} data;\r\n\r\n// In my JIT generation\r\n// Goal: move data.v to xmm1\r\n```\r\nFirst tentative: will really add data to rip as expected but I don't want to do that.\r\n```\r\nvmovdqa(xmm1, ptr [ rip + (size_t)&data]);\r\n```\r\n\r\nSecond tentative: can't use `-` with label\r\n```\r\n// So you need to manually compute the address of the next instruction so something like this\r\nLabel next;\r\nvmovdqa(xmm1, ptr [ rip - next + (size_t)&data]);\r\nL(next);\r\n```\r\n\r\nThird tentative: manually compute the displacement but requires to know the size of the instruction in advance.\r\n```\r\nvmovdqa(xmm1, ptr [ rip + (size_t)&data - top_ - size_ - 8]);\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/herumi/xbyak/issues/comments/261777318","html_url":"https://github.com/herumi/xbyak/issues/38#issuecomment-261777318","issue_url":"https://api.github.com/repos/herumi/xbyak/issues/38","id":261777318,"user":{"login":"gregory38","id":1569559,"avatar_url":"https://avatars.githubusercontent.com/u/1569559?v=3","gravatar_id":"","url":"https://api.github.com/users/gregory38","html_url":"https://github.com/gregory38","followers_url":"https://api.github.com/users/gregory38/followers","following_url":"https://api.github.com/users/gregory38/following{/other_user}","gists_url":"https://api.github.com/users/gregory38/gists{/gist_id}","starred_url":"https://api.github.com/users/gregory38/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregory38/subscriptions","organizations_url":"https://api.github.com/users/gregory38/orgs","repos_url":"https://api.github.com/users/gregory38/repos","events_url":"https://api.github.com/users/gregory38/events{/privacy}","received_events_url":"https://api.github.com/users/gregory38/received_events","type":"User","site_admin":false},"created_at":"2016-11-20T13:07:15Z","updated_at":"2016-11-20T13:07:15Z","body":"Thanks you very much. It works nicely"}}
{"actor":{"display_login":"gregory38"}}