C Print function doesn't work...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

C Print function doesn't work...

Post 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?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

*cough*0xb8000*cough*
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

thanx

Post 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
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

BUT IT DOESN'T WORK...

Post 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?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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..) :wink:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

info

Post 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
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post 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.
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

more info

Post 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...
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
Post Reply