Page 1 of 1
C Print function doesn't work...
Posted: Mon Aug 06, 2007 5:44 pm
by matias_beretta
char *VIDEO = (char *) 0xb800;
void character(char A)
{
*VIDEO = A;
VIDEO++;
*VIDEO = 7;
VIDEO++;
}
void main()
{
character('A');
character('B');
asm mov ah, 0
asm int 22
}
This doesn´t work... do you know why?
Posted: Mon Aug 06, 2007 5:54 pm
by Alboin
*cough*0xb8000*cough*
thanx
Posted: Mon Aug 06, 2007 5:56 pm
by matias_beretta
char *VIDEO
void character(char A)
{
*VIDEO = A;
VIDEO++;
*VIDEO = 7;
VIDEO++;
}
void main()
{
VIDEO = (char *) 0xb8000; //CORRECTION
character('A');
character('B');
asm mov ah, 0
asm int 22
}
ok, this is the final code
BUT IT DOESN'T WORK...
Posted: Mon Aug 06, 2007 5:59 pm
by matias_beretta
char *VIDEO;
void character(char A)
{
*VIDEO = A;
VIDEO++;
*VIDEO = 7;
VIDEO++;
}
void main()
{
VIDEO = (char *) 0xb8000;
character('A');
character('B');
asm mov ah, 0
asm int 22
}
What's the problem?
Posted: Mon Aug 06, 2007 7:03 pm
by Brynet-Inc
Could you perhaps be a little more clear? what compiler are you using.. Is it failing to compile..
(
Those ASM statements are not valid in gcc for instance..)
info
Posted: Mon Aug 06, 2007 7:39 pm
by matias_beretta
I'm using Turbo C++ 3.0... with BootProg to load EXE files...
The compilation proccess finishes succesfully... but when I run it under DosBox, Bochs, or Virtual PC, I doesn't prints anithyng...
--------
I made a new post because I don't think anyone will answer a post with 3 replies...
I'm sorry, I didn't wanted to make spam...
Thanks
Posted: Mon Aug 06, 2007 7:48 pm
by 01000101
well, from what I can tell, your C code is fine (although I am uncertain of the asm).
Is it possible that your bootloader/exe handler could have offset your base memory addressing or something of that nature?
not to disuade you from your current bootloader, but try that code with another bootloader like grub or any other a20-enabled bootstrap to see if it is the C or the loader.
more info
Posted: Mon Aug 06, 2007 7:51 pm
by matias_beretta
1) I'm working in real mode, so grub will not work.
2) I had already done this before and it worked with the same bootloader and the same compiler...
Posted: Tue Aug 07, 2007 12:17 am
by pcmattman
Use a short for video memory instead, then do:
Code: Select all
VIDEO[offset] = ( 0x07 << 8 ) | A;
You should know how to calculate the offset.
Posted: Tue Aug 07, 2007 3:47 am
by os64dev
in real mode you can't use 0xB8000 that will translate to 0x8000 as the high word is chopped off. use unreal mode to get it working.