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



    s23
    3,185Articles

    Difference between revisions of "HelloAssembler"

    imported>mutante
    m
    imported>mutante
    m
     
    Line 1: Line 1:
    This is an example of "Hello Fnord" in Assembler:
    +
    This is an example of "Hello Fnord" in [[Assembler]]:
       
     
    vi hello.asm
     
    vi hello.asm
    Line 30: Line 30:
     
    ---
     
    ---
       
    put this into hello.asm then compile it with [[nasm]]
    +
    put this into hello.asm then [[compiler|compile]] it with [[nasm]]
       
     
    $ nasm -f elf hello.asm
     
    $ nasm -f elf hello.asm
    Line 42: Line 42:
     
    $ ./a.out
     
    $ ./a.out
       
    Hello, fnord!
    +
    Hello, [[fnord]]!
       
    tataaaa! you wrote your first assembler program.
    +
    tataaaa! you wrote your first [[assembler]] [[program]].
       
       

    Latest revision as of 16:51, 19 March 2005

    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.