Search code examples
cudanvidiaptx

PTX - get value/address


I don't understand how the mov instruction works in PTX..

mov.type d, a

this moves a in d if a is a register or immediate value. By the way this can move into d the address of a if a is a variable in global, local or shared state space.

Let's suppose that a is a variable in global memory and points to an u64 with value 0x1... how do I store 0x1 into d since I can only get a's address??

I'm not sure on how to get a value instead of an address.. something like intel ASM's mov eax, ebx for address and mov eax, [ebx] for value (dereferencing ebx)


Solution

  • This answer should help you. It shows a worked example of using the mov and ld instructions to load a value from a pointer.