Unexpected result about screen print in pmode,help!
Posted: Thu May 01, 2003 7:59 pm
I want to print a string from the current cursor position in pmode,the following is the codes:
void delay()
{
???__asm__("movb $0,%%al;
?????? outb %%al,$0x80;"
?????? :::"%al");
}
unsigned int getcurpos()
{
???unsigned int uCurPos;
???unsigned char uHByte,uLByte;
???
???/*outb(0x3D4,0x0F);*/
???__asm__("movb $0x0F,%%al;
??? movw $0x3D4,%%dx;
?????? outb %%al,%%dx;"
?????? :::"%al","%dx");
???delay();
/*uLByte = inb(0x3D5);*/
???__asm__("movw $0x3D5,%%dx;
?????? inb %%dx,%0;"
?????? :"=r"(uLByte)
?????? ::"%dx");
???
???
???delay();
/*outb(0x3D4,0x0E);*/
???__asm__("movb $0x0E,%%al;
??? movw $0x3D4,%%dx
?????? outb %%al,%%dx;"
?????? :::"%al","%dx");
???delay();
/*uHByte = inb(0x3D5);*/
???__asm__("movw $0x3D5,%%dx;
?????? inb %%dx,%0;"
?????? :"=r"(uHByte)
?????? ::"%dx");
???
???uCurPos = uHByte;
???uCurPos = (uCurPos<<8)|uLByte;
???return uCurPos;
}
void printMsg(char *msg)
{
???unsigned int nCurPos;
???char *pVRAM = (char *)0xB8000;
???
???nCurPos = getcurpos();
???pVRAM = pVRAM + nCurPos;
???while(*msg!=0)
???{
?????? *pVRAM=*msg;
?????? msg++;
?????? pVRAM++;
?????? *pVRAM=0x07;
?????? pVRAM++;
???}???
}
any hint?
BTW:I want to write a function named outb() originally just like this:
void outb(unsigned int portaddr,unsigned char var)
{
???__asm__("movb %0,%%al;
movw %1,%%dx;
?????? outb %%al,%%dx";
?????? :
?????? :"r"(var),"r"(portaddr)
?????? :"%al","%dx");???
}
but compile it with gcc -c outb.c -o outb.o
will result in error: suffix or operands invalid for 'mov'
why?
void delay()
{
???__asm__("movb $0,%%al;
?????? outb %%al,$0x80;"
?????? :::"%al");
}
unsigned int getcurpos()
{
???unsigned int uCurPos;
???unsigned char uHByte,uLByte;
???
???/*outb(0x3D4,0x0F);*/
???__asm__("movb $0x0F,%%al;
??? movw $0x3D4,%%dx;
?????? outb %%al,%%dx;"
?????? :::"%al","%dx");
???delay();
/*uLByte = inb(0x3D5);*/
???__asm__("movw $0x3D5,%%dx;
?????? inb %%dx,%0;"
?????? :"=r"(uLByte)
?????? ::"%dx");
???
???
???delay();
/*outb(0x3D4,0x0E);*/
???__asm__("movb $0x0E,%%al;
??? movw $0x3D4,%%dx
?????? outb %%al,%%dx;"
?????? :::"%al","%dx");
???delay();
/*uHByte = inb(0x3D5);*/
???__asm__("movw $0x3D5,%%dx;
?????? inb %%dx,%0;"
?????? :"=r"(uHByte)
?????? ::"%dx");
???
???uCurPos = uHByte;
???uCurPos = (uCurPos<<8)|uLByte;
???return uCurPos;
}
void printMsg(char *msg)
{
???unsigned int nCurPos;
???char *pVRAM = (char *)0xB8000;
???
???nCurPos = getcurpos();
???pVRAM = pVRAM + nCurPos;
???while(*msg!=0)
???{
?????? *pVRAM=*msg;
?????? msg++;
?????? pVRAM++;
?????? *pVRAM=0x07;
?????? pVRAM++;
???}???
}
any hint?
BTW:I want to write a function named outb() originally just like this:
void outb(unsigned int portaddr,unsigned char var)
{
???__asm__("movb %0,%%al;
movw %1,%%dx;
?????? outb %%al,%%dx";
?????? :
?????? :"r"(var),"r"(portaddr)
?????? :"%al","%dx");???
}
but compile it with gcc -c outb.c -o outb.o
will result in error: suffix or operands invalid for 'mov'
why?