1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (C) 2015-2021 ARM Limited.
3 // Original author: Dave Martin <Dave.Martin@arm.com>
5 // Utility functions for assembly code.
7 #include <asm/unistd.h>
10 // Print a single character x0 to stdout
15 mov x0, #1 // STDOUT_FILENO
26 // Print a NUL-terminated string starting at address x0 to stdout
37 1: mov w0, #1 // STDOUT_FILENO
45 // Print an unsigned decimal number x0 to stdout
49 str x30, [sp, #-32]! // Result can't be > 20 digits
52 strb w2, [x1, #-1]! // Write the NUL terminator
55 0: udiv x3, x0, x2 // div-mod loop to generate the digits
64 mov w0, #'0' // Print "0" for 0, not ""
75 // Print an unsigned decimal number x0 to stdout, followed by a newline
90 str x30, [sp, #-0x10]!
98 // fall through to puthexnibble
103 function puthexnibble
107 add w0, w0, #'a' - ('9' + 1)
113 // x0=data in, x1=size in, clobbers x0-x5,x8
115 str x30, [sp, #-0x10]!
126 1: ldr x30, [sp], #0x10
131 // Trivial memory copy: copy x2 bytes, starting at address x1, to address x0.
144 // Fill x1 bytes starting at x0 with 0xae (for canary purposes)
152 // Fill x1 bytes starting at x0 with 0.
158 // fall through to memfill
160 // Trivial memory fill: fill x1 bytes starting at address x0 with byte w2