From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Plantz Subject: Re: Unable to use a variable in instruction Date: Sun, 14 Oct 2007 19:01:57 -0700 Message-ID: <1192413717.5651.4.camel@ubuntu> References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-assembly-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii" To: A D Cc: "linux-assembly@vger.kernel.org" On Sun, 2007-10-14 at 19:37 -0400, A D wrote: > I'm having strange problem accessing a variable in a gnu assembly language program. > When i write a code: > > .section .data > x = 4 This is equivalent to writing .equ x,4 > mm: > .int 1, 2 > > .section .text > .globl _start > _start: > nop So this instruction: > movl x, %ecx #can't do this is trying to move the 4 bytes stored at memory location 4 into the ecx register. As the OS told you, you cannot do that. The way to allocate an initialized 32-bit int in the .data section is: x: .long 4