blob: 2d50e7348752735f8ce9717faba42de022525bf8 (
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
|
# Just an example of calling printf() using ASM
.section .data
firststring:
.ascii "Hello! %s is a %s who lives the number %d\n\0"
name:
.ascii "Maiolino\0"
personstring:
.ascii "person\0"
numberloved:
.long 123
.section .text
.globl _start
# Recall we are using x86_64 ABI here, so we pass arguments through
# registers instead of on the stack.
_start:
movq $firststring, %rdi
movq $name, %rsi
movq $personstring, %rdx
# We don't use $numberloved here because $ sign means 'immediate'
# addressing. Here we want the 'CONTENT' pointed by label 'numberloved'
# so, we use 'direct' addressing, by ommiting the $ sign, so we get the
# information "pointed by" the label numberloved itself.
movq numberloved, %rcx
call printf
movq $0, %rdi
call exit
|