Skip to content

Commit cab9c48

Browse files
Add amd64_save_registers.S
Added amd64_save_registers.S which reimplements amd64_save_registers.asm for the clang assembler. The primary differences here are the following: - Linux assembler syntax - The Linux x64 ABI has the first parameter passed in in $rdi so this implementation uses that
1 parent f536a5b commit cab9c48

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

lib/Common/Memory/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_library (Chakra.Common.Memory STATIC
3939
SmallNormalHeapBucket.cpp
4040
StressTest.cpp
4141
VirtualAllocWrapper.cpp
42+
amd64/amd64_SAVE_REGISTERS.S
4243
)
4344

4445
include_directories(..)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//
5+
6+
.intel_syntax noprefix
7+
8+
//void amd64_SAVE_REGISTERS(registers)
9+
//
10+
// This method pushes the 16 general purpose registers into the passed in array.
11+
// By convention, the stack pointer will always be stored at registers[0]
12+
//
13+
// void* registers[16];
14+
// amd64_SAVE_REGISTERS(registers);
15+
//
16+
.globl amd64_SAVE_REGISTERS
17+
amd64_SAVE_REGISTERS:
18+
mov [rdi+00h], rsp
19+
mov [rdi+08h], rax
20+
mov [rdi+10h], rbx
21+
mov [rdi+18h], rcx
22+
mov [rdi+20h], rdx
23+
mov [rdi+28h], rbp
24+
mov [rdi+30h], rsi
25+
mov [rdi+38h], rdi
26+
mov [rdi+40h], r8
27+
mov [rdi+48h], r9
28+
mov [rdi+50h], r10
29+
mov [rdi+58h], r11
30+
mov [rdi+60h], r12
31+
mov [rdi+68h], r13
32+
mov [rdi+70h], r14
33+
mov [rdi+78h], r15
34+
ret
35+
36+

0 commit comments

Comments
 (0)