Page 1 of 1

asm & c compile problem

Posted: Wed Jun 06, 2012 10:00 am
by hatling
this is my code
is there anyone help me analyze this problem,thanks

Re: asm & c compile problem

Posted: Wed Jun 06, 2012 10:08 am
by Combuster
Don't use a 32 or 64-bit compiler if you expect 16-bit code.

Re: asm & c compile problem

Posted: Wed Jun 06, 2012 12:29 pm
by Love4Boobies
Actually, it should be fine with GCC, if DS = ES and the code fits one segment. Isn't that what they do with GRUB?

Re: asm & c compile problem

Posted: Wed Jun 06, 2012 2:34 pm
by Combuster
Love4Boobies wrote:Actually, it should be fine with GCC, if DS = ES and the code fits one segment. Isn't that what they do with GRUB?
Not without doing the hack that makes it emit 16-bit code.

The OP is executing 32-bit opcodes in 16-bit mode and wonders why the compiler is "broken". The problem gets ever more interesting when you end up using a mingw32 (educated guess) compiler to make a DOS .COM binary in a "bootloader" folder. Add to that that the OP can't even formulate a proper question chances are likely he doesn't even understand what he's doing - in which case guessing the right fix is rather dangerous.

Re: asm & c compile problem

Posted: Wed Jun 06, 2012 7:11 pm
by hatling
Combuster wrote:
Love4Boobies wrote:Actually, it should be fine with GCC, if DS = ES and the code fits one segment. Isn't that what they do with GRUB?
Not without doing the hack that makes it emit 16-bit code.

The OP is executing 32-bit opcodes in 16-bit mode and wonders why the compiler is "broken". The problem gets ever more interesting when you end up using a mingw32 (educated guess) compiler to make a DOS .COM binary in a "bootloader" folder. Add to that that the OP can't even formulate a proper question chances are likely he doesn't even understand what he's doing - in which case guessing the right fix is rather dangerous.
thanks
when i add

Code: Select all

asm(".code16gcc\n\t");
at the head of the file main.c,it is the same result

Re: asm & c compile problem

Posted: Thu Jun 07, 2012 5:29 am
by Combuster
Combuster wrote:Add to that that the OP can't even formulate a proper question chances are likely he doesn't even understand what he's doing
hatling wrote:...
berkus wrote: #-o #-o
I agree with half of that, Berkus.

Re: asm & c compile problem

Posted: Thu Jun 07, 2012 11:03 am
by Combuster
Well, you just wasted both your hands on one stupidity. There might be more to come. :wink: That is, unless the OP finally gets the hint and stops posting symptoms of an unmentioned problem.

Re: asm & c compile problem

Posted: Thu Jun 07, 2012 11:17 am
by Griwes
Both hands? Those were two one-handed facepalms :lol:

Re: asm & c compile problem

Posted: Wed Jun 13, 2012 1:40 pm
by qw
And two heads obviously.