www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/03/23:24:06

From: hzheng AT uoguelph DOT ca (Hui Zheng)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline Asm?
Date: 4 Jan 1997 01:21:40 GMT
Organization: University of Guelph
Lines: 45
Message-ID: <5akbb4$ov6@ccshst05.cs.uoguelph.ca>
References: <19961231 DOT 204032 DOT 5015 DOT 0 DOT chambersb AT juno DOT com>
NNTP-Posting-Host: ccshst01.cs.uoguelph.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Benjamin D Chambers (chambersb AT juno DOT com) wrote:
: Well, I spent some time stepping through my program with GDB, and found
: that the following lines caused problems:

: cmpl	$0,	%%edx  (This is, of course, in the c file)
: jne	0

You can debug here. I guess it has already jumped but jumped 0. Change "0"
to whatever character or string and try again.

: Now, to me, this means that if edx is not zero, jump to the label 0
: (which was defined earlier) and, if edx is zero, keep executing as
: normal.  However, when I stepped through this with GDB, I found that no
: matter what value edx held, the loop fell through (that is, no jump was
: performed).  Am I doing something wrong here?  Again, thanx in advance...

: ..Chambers
: (PS: Here is the original program (a whole 20 lines)):
: #include <malloc.h>
: #include <stdio.h>

: unsigned char *data;
: int size;

: int main(void)
: {
:   size=20;
:   data=(unsigned char *)malloc(size);
:   size=16;
:   asm("0:                                       \n
:         movb    $1,             (,%%eax,1)      \n
:         incl    %%eax                           \n
:         decl    %%edx                           \n
:         cmpl    $0,             %%edx           \n
:         jne     0                               \n
:        "
:   :     // No Output
:   : "d" (size),
:     "a" (data)
:   : "memory", "%cc"
:   );
:   for (size=0;size<16;size++)
:    printf("At line %d: %d\n",size,data[size]);
:   return(0);
: }

- Raw text -


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