> On Jul 7, 2016, at 6:36 AM, Gordo Cath <ds(a)y23.org> wrote:
>
> Hi,
> I'd like to be able to set a register directly from my c code. I'm using the llvm compiler in a x86_64 build/run environment.
>
> When I compile and link the following code I get no errors or warnings:
>
> I used the thread_create_running function and during setup set the r11 register to 0xBEAD as a start state using x86_thread_state64_t .
>
> ///snippet---- at the very start of my thread I have the following tidbit of code:
> register uint64_t r11 asm("r11");
> r11=0xfade; // some value -- don't care about the value, just want my value set.
> //end snippet
What, precisely, are you trying to do? As far as I know, that asm syntax is just wrong.
I would expect to see something like this for x86_64:
#include <stdio.h>
#include <sys/types.h>
int
main()
{
int64_t r11;
r11 = 0xc01ddeadbeef; /* init r11 */
asm ("movq %0, %%r11" :: "r"(r11) : "r11"); /* move r11 to %r11 */
r11 = 0; /* zero r11 */
asm ("movq %%r11, %0" : "=r"(r11) ::); /* move %r11 to r11 */
(void) printf("%llx\n", r11); /* verify %r11 */
return 0;
}
William Kucharski
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (Darwin-kernel(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists…
This email sent to site_archiver(a)lists.apple.com
Hi,
I'd like to be able to set a register directly from my c code. I'm using the llvm compiler in a x86_64 build/run environment.
When I compile and link the following code I get no errors or warnings:
I used the thread_create_running function and during setup set the r11 register to 0xBEAD as a start state using x86_thread_state64_t .
///snippet---- at the very start of my thread I have the following tidbit of code:
register uint64_t r11 asm("r11");
r11=0xfade; // some value -- don't care about the value, just want my value set.
//end snippet
Each time I run, my code crashes in what looks to be random locations, but its always my thread. However R11 is always set to 0xBEAD.
Am I missing something or is there something else I need to do to set r11 to a new value?
Gordo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (Darwin-kernel(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists…
This email sent to site_archiver(a)lists.apple.com
sudo nvram boot-args="debug=0xd44 kdp_match_name=firewire fwkdp=0x8000 _panicd_ip=1.2.3.4"
sudo shutdown -r now
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (Darwin-kernel(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists…
This email sent to site_archiver(a)lists.apple.com
sudo nvram boot-args="debug=0xd44 kdp_match_name=firewire fwkdp=0x8000 _panicd_ip=1.2.3.4"
sudo shutdown -r now
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (Darwin-kernel(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists…
This email sent to site_archiver(a)lists.apple.com