Advertisement
Guest User

Untitled

a guest
Sep 30th, 2010
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   BITS 32
  2.  
  3.                 org     0x08048000
  4.  
  5.   ehdr:                                                 ; Elf32_Ehdr
  6.                 db      0x7F, "ELF", 1, 1, 1, 0         ;   e_ident
  7.         times 8 db      0
  8.                 dw      2                               ;   e_type
  9.                 dw      3                               ;   e_machine
  10.                 dd      1                               ;   e_version
  11.                 dd      _start                          ;   e_entry
  12.                 dd      52
  13.                 dd      0                               ;   e_shoff
  14.                 dd      0                               ;   e_flags
  15.                 dw      52
  16.                 dw      32
  17.                 dw      2                               ;   e_phnum
  18.                 dw      0                               ;   e_shentsize
  19.                 dw      0                               ;   e_shnum
  20.                 dw      0                               ;   e_shstrndx
  21.  
  22.   ;   this is the header for the code section
  23.  
  24.                 dd      1                               ;   p_type
  25.                 dd      0                               ;   p_offset
  26.                 dd      $$                              ;   p_vaddr
  27.                 dd      $$                              ;   p_paddr
  28.                 dd      filesize                        ;   p_filesz
  29.                 dd      filesize                        ;   p_memsz
  30.                 dd      5                               ;   p_flags
  31.                 dd      0x1000                          ;   p_align
  32.  
  33.   ;   this is the header for the string table
  34.  
  35.                 dd      1                               ;   p_type
  36.                 dd      0                               ;   p_offset
  37.                 dd      $$                              ;   p_vaddr
  38.                 dd      $$                              ;   p_paddr
  39.                 dd      filesize                        ;   p_filesz
  40.                 dd      filesize                        ;   p_memsz
  41.                 dd      5                               ;   p_flags
  42.                 dd      0x1000                          ;   p_align
  43.  
  44.   _start:
  45.  
  46.                 ; We want to print the string
  47.                
  48.         mov eax,4            ; 'write' system call
  49.         mov ebx,1            ; file descriptor 1 = screen
  50.         mov ecx,teststr      ; string to write
  51.         mov edx,14           ; length of string to write
  52.         int 80h              ; call the kernel
  53.  
  54.         ; Terminate program
  55.         mov eax,1            ; 'exit' system call
  56.         mov ebx,0            ; exit with error code 0
  57.         int 80h              ; call the kernel
  58.                
  59.   _stringtable:
  60.  
  61.                 teststr db "Hello, world!",10,0
  62.  
  63.   filesize      equ     $ - $$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement