-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf.s
More file actions
37 lines (32 loc) · 894 Bytes
/
printf.s
File metadata and controls
37 lines (32 loc) · 894 Bytes
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
#PURPOSE: This program is to demonstrate how
# to call printf
.section .data
#This string is called the format string. It's
#the first parameter, and printf uses it to
#find out how many parameters was given and
#what kind they are.
firststring:
.ascii "Hello! %s is a %s who loves the number %d\n\0"
name:
.ascii "Jonathan\0"
personstring:
.ascii "person\0"
#This could also have been an .equ, but we
#decided to give it a real memory location
#just for kicks
numberloved:
.long 3
.section .text
.globl _start
_start:
#Note that the parameters are
#passed in the reverse order
#that they are listed in the
#function's prototype
pushl numberloved #This is the %d
pushl $personstring #This is the second %s
pushl $name #This is the first %s
pushl $firststring #This is the format string #in the prototype
call printf
pushl $0
call exit