CSC231 HelloWorld.asm

From dftwiki3
Revision as of 17:58, 12 September 2015 by Thiebaut (talk | contribs)
Jump to: navigation, search

--D. Thiebaut 08:46, 7 September 2012 (EDT)


;;; helloWorld.asm 
;;; D. Thiebaut  
;;;                
;;; Display "Hello there!" on the screen      
;;;                              
;;; To assemble, link, and run:  
;;;     nasm -f elf  helloWorld.asm  
;;;     ld -melf_i386 -o helloWorld helloWorld.o 
;;;     ./helloWorld        
;;;      

                section .data
Hello           db      "Hello there!"
HelloLen        equ     $-Hello

                section .text
                global  _start
_start:

;;; print message                                                                                                                           
                mov     eax, 4          ; write                                                                                             
                mov     ebx, 1          ; stdout                                                                                            
                mov     ecx, Hello      ; address of message to print                                                                       
                mov     edx, HelloLen   ; # of chars to print                                                                               
                int     0x80

;;; exit                                                                                                                                    
                mov     ebx, 0
                mov     eax, 1
                int     0x80