From: Matthias-Christian O. <mat...@ti...> - 2005-03-15 18:43:30
|
Hi! I've 2 Problems with nasm: 1: *Strage Linking Problem* I have this code: SECTION .DATA hello: db 'Hello world!',10 helloLen: equ $-hello SECTION .TEXT GLOBAL main main: ; 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 If try to assemble, link (by using ld) and run it, I only get a segementation fault (I have to rename main to _start): nasm -f elf hello.asm ld -s -o hello hello.o ./hello segementation fault If I try to link it with the gcc (_start -> main), everything works fine. What's wrong? Why doesn't it work? 2: *Strange Syntax Error* I have this code (I know that it will only work in the priviledged mode, but it should assemble cleanly (?)): global sys_core_in sys_core_in: push ebp push dx mov ebp,esp in edx,[ebp+4] mov eax,dx pop dx pop ebp ret global sys_core_out sys_core_out: push ebp mov ebp,esp out [ebp+4],[ebp+8] pop ebp ret If I try to assemble it I get this: io.s:7: error: invalid combination of opcode and operands io.s:8: error: invalid combination of opcode and operands io.s:18: error: invalid combination of opcode and operands What's wrong with the syntax? Thanks Matthias-Chritian Ott |