Programming, for all ages and all languages.
hojjatrakhshani
Posts: 21 Joined: Sun Feb 19, 2012 7:25 am
Post
by hojjatrakhshani » Mon Jul 30, 2012 4:04 am
hi guys
!
problem is print charachter on screen
with loop it isnt work?
without loop its work?
for-loop:
Code: Select all
void __cdecl write_string(char colour, const char *string )
{
volatile char *video = (volatile char*)0xB8000;
for(int x=0;x<17;x++)
{
*video++ = *string++;
*video++ = colour;
}
}
no for-loop
Code: Select all
void __cdecl write_string(char colour, const char *string )
{
volatile char *video = (volatile char*)0xB8000;
*video++ = *string++;
*video++ = colour;
*video++ = *string++;
*video++ = colour;
etc......
}
Attachments
without loop
with loop
gerryg400
Member
Posts: 1801 Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia
Post
by gerryg400 » Mon Jul 30, 2012 4:46 am
Neither of them has printed 17 characters. So I would say that both are wrong.
If a trainstation is where trains stop, what is a workstation ?
gerryg400
Member
Posts: 1801 Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia
Post
by gerryg400 » Mon Jul 30, 2012 6:38 am
I'm sorry but I don't understand your post.
If a trainstation is where trains stop, what is a workstation ?
Gigasoft
Member
Posts: 855 Joined: Sat Nov 21, 2009 5:11 pm
Post
by Gigasoft » Mon Jul 30, 2012 7:19 am
Check that ESP points to RAM.
Nable
Member
Posts: 453 Joined: Tue Nov 08, 2011 11:35 am
Post
by Nable » Mon Jul 30, 2012 7:25 am
What about looking at disassembly?
bluemoon
Member
Posts: 1761 Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong
Post
by bluemoon » Mon Jul 30, 2012 9:46 am
As Gigasoft mentioned, it sound like a stack issue.
I do not see any startup code in kmain except setting ds/es/fs/gs, so are the proper environment setup on the boot loader? C code depends on some conditions - you should know that.
hojjatrakhshani
Posts: 21 Joined: Sun Feb 19, 2012 7:25 am
Post
by hojjatrakhshani » Mon Jul 30, 2012 11:17 am
i set it but...
Code: Select all
_asm {
cli
mov ax,0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp,0x90000
}
AndrewBuckley
Member
Posts: 95 Joined: Thu Jan 29, 2009 9:13 am
Post
by AndrewBuckley » Mon Jul 30, 2012 1:52 pm
You will want to set up stack before you enter your C code, using a _asm block inside of C to do that will just be a headache, if possible at all.
Tosi
Member
Posts: 255 Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:
Post
by Tosi » Mon Jul 30, 2012 10:21 pm
Did you read the
Required Knowledge and getting started articles on the wiki?
You seem to have no idea what you are doing.
hojjatrakhshani
Posts: 21 Joined: Sun Feb 19, 2012 7:25 am
Post
by hojjatrakhshani » Mon Jul 30, 2012 10:51 pm
thank!i am set them either from my boot loader when it is go to protected mode.
but you can set them in your c code entry point,there is problem?
sorry i am not set base address?