Thread: Why this code crash ?

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    5

    Why this code crash ?

    Hello

    i get this code from RYMOS : http://sourceforge.net/projects/rymos

    Code:
    unsigned int k_printf(char *message, unsigned int line)
    {
    	char *vidmem = (char *) 0xb8000;
    	unsigned int i=0;
    
    	i=(line*80*2);
    
    	while(*message!=0) // 24h
    	{
    		if(*message==0x2F)
    		{
    			*message++;
    			if(*message==0x6e)
    			{
    				line++;
    				i=(line*80*2);
    				*message++;
    				if(*message==0)
    				{
    					return(1);
    				};
    			};
    		};
    		vidmem[i]=*message;
    		*message++;
    		i++;
    		vidmem[i]=0x7;
    		i++;
    	};
    
    	return(1);
    };
    i try to compile it with Dev-C++ , no any errors but when i run programme it's crash and show report problem (Windows XP)

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    How do you knwo the problem is here? Are you sure it's not somewhere else? What line is the error on? Are you sure that this isn't just where the problem shows itself? Can you provide any helpful information at all?

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    5
    Hello ..

    this is errors which show for me when i try run this code

    Code:
    unsigned int k_printf(char *message, unsigned int line)
    {
    	char *vidmem = (char *) 0xb8000;
    	unsigned int i=0;
    
    	i=(line*80*2);
    
    	while(*message!=0) // 24h
    	{
    		if(*message==0x2F)
    		{
    			*message++;
    			if(*message==0x6e)
    			{
    				line++;
    				i=(line*80*2);
    				*message++;
    				if(*message==0)
    				{
    					return(1);
    				};
    			};
    		};
    		vidmem[i]=*message;
    		*message++;
    		i++;
    		vidmem[i]=0x7;
    		i++;
    	};
    
    	return(1);
    };
    
    int main() {
        k_printf("Test",0);
    }

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    My guess is your attempt to assign a pointer to some spot in memory in hopes it's actually video memory, and then tweek it, under Windows XP:
    Code:
    char *vidmem = (char *) 0xb8000;

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,435
    Or you could just stop trying to use the low-level code from one operating system as high level code on another operating system.

    Or explain why you want to do this, and why the regular printf() isn't adequate for your needs.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM