Printf help
Posted: Sat Sep 15, 2007 7:37 am
ok this is driving me insane... ok each time i call the printf to print to screen, it comes up as well lets say crap none of the symbols i wanted, my putch command works fine, here is my text mode header and link.ld
&
Code: Select all
#define WHITE_TXT 0x07 // white on black text
typedef unsigned char byte;
byte *VGA=(byte *)0xA0000000L;
void ccls(int color)
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=color;
i++;
};
};
void cls() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
void putch(char ch, int pos, int color)
{
char *vidmem = (char *) 0xb8000;
vidmem[pos]=ch;
vidmem[pos+1]=color;
};
void puts(int ch, int x, int y, int color)
{
unsigned int i=0;
char *vidmem = (char *) 0xb8000;
i=(80*2*x)+(y*2);
vidmem[i]=ch;
vidmem[i+1]=color;
};
void pset(int x, int y, int color)
{
VGA[y*320+x]=color;
};
void printf(int color, const char *string, int x, int y)
{
char *vidmem=(char *)0xB8000;
unsigned int i=(80*2*x)+(2*y);
while(*string!=0)
{
vidmem[i]=*string;
string++;
i++;
vidmem[i]=color;
i++;
};
};
&
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(16);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(16);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(16);
}
end = .;
}