PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : NASM: nur Speicherzugriffsfehler



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

`kk
27-06-2005, 21:23
Hallo.
Also ich weiß jetzt nicht, ob es dir wirklich was bringt aber bei mir funktioniert das Programm auch nicht.
Nur, damit man vielleicht nen kapputen RAM ausschließen kann...

Gruß
Kai

Gelonida
27-06-2005, 21:40
Hallo,

danke fürs probieren.

Der Knackpuntk ist, dass gar kein Programm (aus diversen Tutorials) geht. Das oben war nur ein Beispiel zur Verdeutlichung. Deshalb vermute ich, dass ich etwas grundlegendes falsche ... nur was?

Gruß,
Gelonida

Gelonida
30-06-2005, 21:06
aus man nasm: "Note that the actual assembly is still case sensitive"
so läuft's:

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
Gruß,
Gelonida