File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ ; this example file for x86-64(amd64) devices and Netwide Assembler
2+
3+ section .data
4+ hello1: times 10 db 0 ; you can do this like that
5+ Len: equ $ - hello1
6+ section .bss
7+ hello2 resb 10 ; or like that
8+ section .text
9+ global _start
10+
11+ _start:
12+ sub rsp , 8 ; reserving stack for the value
13+ mov BYTE [ rsp ], 10 ; equivalent of this: push 10 (you cannot do 0x10, it will not work)
14+ mov DWORD [ hello1 ], 0x31727261 ; 0x31727261 = arr1
15+ mov DWORD [ hello2 ], 0x32727261 ; 0x32727261 = arr2
16+
17+ mov rax , 1
18+ mov rdi , 1
19+ lea rsi , [ rel hello1 ] ; pointer to the message
20+ mov rdx , Len
21+ syscall
22+
23+ mov rax , 1
24+ mov rdi , 1
25+ lea rsi , [ rsp ] ; newline
26+ mov rdx , 1
27+ syscall
28+
29+ mov rax , 1
30+ mov rdi , 1
31+ lea rsi , [ rel hello2 ] ; pointer to the message
32+ mov rdx , Len
33+ syscall
34+
35+ mov rax , 1
36+ mov rdi , 1
37+ lea rsi , [ rsp ] ; newline
38+ mov rdx , 1
39+ syscall
40+
41+ add rsp , 8 ; restoring stack
42+ mov rax , 60 ; exit
43+ xor rdi , rdi ; return 0
44+ syscall
You can’t perform that action at this time.
0 commit comments