All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Plantz <plantz@sonoma.edu>
To: A D <a_d_249@hotmail.com>
Cc: "linux-assembly@vger.kernel.org" <linux-assembly@vger.kernel.org>
Subject: Re: Unable to use a variable in instruction
Date: Sun, 14 Oct 2007 19:01:57 -0700	[thread overview]
Message-ID: <1192413717.5651.4.camel@ubuntu> (raw)
In-Reply-To: <BAY133-W25307FEE9AA1A457394586F5A20@phx.gbl>


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



  parent reply	other threads:[~2007-10-15  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-14 23:37 Unable to use a variable in instruction A D
2007-10-15  1:45 ` Frank Kotler
2007-10-15  2:01 ` Robert Plantz [this message]
2007-10-15 13:31   ` A D

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1192413717.5651.4.camel@ubuntu \
    --to=plantz@sonoma.edu \
    --cc=a_d_249@hotmail.com \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.