ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/08/12:00:16

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Declaring variables in GAS
Date: 8 Apr 2002 10:48:41 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 39
Message-ID: <a8rsi9$lt$1@nets3.rz.RWTH-Aachen.DE>
References: <a8okc7$n057 AT imsp212 DOT netvigator DOT com> <a8p52l$qj71648 AT imsp212 DOT netvigator DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1018262921 701 137.226.32.75 (8 Apr 2002 10:48:41 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 8 Apr 2002 10:48:41 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Jacky Luk <luckie AT netvigator DOT com> wrote:
> This is the first time I get it->

You got it wrong.  You were asking about a *global* variable and how
to declare it in asm.  But your C example only has a variable local to
function main.

Try this instead:

#include <stdio.h>

int foo1 = 100;

int main()
{

 printf ("%d\n", foo1);
 return 0;


}

And the important fragments of the assembly output you'll get are:

.globl foo1
.data
foo1:
        .align 4
        .long 100

And to get it into a register:

        movl foo1,%eax



-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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