WUT_Computer_Science/ECOAR/x86/C/asm_part.lst
2021-08-05 20:02:17 +02:00

28 lines
1.6 KiB
Plaintext
Executable File

1 section .text
2 global hello_world ;must be declared for linker (ld)
3
4 hello_world: ;tells linker entry point
5
6 00000000 55 push ebp
7 00000001 89E5 mov ebp,esp
8 00000003 53 push ebx
9
10 00000004 BA0E000000 mov edx,len ;message length
11 00000009 B9[00000000] mov ecx,msg ;message to write
12 0000000E BB01000000 mov ebx,1 ;file descriptor (stdout)
13 00000013 B804000000 mov eax,4 ;system call number (sys_write)
14 00000018 CD80 int 0x80 ;call kernel
15
16 0000001A 5B pop ebx
17 0000001B 89EC mov esp, ebp
18 0000001D 5D pop ebp
19 0000001E C3 ret
20
21 ;mov eax,1 ;system call number (sys_exit)
22 ;int 0x80 ;call kernel
23
24 section .data
25 00000000 48656C6C6F2C20776F- msg db 'Hello, world!', 0xa ;string to be printed
25 00000009 726C64210A
26 len equ $ - msg ;length of the string