What you're trying to do won't work. PC BIOS interrupts, like int 16h, are only available when the system is running in real mode (i.e, at startup before the MMU is enabled); they cannot be used in Linux executables.
That being said, in general, you can specify an output register using gcc assembler constraints. For example:
asm(
"movq $0, %RAX\n"
"int $0x16\n"
: "=a" (ret)
);
Note that there's no mov
instruction at the end of this code! The "=A"
constraint tells the compiler that the result will be left in the A register; it'll figure out what to do from there. (There are ways to eliminate the first mov
as well, if you're clever about it.)