Gelonida
27-06-2005, 21:00
Hallo,
ich verwende nasm unter Fedora Linux Core 4. Assemblieren und linken gehen ohne Fehler, aber beim Ausführen kommt immer "Speicherzugriffsfehler". Das Problem tritt z.B. bei diesem Programm auf, aber auch bei allen anderen, die ich im Netz gefunden habe.
SECTION .DATA
hello: db 'Hello world!',10
helloLen: equ $-hello
SECTION .TEXT
GLOBAL _start
_start:
; Write 'Hello world!' to the screen
mov eax,4 ; 'write' system call
mov ebx,1 ; file descriptor 1 = screen
mov ecx,hello ; string to write
mov edx,helloLen ; length of string to write
int 80h ; call the kernel
; Terminate program
mov eax,1 ; 'exit' system call
mov ebx,0 ; exit with error code 0
int 80h ; call the kernel
Folgende Kommandozeilenausgabe:
chriss@Zacharias Info4_Uebung_Gruppe06]$ nasm -f elf program.asm
[chriss@Zacharias Info4_Uebung_Gruppe06]$ ld -s -o program program.o
[chriss@Zacharias Info4_Uebung_Gruppe06]$ ./program
Speicherzugriffsfehler
[chriss@Zacharias Info4_Uebung_Gruppe06]$
Ich hoffe, jemand kann mir sagen, was ich grundlegendes falsch mache.
Danke und Grüße,
Gelonida
ich verwende nasm unter Fedora Linux Core 4. Assemblieren und linken gehen ohne Fehler, aber beim Ausführen kommt immer "Speicherzugriffsfehler". Das Problem tritt z.B. bei diesem Programm auf, aber auch bei allen anderen, die ich im Netz gefunden habe.
SECTION .DATA
hello: db 'Hello world!',10
helloLen: equ $-hello
SECTION .TEXT
GLOBAL _start
_start:
; Write 'Hello world!' to the screen
mov eax,4 ; 'write' system call
mov ebx,1 ; file descriptor 1 = screen
mov ecx,hello ; string to write
mov edx,helloLen ; length of string to write
int 80h ; call the kernel
; Terminate program
mov eax,1 ; 'exit' system call
mov ebx,0 ; exit with error code 0
int 80h ; call the kernel
Folgende Kommandozeilenausgabe:
chriss@Zacharias Info4_Uebung_Gruppe06]$ nasm -f elf program.asm
[chriss@Zacharias Info4_Uebung_Gruppe06]$ ld -s -o program program.o
[chriss@Zacharias Info4_Uebung_Gruppe06]$ ./program
Speicherzugriffsfehler
[chriss@Zacharias Info4_Uebung_Gruppe06]$
Ich hoffe, jemand kann mir sagen, was ich grundlegendes falsch mache.
Danke und Grüße,
Gelonida