I am developing a small toy core in C. I am at the point where I need to get user input from the keyboard. So far I have implemented inbusing the following code:
static inline uint8_t inb(uint16_t port) {
uint8_t ret;
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
return ret;
}
I know that a constraint "=a"means it al/ax/eaxwill be copied to retas output, but I'm still confused about the constraint "Nd". Can someone give an idea of why this restriction is necessary? Or why can't I just use a general purpose constraint like "r"or "b"? Any help would be appreciated.
source
share