On Wed, 2010-02-10 at 09:19 -0700, [email protected] wrote:
> Hello,
>
> I'm having some issues with the first actual example assembly program
> in the text, namely that when I run it through the assembler, this is
> what I'm getting:
>
> jwesleycoo...@linux-twom:~/asm> as exit.s -o exit.o
> exit.s: Assembler messages:
> exit.s:0: Warning: end of file in comment; newline inserted
> exit.s:25: Error: no such instruction: `mov1 $1,%eax'
> exit.s:29: Error: no such instruction: `mov1 $0,%ebx'
> jwesleycoo...@linux-twom:~/asm>
>
> I'm not quite sure why this is happening, so I've attached my source
> file to this message, which I created and attempted to assemble using
> kwrite on my 32-bit openSUSE installation. Please let me know why
> this is happening, so I can continue learning assembly with confidence
> in my materials.
>
> ~Wesley
[ looks like my original reply never made it to the list as I sent it
from the wrong mail alias :) ]
Hi Wesley,
Looks like a minor typo - those are "l"s (lowercase L) on the end of the
mov instruction not "1"s (numeral one) - it should read "movl". The
error you are getting is because "mov1" isn't recognised as a valid x86
assembler mnemonic.
The full name of the instruction is "move long".
Corrected version (assembles, links & runs here) attached:
$ as -o exit.o exit.s
$ ld -o exit exit.o
$ ./exit
$ echo $?
0
$ objdump -d ./a.out
./a.out: file format elf64-x86-64
Disassembly of section .text:
0000000000400078 <_start>:
400078: b8 01 00 00 00 mov $0x1,%eax
40007d: bb 00 00 00 00 mov $0x0,%ebx
400082: cd 80 int $0x80
Cheers,
Bryn.
#PURPOSE: Simple program that exits and returns a
# status code back to the Linux kernel
#
#INPUT: none
#
#OUTPUT: returns a status code. This can be viewed
# by typing
#
# echo $?
# after running the program
#
#VARIABLES:
# %eax holds the system call number
# %ebx holds the return status
#
.section .data
.section .text
.globl _start
_start:
movl $1, %eax # this is the linux kernel command
# number (system call) for exiting
# a program
movl $0, %ebx # this is the status number we will
# return to the operating system.
# Change this around and it will
# return different things to
# echo $?
int $0x80 # this wakes up the kernel to run
# the exit command
_______________________________________________
Pgubook-readers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/pgubook-readers