forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crthelpers.S
74 lines (62 loc) · 2.12 KB
/
crthelpers.S
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.intel_syntax noprefix
#include "unixasmmacros.inc"
#include "asmconstants.h"
// JIT_MemSet/JIT_MemCpy
//
// It is IMPORTANT that the exception handling code is able to find these guys
// on the stack, but on non-windows platforms we can just defer to the platform
// implementation.
//
// void JIT_MemSet(void* dest, int c, size_t count)
//
// Purpose:
// Sets the first "count" bytes of the block of memory pointed byte
// "dest" to the specified value (interpreted as an unsigned char).
//
// Entry:
// RDI: void* dest - Pointer to the block of memory to fill.
// RSI: int c - Value to be set.
// RDX: size_t count - Number of bytes to be set to the value.
//
// Exit:
//
// Uses:
//
// Exceptions:
//
LEAF_ENTRY JIT_MemSet, _TEXT
test rdx, rdx // check if count is zero
jz Exit_MemSet // if zero, no bytes to set
cmp byte ptr [rdi], 0 // check dest for null
jmp C_PLTFUNC(memset) // forward to the CRT implementation
Exit_MemSet:
ret
LEAF_END_MARKED JIT_MemSet, _TEXT
// void JIT_MemCpy(void* dest, const void* src, size_t count)
//
// Purpose:
// Copies the values of "count" bytes from the location pointed to
// by "src" to the memory block pointed by "dest".
//
// Entry:
// RDI: void* dest - Pointer to the destination array where content is to be copied.
// RSI: const void* src - Pointer to the source of the data to be copied.
// RDX: size_t count - Number of bytes to copy.
//
// Exit:
//
// Uses:
//
// Exceptions:
//
LEAF_ENTRY JIT_MemCpy, _TEXT
test rdx, rdx // check if count is zero
jz Exit_MemCpy // if zero, no bytes to set
cmp byte ptr [rdi], 0 // check dest for null
cmp byte ptr [rsi], 0 // check src for null
jmp C_PLTFUNC(memcpy) // forward to the CRT implementation
Exit_MemCpy:
ret
LEAF_END_MARKED JIT_MemCpy, _TEXT