All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephan Sauerburger <stephan@sauerburger.org>
To: Linux Assembly List <linux-assembly@vger.kernel.org>
Subject: math on variables
Date: Sun, 15 Dec 2002 07:29:06 -0500	[thread overview]
Message-ID: <20021215122906.GB8507@sauerburger.org> (raw)

Hi, I'm a newbie and trying to perform basic math on variables in memory (not the stack).
I tried this but it gives lots of "error: invalid combination of opcode and
operands" and "error: operation size not specified" messages:

section .bss
     [...]
     totalcoins  	resd	1
     totalvalue		resd	1

section .text

extern scanf
global main
main:
     mov	[totalcoins],0	;This gives an error. I just want to
     				;initialize them to 0 at beginning.
     mov	totalvalue,dword 0	    ;This doesn't work either,
     				;when I give its address with "name"
				;in lieu of "[name]" or specify dword.

     ;;read in nickels
     push   dword	nickels
     push   dword  dformat
     call   scanf
     add     esp,8
     ;;add it to "totalcoins"
     add    [totalcoins],[nickels]	;error: invalid combination of
     	    				;opcode and operands. Tried
					;"add totalcoins,dword [nickels]" too.
     ;add value in centes to "totalvalue"
     ;(nickels are worth 5 cents, so multiply by 5 first.)
     mov    eax,[nickels]
     mul    eax,5	 		;error: invalid combination of
     mov  [nickels],eax			;opcode and operands.


I'm using nasm 0.98.28, on Debian Linux, on a Pentium III 450 mhz, 256 MB of
ram. I find it odd, but I have found no information on such operations on
variables anywhere on the web or my books. Perhaps I'm just dense.
How can one accomplish these things? Thx.

-- 
-Stephan
For PGP Public Key, visit:
http://www.sauerburger.org

             reply	other threads:[~2002-12-15 12:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-15 12:29 Stephan Sauerburger [this message]
2002-12-15 21:20 ` math on variables Pea Jay

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=20021215122906.GB8507@sauerburger.org \
    --to=stephan@sauerburger.org \
    --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.