;;; Courtesy of the excellent writeup at http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html, ;;; "A Whirlwind Tutorial on Creating Really Teensy ELF Executables in Linux" ;;; ;;; Use "yasm -f bin flat-yasmtest.asm -o flat-yasmtest.exe" to assemble BITS 32 org 0x08048000 ehdr: ; Elf32_Ehdr db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident times 8 db 0 dw 2 ; e_type dw 3 ; e_machine dd 1 ; e_version dd _start ; e_entry dd phdr - $$ ; e_phoff dd 0 ; e_shoff dd 0 ; e_flags dw ehdrsize ; e_ehsize dw phdrsize ; e_phentsize dw 1 ; e_phnum dw 0 ; e_shentsize dw 0 ; e_shnum dw 0 ; e_shstrndx ehdrsize equ $ - ehdr phdr: ; Elf32_Phdr dd 1 ; p_type dd 0 ; p_offset dd $$ ; p_vaddr dd $$ ; p_paddr dd filesize ; p_filesz dd filesize ; p_memsz dd 5 ; p_flags dd 0x1000 ; p_align phdrsize equ $ - phdr _start: ;;; SYS_WRITE 1,msg,msglen mov EAX,4 mov EBX,1 mov ECX,msg mov EDX,msglen int 0x80 ;;; SYS_EXIT 10 mov EAX,1 mov EBX,10 int 0x80 ;; mov ebx,1 ; this is a comment ;; mov eax,syscall_exit ;; int 0x80 msg: db 'Hello World!',10 msglen equ $-msg filesize equ $ - $$