I have this inline assembler on my C code:
asm volatile ("mov %ah, 01\n"
"int $0x16\n");
This code is a assembler version of getch()
It works, but now I want to get the value that returned this inline assembler (specifically I want to know the key that returns the interruption 16h).
How I can do it?
Edit: I'm making MS-DOS COM files using C and DosBox. Currently everything is working fine, except for the problem that I'm having right now.
Full code:
asm (".code16gcc\n"
"call dosmain\n"
"mov $0x4C,%ah\n"
"int $0x21\n");
static void print(char *string)
{
asm volatile ("mov $0x09, %%ah\n"
"int $0x21\n"
: /* no output */
: "d"(string)
: "ah");
}
int dosmain(void)
{
int a;
asm volatile ("mov %%ah, 0\n"
"int $0x16\n"
: "=r"(a));
print(a);
print("Hello, World!\n$");
return 0;
}
But causes a nice "buffer overflow?"