viernes, 29 de noviembre de 2013

[SLAE] ASM Hello World

Hello. It's a just small example of hello world from SLAE course

; HelloWorld.asm
; Author: Andriy Brukhovetskyy

global _start

section .text


        ;print hello world on the screen
        mov eax, 0x4
        mov ebx, 0x1
        mov ecx, message
        mov edx, mlen
        int 0x80

        ;exit the program gracefully
        mov eax, 0x1
        mov ebx, 0x5
        int 0x80

section .data

        message: db "Hello World!"
        mlen     equ $-message

;int 0x80 invoke a system call

For creating object from this .asm you need (install if missed nasn, sudo apt-get install nasm in Ubuntu)

sudo nasm -f elf32 -o helloworld.o hw.asm

and then

ld -o HelloWorld helloworld.o

more information about syscalls in Ubuntu you can find in: /usr/include/i386-linux-gnu/asm/unistd_32.h 

Nice article : Sysenter Based System Call Mechanism in Linux 2.6

Best regards

No hay comentarios:

Publicar un comentario