print string problem and screen mode switching
Posted: Fri Jan 25, 2002 8:16 pm
Okay, I've got two questions:
1. I'm using NASM, DJGPP, LD, and John Fine's bootf02.zip bootsector and I can't get my C code to print a string on the screen. Below I have listed my C and ASM code along with the commands I use to compile and link them together.
// start of test.c
go()
{
char mystring[] = "Hi OS";
char *vidmem = (char *) 0xb8000;
// displays 'This works' onscreen
vidmem[0]='T';
vidmem[1]=0x7;
vidmem[2]='h';
vidmem[3]=0x7;
vidmem[4]='i';
vidmem[5]=0x7;
vidmem[6]='s';
vidmem[7]=0x7;
vidmem[8]=' ';
vidmem[9]=0x7;
vidmem[10]='w';
vidmem[11]=0x7;
vidmem[12]='o';
vidmem[13]=0x7;
vidmem[14]='r';
vidmem[15]=0x7;
vidmem[16]='k';
vidmem[17]=0x7;
vidmem[18]='s';
vidmem[19]=0x7;
// supposed to show 'Hi OS' but instead
// shows '@@@@@'
vidmem[20]=mystring[0];
vidmem[21]=0x7;
vidmem[22]=mystring[1];
vidmem[23]=0x7;
vidmem[24]=mystring[2];
vidmem[25]=0x7;
vidmem[26]=mystring[3];
vidmem[27]=0x7;
vidmem[28]=mystring[4];
vidmem[29]=0x7;
};
// end of test.c
; start of test.asm
[BITS 32]
[extern _go] ; this is in test.c
start:
call _go ; call go from test.c
jmp $
; end of test.asm
The commands I use to compile and link my code are:
gcc -c test.c -o test.o
nasmw -f coff test.asm -o test1.o
ld --oformat binary -e 0xFF800000 test1.o test.o
2. My second question is how do I switch screen modes will in PMode? I know that in real mode I can use interrupt 10h, but it's a bios function so it doesn't work in PMode(at least I can't get it to), only real mode.
Thanks in advace,
K.J.
1. I'm using NASM, DJGPP, LD, and John Fine's bootf02.zip bootsector and I can't get my C code to print a string on the screen. Below I have listed my C and ASM code along with the commands I use to compile and link them together.
// start of test.c
go()
{
char mystring[] = "Hi OS";
char *vidmem = (char *) 0xb8000;
// displays 'This works' onscreen
vidmem[0]='T';
vidmem[1]=0x7;
vidmem[2]='h';
vidmem[3]=0x7;
vidmem[4]='i';
vidmem[5]=0x7;
vidmem[6]='s';
vidmem[7]=0x7;
vidmem[8]=' ';
vidmem[9]=0x7;
vidmem[10]='w';
vidmem[11]=0x7;
vidmem[12]='o';
vidmem[13]=0x7;
vidmem[14]='r';
vidmem[15]=0x7;
vidmem[16]='k';
vidmem[17]=0x7;
vidmem[18]='s';
vidmem[19]=0x7;
// supposed to show 'Hi OS' but instead
// shows '@@@@@'
vidmem[20]=mystring[0];
vidmem[21]=0x7;
vidmem[22]=mystring[1];
vidmem[23]=0x7;
vidmem[24]=mystring[2];
vidmem[25]=0x7;
vidmem[26]=mystring[3];
vidmem[27]=0x7;
vidmem[28]=mystring[4];
vidmem[29]=0x7;
};
// end of test.c
; start of test.asm
[BITS 32]
[extern _go] ; this is in test.c
start:
call _go ; call go from test.c
jmp $
; end of test.asm
The commands I use to compile and link my code are:
gcc -c test.c -o test.o
nasmw -f coff test.asm -o test1.o
ld --oformat binary -e 0xFF800000 test1.o test.o
2. My second question is how do I switch screen modes will in PMode? I know that in real mode I can use interrupt 10h, but it's a bios function so it doesn't work in PMode(at least I can't get it to), only real mode.
Thanks in advace,
K.J.