Assembly language is a Programming Language and intermediate instructions usually gotten from a compiled higher level language (such as C Language) and before it is itself translated to binary machine code to run on a microprocessor.

Example of “Hello World” in X86 assembly for Linux

section .text ;section declaration

                                ;we must export the entry point to the ELF linker or
    global  _start              ;loader. They conventionally recognize _start as their
                                      ;entry point. Use ld -e foo to override the default.

_start:

                                ;write our string to stdout

    mov     edx,len             ;third argument: message length
    mov     ecx,msg             ;second argument: pointer to message to write
    mov     ebx,1               ;first argument: file handle (stdout)
    mov     eax,4               ;system call number (sys_write)
    int     0x80                ;call kernel

                                ;and exit

    mov     ebx,0               ;first syscall argument: exit code
    mov     eax,1               ;system call number (sys_exit)
    int     0x80                ;call kernel

section .data                   ;section declaration

msg db      "Hello, world!",0xa ;our dear string
len equ     $ - msg             ;length of our dear string

Example code is from TLDP

Myths about Assembly:

  • It’s always faster - not necessarily, compilers are very smart about optimisations.
  • There’s 1 instruction executed per clock cycle - not in today’s hardware as Microprocessors are super scalar and can execute more than 1 per clock cycle. Processors will have more than one Arithmetic Logic Unit (ALU) so 2 increment instructions (add 1 to 2 different integers for ex.) could be done in the same clock cycle.
  • Assembly instructions are atomic -

See also: