From: "Kenton Brede" <kbrede@gmail.com>
To: linux-assembly@vger.kernel.org
Subject: suffix or operands invalid for
Date: Thu, 21 Dec 2006 20:39:51 -0600 [thread overview]
Message-ID: <d5418ffc0612211839n531644f2x11f8afc4f293f1dd@mail.gmail.com> (raw)
I've done some scripting but don't consider myself a programmer. I
ran across "Programming from the Ground Up" and thought it would be an
interesting project. At any rate I'm having problems compiling a
program I've copied out of the book. I'm hoping someone can help me
out. Thanks for any help.
Kent
Here are the errors when I run "as power.s -o power.o":
power.s: Assembler messages:
power.s:14: Error: suffix or operands invalid for `push'
power.s:15: Error: suffix or operands invalid for `push'
power.s:19: Error: suffix or operands invalid for `push'
power.s:22: Error: suffix or operands invalid for `push'
power.s:23: Error: suffix or operands invalid for `push'
power.s:27: Error: suffix or operands invalid for `pop'
power.s:61: Error: suffix or operands invalid for `push'
power.s:85: Error: suffix or operands invalid for `pop'
The code:
------------------------------------------------------------------------------------------------------------
.section .data
.section .text
.globl _start
_start:
pushl $3 #push second argument
pushl $2 #push first argument
call power #call the function
addl $8, %esp #move the stack pointer back
pushl %eax #save the first answer before
#calling the next function
pushl $2 #push second argument
pushl $5 #push first argument
call power #call the function
addl $8, %esp #move the stack pointer back
popl %ebx #The second answer is already
#in %eax. We saved the
#first answer onto the stack,
#so now we can just pop it
#out into %ebx
addl %eax, %ebx #add them together
#the result is in %ebx
movl $1, %eax #exit (%ebx is returned)
int $0x80
.type power, @function
power:
pushl %ebp #save old base pointer
movl %esp, %ebp #make stack pointer the base pointer
subl $4, %esp #get room for our local storage
movl 8(%ebp), %ebx #put first argument in %eax
movl 12(%ebp), %ecx #put second argument in %ecx
movl %ebx, -4(%ebp) #store current result
power_loop_start:
cmpl $1, %ecx #if the power is 1, we are done
je end_power
movl -4(%ebp), %eax #move the current result into %eax
imull %ebx, %eax #multiply the current result by
#the base number
movl %eax, -4(%ebp) #store the current result
decl %ecx #decrease the power
jmp power_loop_start #run for the next power
end_power:
movl -4(%ebp), %eax #return value goes in %eax
movl %ebp, %esp #restore the stack pointer
popl %ebp #restore the base pointer
ret
----------------------------------------------------------------------------------------------------------------------------
next reply other threads:[~2006-12-22 2:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-22 2:39 Kenton Brede [this message]
2006-12-22 12:51 ` suffix or operands invalid for Frank Kotler
2006-12-22 14:18 ` Kenton Brede
2006-12-22 16:16 ` Robert Plantz
2006-12-22 16:55 ` Robert Plantz
2006-12-22 19:05 ` Kenton Brede
2006-12-22 19:15 ` Robert Plantz
2006-12-31 18:06 ` Hendrik Visage
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=d5418ffc0612211839n531644f2x11f8afc4f293f1dd@mail.gmail.com \
--to=kbrede@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).