logoISU  

CS 456 - Systems Programming

Spring 2024

Displaying ./code/mar27/hello.asm

; Hello World Program - asmtutor.com
; Compile with: nasm -f elf helloworld.asm
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld.o -o helloworld
; Run with: ./helloworld
 
SECTION .data
msg     db      'Hello World!', 0Ah
 
SECTION .text
global  _start
 
_start:
 
    mov     edx, 13     ; third argument in write (number of bytes to write)
    mov     ecx, msg    ; buffer, second argument in write
    mov     ebx, 1      ; file descriptor (first arg in write
    mov     eax, 4      ; this 4 in eax means we are calling the 'write' system call
    int     80h
 
    mov     ebx, 0      ; return 0 status on exit - 'No Errors'
    mov     eax, 1      ; invoke SYS_EXIT (kernel opcode 1)
    int     80h