Author Topic: Nasm and Linux  (Read 8611 times)

nobody

  • Guest
Nasm and Linux
« on: August 14, 2007, 09:00:48 PM »
Hi all,

Just a question. In Linux, the platform dependant code (files .S) are written in assembler, as you know. The sintax used in these files is similiar to the one used in NAMS ? I read that Linux use the AT & T sintax, the UNIX standard.
Is is correct ?

Thanks a lot
Dario

nobody

  • Guest
Re: Nasm and Linux
« Reply #1 on: August 14, 2007, 09:11:58 PM »
> The sintax used in these files is

"sintax" -> "syntax"

> similiar to the one used in NAMS

"NAMS" -> "NASM"

> read that Linux use the AT & T sintax, the UNIX standard.

Seems to :-( And NO, NASM doesn't use the "AT&T" syntax ...

nobody

  • Guest
Re: Nasm and Linux
« Reply #2 on: August 15, 2007, 05:22:50 AM »
Nasm's syntax and AT&T syntax differ quite a bit. Nasm syntax:

global _start
section .text
_start
mov eax,4
mov ebx,1
mov ecx, msg
mov edx,msg_len
int 80h
mov eax,1
int 80h

section .data
msg db 'Hello, world',0Ah
msg_len equ $-msg


(G)as syntax (AT&T):

.global _start

.text
_start:
    movl $4, %eax
    movl $1, %ebx
    movl $msg, %ecx
    movl $msg_len, %edx
    int  $0x80

movl %eax, %ebx
    movl $1, %eax
    int  $0x80

.data
    msg: .ascii "Hello World!\n"
    msg_len = . - msg

As you can see, they look quite different, but recognizably do the same thing.

Best,
Frank

nobody

  • Guest
Re: Nasm and Linux
« Reply #3 on: August 15, 2007, 11:23:36 AM »
Thanks a lot Frank for your example and sorry for my mistakes during writing. I wanted to put the message two seconds before leaving home.
Bye
Dario