'Differences between Assembly Languages

I'm very new to Assembly Language and I know there are many, many types of assembly languages. Such as ARM, MIPS, x86 etc. So I have questions.

Below is more Information

Hello World in ARM

.text            
.global _start
_start:
    mov r0, #1
    ldr r1, =message
    ldr r2, =len
    mov r7, #4
    swi 0

    mov r7, #1
    swi 0

.data
message:
    .asciz "hello world\n"
len = .-message 

Hello World in NASM

section .data                        ; section to define memory
    msg db  "Hello, World!", 10      ; define string to the name 'msg', 10 is '\n' character
    len equ $ - msg                  ; assign the length of the string to the name 'len'
        
section .text                        ; section to put code
    global _start                    ; a global label to be declared for the linker (ld)
        
_start:
    mov rax, 1                       ; syscall ID number (sys_write)
    mov rdi, 1                       ; file descriptor (stdout)
    mov rsi, msg                     ; address of string to write
    mov rdx, len                     ; length of string
    syscall                          ; call kernel
        
    mov rax, 60                      ; syscall ID number (sys_exit)
    mov rdi, 0                       ; error code 0
    syscall                          ; call kernel

Hello World in GAS Syntax

.data
hello:
    .string "Hello world!\n"

.text
.globl _start
_start:
    movl $4, %eax # write(1, hello, strlen(hello))
    movl $1, %ebx
    movl $hello, %ecx
    movl $13, %edx
    int  $0x80

    movl $1, %eax # exit(0)
    movl $0, %ebx
    int  $0x80

Hello World in MIPS Assembly

        .data
msg:   .asciiz "Hello World"
    .extern foobar 4

        .text
        .globl main
main:   li $v0, 4       # syscall 4 (print_str)
        la $a0, msg     # argument: string
        syscall         # print the string
        lw $t1, foobar
        
        jr $ra          # retrun to caller

I searched the internet for a lot of information on these.

So I found this information:

  • Gas and Intel Assembly are same. But syntax is different
  • Syntax is only different for copyright reasons
  • ARM's have their own Syntax type

And I have questions to ask from you:

  1. Although the assembly languages has changed, isn't the code writing order different?
  2. The only difference between assembly languages is the syntax they used?

More information

GAS : At&T Syntax

movq    $2, %r8                 # %r8 = 2
movq    $3, %r9                 # %r9 = 3
movq    $5, %r10                # %r10 = 5
imulq   %r9, %r10               # %r10 = 3 * 5 = 15
addq    %r8, %r10               # %r10 = 2 + 15 = 17

NASM : INTEL Syntex

mov r8, 2               ; r8 = 2
mov r9, 3               ; r9 = 3
mov r10, 5              ; r10 = 5
mul r9, r10             ; r10 = 3 * 5 = 15
add r8, r10             ; r10 = 2 + ( 15 ) = 17


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source