I'm using Watcom C/C++ 11.0c and no value is returned. What am I doing wrong here?
unsigned char indata;
unsigned char in(unsigned short port) {
__asm {
mov dx, port
in al, dx
mov indata, al
}
return indata;
}
What am I doing wrong here? (C)
Re:What am I doing wrong here? (C)
maybe the port isn't returning anything(or 0) and I'm suprised you didn't have to put _indata in the asm
Re:What am I doing wrong here? (C)
I know something is going wrong here.
out(0x70, 0x14);
printf("Detecting floppy disks");
det = in(0x71);
That should return a value. Port 0x70 tells the CMOS to return the floppys. I found this document on osdever.net and I wrote the out and in code fine.
void out(unsigned short port, unsigned short portdata) {
__asm {
mov dx, port //unsigned short
mov ax, portdata //unsigned short
out dx, ax
}
}
Theres the out() code. This is driving me nuts!
out(0x70, 0x14);
printf("Detecting floppy disks");
det = in(0x71);
That should return a value. Port 0x70 tells the CMOS to return the floppys. I found this document on osdever.net and I wrote the out and in code fine.
void out(unsigned short port, unsigned short portdata) {
__asm {
mov dx, port //unsigned short
mov ax, portdata //unsigned short
out dx, ax
}
}
Theres the out() code. This is driving me nuts!
Re:What am I doing wrong here? (C)
I/O port 70h & 71h are byte wide ports. Correct this in out()function. Its better to name that outw() and make one for outb() and outd() if you want to wrap these calls in C.
Re:What am I doing wrong here? (C)
shouldnt you use a pragma aux with watcom?
(plus upgrade from 11.0c to openwatcom 1.4/1.5)
(off top of my head)
found this after searching
not sure about the trailing ';' after the modify's.
(plus upgrade from 11.0c to openwatcom 1.4/1.5)
(off top of my head)
Code: Select all
unsigned char in(unsigned short port);
#pragma aux in= \
"in al,dx" \
parm caller [dx] \
value [al] \
modify [eax edx];
Code: Select all
void koutpw(long i1, long i);
#pragma aux koutpw =\
"out dx, ax",\
parm [edx][eax]\
modify exact;
int kinp(long i);
#pragma aux kinp =\
"in al, dx",\
parm nomemory [edx]\
modify exact [eax];
-- Stu --