I have this code which enables the cursor:
inline uint8_t inb(uint16_t port)
{
uint8_t ret;
asm volatile ( "inb %1, %0"
: "=a"(ret)
: "Nd"(port) );
return ret;
}
static inline void outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %0, %1" : : "a"(val), "d"(port) );
}
int main(void)
{
outb(0x3D4, 0x0A);
outb(0x3D5, (inb(0x3D5) & 0xC0) | 1);
outb(0x3D4, 0x0B);
outb(0x3D5, (inb(0x3D5) & 0xE0) | 2);
}
I want dont want to use inline assembly and wrote it in nasm assembly, however when using the assembly implementation of outb instead of inline assembly it wont enable the cursor correctly. The declaration for the nasm function:
extern void outb(uint16_t port, uint8_t val);
And the function:
outb:
mov dx, di
mov eax, esi
out dx, al
ret
Whats the problem?
Update: The function now looks like this but it still doesnt work:
outb:
push ebp
mov esp, ebp
mov dx, word [ebp+2]
mov al, byte [ebp+3]
out dx, al
mov esp, ebp
pop ebp
ret