{"action":"closed","issue":{"url":"https://api.github.com/repos/kobalicek/asmjit/issues/73","labels_url":"https://api.github.com/repos/kobalicek/asmjit/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/kobalicek/asmjit/issues/73/comments","events_url":"https://api.github.com/repos/kobalicek/asmjit/issues/73/events","html_url":"https://github.com/kobalicek/asmjit/issues/73","id":57540054,"number":73,"title":"Code works incorrectly in 32 bit mode","user":{"login":"peastman","id":4379786,"avatar_url":"https://avatars.githubusercontent.com/u/4379786?v=3","gravatar_id":"","url":"https://api.github.com/users/peastman","html_url":"https://github.com/peastman","followers_url":"https://api.github.com/users/peastman/followers","following_url":"https://api.github.com/users/peastman/following{/other_user}","gists_url":"https://api.github.com/users/peastman/gists{/gist_id}","starred_url":"https://api.github.com/users/peastman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peastman/subscriptions","organizations_url":"https://api.github.com/users/peastman/orgs","repos_url":"https://api.github.com/users/peastman/repos","events_url":"https://api.github.com/users/peastman/events{/privacy}","received_events_url":"https://api.github.com/users/peastman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kobalicek/asmjit/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-13T00:06:54Z","updated_at":"2015-02-13T00:24:09Z","closed_at":"2015-02-13T00:24:09Z","body":"The following example generates a function to compute -sqrt(2).  It works correctly in 64 bit mode, but returns 0 in 32 bit mode.\r\n\r\n```C++\r\nvoid test() {\r\n    JitRuntime runtime;\r\n    X86Compiler c(&runtime);\r\n    c.addFunc(kFuncConvHost, FuncBuilder0<double>());\r\n    X86XmmVar argVar = c.newXmmVar(kX86VarTypeXmmSd);\r\n    X86XmmVar resultVar = c.newXmmVar(kX86VarTypeXmmSd);\r\n    X86GpVar argPointer(c);\r\n    double two = 2.0;\r\n    c.mov(argPointer, imm_ptr(&two));\r\n    c.movsd(argVar, x86::ptr(argPointer, 0, 0));\r\n    X86GpVar fn(c, kVarTypeIntPtr);\r\n    double (*function)(double) = sqrt;\r\n    c.mov(fn, imm_ptr((void*) function));\r\n    X86CallNode* call = c.call(fn, kFuncConvHost, FuncBuilder1<double, double>());\r\n    call->setArg(0, argVar);\r\n    call->setRet(0, resultVar);\r\n    c.xorps(argVar, argVar);\r\n    c.subsd(argVar, resultVar);\r\n    c.ret(argVar);\r\n    c.endFunc();\r\n    void* jitCode = c.make();\r\n    printf(\"%g\\n\", ((double (*)()) jitCode)());\r\n}\r\n```\r\n\r\nThis is almost identical to the example in #72.  The only difference is that\r\n\r\n```C++\r\n    c.ret(resultVar);\r\n```\r\n\r\nhas changed to\r\n\r\n```C++\r\n    c.xorps(argVar, argVar);\r\n    c.subsd(argVar, resultVar);\r\n    c.ret(argVar);\r\n```\r\n\r\nIt negates the return value by xor'ing argVar with itself to clear it, then subtracting resultVar and returning argVar."}}