ref: e4df0925260ce4f14ba6db4025d1ed4913b0f9ec
dir: /posix-arm64/run.s/
/* SPDX-License-Identifier: Unlicense */
.text
.global _run
_run:
mov x29, x0 // entry (x0 is the first argument, equivalent to rdi)
mov x9, x1 // _tos (x1 is the second argument, equivalent to rsi)
mov x19, x2 // argc (x2 is the third argument, equivalent to rdx)
mov x20, x3 // argv (x3 is the fourth argument, equivalent to rcx)
// Push argv onto stack
mov x10, x19 // x10 = argc
add x10, x10, #1 // x10 = argc + 1
lsl x10, x10, #3 // x10 = (argc + 1) * 8 (shifting left by 3 is multiplying by 8)
sub sp, sp, x10 // Allocate space on stack
mov x0, sp // x0 = new stack pointer (destination for memcpy)
mov x1, x20 // x1 = argv (source for memcpy)
mov x2, x10 // x2 = number of bytes to copy
bl _memcpy // Call memcpy to copy argv to stack
// Push argc onto stack
str x19, [sp, #-16]! // Push argc onto stack and update stack pointer
// Jump to entry point
br x29