hi
I'm try to develop my own os and i try to develop conio library for my os in visual studio 2008. i developed must of importants functions that i need, but i can't write outp and inp functions!!!
where is my wrong in this function?! ( I'm working in protected mode)
void outp(unsigned portid,int value)
{
_asm
{
mov edx,[portid]
mov eax,[value]
out dx,eax
}
}
sorry for my bad english
wrriting outp function in MSVC++
Re: wrriting outp function in MSVC++
Why not use
if you are using MSVC? Its faster and you don't have to write a single line of assembler.
Code: Select all
extern "C" {
{
void __outbyte(unsigned short Port, unsigned char Data);
#pragma intrinsic(__outbyte)
}
inline void outp(unsigned portid,int value) { __outbyte(portid, value); }
Re: wrriting outp function in MSVC++
Heres my routines if you want to try them:
It doesnt really matter if you decide to use intrinsics or not as they both rely on compiler dependent code.
Code: Select all
// read byte from port
inline unsigned char _cdecl inportb (unsigned short portid) {
unsigned char res=0;
_asm {
mov dx, [portid]
in al, dx
mov [res], al
}
return res;
}
// write byte to port
inline void _cdecl outportb (unsigned short portid, unsigned char value) {
_asm {
mov al, [value]
mov dx, [portid]
out dx, al
}
}
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}