×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles
    Revision as of 16:51, 19 March 2005 by imported>mutante
    (diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

    This is an example of "Hello Fnord" in Assembler:

    vi hello.asm

    ---

    
    section .data                     ;section declaration
    msg db "Hello, fnord!"       ;der String
    section .text                     ;section declaration
    global _start                    ;default Eingangspunkt fuer ELF-Link
    
    _start:
    
    ;write() call
    
    mov eax, 4                    ;4 in eax, weil write syscall #4 ist
    mov ebx, 1                    ;stdout in ebx, weil die richtige fd 1 ist
    mov ecx, msg                ;die Adresse des Strings in ecx
    mov edx, 13                  ;13 in edx, weil der String 13 Bytes enthaelt
    int 0x80                        ;Kernelaufruf, um den System-Call auszuloesen
    
    ; exit() call
    
    mov eax,1                    ;1 in eax, weil exit syscall #1 ist
    mov ebx,0                    ;0 in ebx
    int 0x80                       ;Kernelaufruf, um den System-Call auszuloesen
    
    

    ---

    put this into hello.asm then compile it with nasm

    $ nasm -f elf hello.asm

    link it

    $ ld hello.o

    run it

    $ ./a.out

    Hello, fnord!

    tataaaa! you wrote your first assembler program.

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.