www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/29/13:52:34

Date: Mon, 29 Dec 1997 10:51:59 -0800 (PST)
Message-Id: <199712291851.KAA11512@adit.ap.net>
Mime-Version: 1.0
To: Gertjan Klein <gklein AT xs4all DOT nl>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: error idiv :divide by zero

At 01:19  12/27/1997 +0100, Gertjan Klein wrote:
>In article <34A430E1 DOT 2495 AT bluewin DOT ch>, leger_v AT bluewin DOT ch wrote:
>
> > static unsigned char quotient;
> > static unsigned char remainder;
> > main()
> > { asm("pusha
> >        movb $8,%al       ;2 samples numbers
> >        movb $3,%cl       ;
> >        idiv %cl
> >        mov %al, _quotient
> >        mov %ah, _remainder
> >        popa");
> >   printf("8 : 3 = %d and remainder : %d" quotient, remainder);
> >}
> > this program works fine.
>
>  No it doesn't; it doesn't even compile.  There is a comma missing
>after the printf format specifier, and the assembler chokes on the colon
>comments (use /* C comments */ instead).  Always cut-and-paste from the
>actual code you tried, to prevent people on the list from chasing typing
>errors instead of finding the real problem.
Minor correction: You can use C comments only when they are outside the asm
string. The preprocessor, which strips comments, ignores things in strings.
If you want the comment inside the quotes, use assembler-style comments,
which begin with a `#' character and go till the end of the line.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019