4 ms·
I see absolutely no examples in that link there where they assign into a register via C code, not using it anywhere else, and then assume you can read the same
by asveikau 3y ago
I see absolutely no examples in that link there where they assign into a register via C code, not using it anywhere else, and then assume you can read the same value back from that register in an asm() statement without declaring it as an input.
- dundarious 3y agoI referenced both links (the latter links to the former, and the former, which was in the first comment of mine you replied to, contains the following examples: register int *p1 asm ("r0") = …; register int *p2 asm ("r1") = …; register int *result asm ("r0"); asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); and int t1 = …; register int *p1 asm ("r0") = …; register int *p2 asm ("r1") = t1; register int *result asm ("r0"); asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); In my example, nr is rax and listed in the input section, rfd is rdi and also listed in the input section, and result is rax and listed in the output section (I even used your preferred syntax for specifying rax here). Using result after the syscall asm statement is perfectly valid.