asm & c compile problem

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
hatling
Posts: 2
Joined: Wed Jun 06, 2012 9:31 am

asm & c compile problem

Post by hatling »

this is my code
is there anyone help me analyze this problem,thanks
Last edited by hatling on Thu Jun 07, 2012 5:52 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: asm & c compile problem

Post by Combuster »

Don't use a 32 or 64-bit compiler if you expect 16-bit code.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: asm & c compile problem

Post 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?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: asm & c compile problem

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
hatling
Posts: 2
Joined: Wed Jun 06, 2012 9:31 am

Re: asm & c compile problem

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: asm & c compile problem

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: asm & c compile problem

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: asm & c compile problem

Post by Griwes »

Both hands? Those were two one-handed facepalms :lol:
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: asm & c compile problem

Post by qw »

And two heads obviously.
Post Reply