/[osn-commons]/trunk/plibc/x86_64/stdio.s
ViewVC logotype

Contents of /trunk/plibc/x86_64/stdio.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (show annotations)
Thu Aug 15 18:10:51 2024 UTC (7 months, 2 weeks ago) by rakinar2
File MIME type: text/x-asm
File size: 975 byte(s)
feat: add plibc to the project
1 .text
2
3 .globl printf
4 .type printf, @function
5
6 printf:
7 push %rbp
8 mov %rsp, %rbp
9
10 push %r9
11 push %r8
12 push %rcx
13 push %rdx
14 push %rsi
15
16 /* The first argument is the format string, which is already loaded in
17 %rdi.
18 The second argument is a pointer to a region in the stack where
19 arguments passed to the registers are pushed in reverse order for easy
20 access. */
21 lea -40(%rbp), %rsi
22
23 /* Since the System V ABI requires that the remaining arguments are pushed
24 to the stack, we need to make sure we have a way to access them.
25 We can go back 16 bytes from the current base pointer to access the
26 first argument, since the last 8 bytes before the base pointer are
27 the return address and the first 8 bytes are base pointer of the
28 previous frame. */
29 lea 16(%rbp), %rdx
30
31 call printf_internal
32 mov %rbp, %rsp
33 pop %rbp
34 ret
35
36 .section .note.GNU-stack,"",@progbits

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26