Strange problem - no call to function?

Programming, for all ages and all languages.
Post Reply
itportal
Posts: 18
Joined: Tue May 18, 2010 1:34 am

Strange problem - no call to function?

Post by itportal »

Hello everyone,

I am trying to compile a simple function, that calls the BIOS to make some output on the screen. The code runs in real mode and the function looks like this:

Code: Select all

void mprint(const char* text)  {	
	while(*text){
		asm volatile("int 0x10" :  : "a" (  (0x0E << 8) | *text ) : "ebx", "ecx", "edx" );
		text++;
	}
}
The code is compiled with following options:
-m32 -march=i386 -O0 -Wall -include 16bit.h -masm=intel -nostdlib -c

where 16bit.h adds the .code16gcc section.

When I make a call to this function in my main, no call is actually produced in the assembled machine code (which of course results in no text output). However, when I remove the -march=i386 option, the calls are correctly produced. This is somehow strange, because I have several other functions as well and the calls to them compile correctly in both cases.

Any ideas what I am missing?

PS. The function itself is compiled and assembled correctly, but no call to it at all.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Strange problem - no call to function?

Post by Chandra »

Try giving function prototype like this:

static char character; /* I have just used name character you can use any other name*/

void print(const char message[30]); /*this is just an example not your real code*/

void main()
{
char message[30]={"Function test successfull"};
print(message);
for(;;);
}

void print(const char message[30])
{
int char_number=0;
for(char_number=0;char_number<30;char_number++)
{
character=message[char_number];
if(character==0) break;
asm("mov al,[_character]\n\
mov bl,0\n\
so on.....to set text attributes and color. Then call the int 10;
int 0x10\n");
}
}

I had encountered similar type of problem but I had finally found this solution. Try it, that should work. And of course you must use masm=intel switcha as well as -ffreestanding to compile this correctly.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: Strange problem - no call to function?

Post by Firestryke31 »

Use

Code: Select all

 tags and people will be less likely to simply skip over this post.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Post Reply