-1st CODE-
original:
Code: Select all
unsigned char _cdecl inportb (unsigned short portid) {
#ifdef _MSC_VER
_asm {
mov dx, word ptr [portid]
in al, dx
mov byte ptr [portid], al
}
#endif
return (unsigned char)portid;
}
Code: Select all
unsigned char inportb(unsigned short portid){
__asm__(
"movw %[portid],%%dx \n"
"in %%dx,%%al \n"
"movb %%al, %[portid] \n"
: // no output
: [portid] "m" (portid) // input
: "dx","al" //clobbers
);
return (unsigned char) portid;
}
2nd CODE:
original:
Code: Select all
void _cdecl outportb (unsigned short portid, unsigned char value) {
#ifdef _MSC_VER
_asm {
mov al, byte ptr [value]
mov dx, word ptr [portid]
out dx, al
}
#endif
}
Code: Select all
void outportb (unsigned short portid, unsigned char value){
__asm__(
"movb %[value], %%al \n"
"movw %[portid], %%dx \n"
"out %%al,%%dx \n"
: // no output
:[value] "m" (value), [portid] "m" (portid)
: "al","dx"
);
}
3rd CODE:
original:
Code: Select all
void _cdecl i86_pit_irq () {
_asm add esp, 12
_asm pushad
//! increment tick count
_pit_ticks++;
//! tell hal we are done
interruptdone(0);
_asm popad
_asm iretd
}
Code: Select all
void i86_pit_irq(){
__asm__(
"addl $12,%esp \n"
"pusha \n"
);
_pit_ticks++;
interruptdone(0);
__asm__(
"popa \n"
"iret \n"
);
}
4nd CODE: (ATTENTION: my attempt doesn't compile- luckily this is not a required function)
original:
Code: Select all
char* i86_cpu_get_vender () {
static char vender[32] = {0};
#ifdef _MSC_VER
_asm {
mov eax, 0
cpuid
mov dword ptr [vender], ebx
mov dword ptr [vender+4], edx
mov dword ptr [vender+8], ecx
}
#endif
return vender;
}
Code: Select all
char* i86_cpu_get_vender(){
static char vendername[50] = {0};
__asm__(
"movl $0,%%eax \n"
"cpuid \n"
"movl %%ebx, %[vendername] \n"
"movl %%edx, %[vendername+$4] \n"
"movl %%ecx, %[vendername+$8] \n"
:"=r"(vendername) //user vendername as output
:[vendername]"m"(vendername) //use vendername as input
:"eax","ebx","edx","ecx" // clobbers those regs
);
return vendername;
}
Thank you very much for the support !