summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/asm-i386/elf.asm
blob: 3fba61ecfb883a6fa5ea915de50828253d4a4158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
format binary
use32
org	$08048000
ehdr:
mov	eax, $$
mov	ebx, $
mov	ecx, $1
db	$7F, "ELF"	; e_ident: magic
db	1		; EI_CLASS: ELFCLASS32
db	1		; EI_BYTE: ELFDATA2LSB (little endian, 2's complement)
db	1		; version of the object file format
db	0		; EI_VERSION: EV_CURRENT, ABI version
dd	0, 0		; EI_PAD: padding
dw	2		; e_type: executable
dw	3		; e_machine: Intel 80386
dd	1		; e_version: current version
dd	_start		; e_entry: entry address to _start
dd	phdr - $$	; e_phoff: program header offset at phdr - current position
dd	0		; e_shoff, no section header table
dd	0		; e_flags
dw	ehdrsize	; e_hsize: header size
dw	phdrsize	; e_phentsize: size of a program header entry
dw	1		; e_phnum: 1 entry in the program header table
dw	0		; e_shentsize
dw	0		; e_shnum
dw	0		; e_shstrndx
ehdrsize = $ - ehdr
phdr:
dd	1		; e_type: PT_LOAD
dd	0		; e_offset
dd	$$		; p_vaddr
dd	$$		; p_paddr
dd	filesize	; p_filesz
dd	filesize	; p_memsz
dd	7		; p_flags: Read, Write & Execute
dd	0x1000		; p_align
phdrsize = $ - phdr
_start:	
mov eax, 42
mov [a], eax
mov eax, 1
mov ebx, [a]
int $80
a: 	dd	43
filesize = $ - $$