Browse Source

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
Hitesh Kanwathirtha 10 years ago
parent
commit
cab9c48ed7
2 changed files with 37 additions and 0 deletions
  1. 1 0
      lib/Common/Memory/CMakeLists.txt
  2. 36 0
      lib/Common/Memory/amd64/amd64_SAVE_REGISTERS.S

+ 1 - 0
lib/Common/Memory/CMakeLists.txt

@@ -39,6 +39,7 @@ add_library (Chakra.Common.Memory STATIC
     SmallNormalHeapBucket.cpp
     StressTest.cpp
     VirtualAllocWrapper.cpp
+    amd64/amd64_SAVE_REGISTERS.S
     )
 
 include_directories(..)

+ 36 - 0
lib/Common/Memory/amd64/amd64_SAVE_REGISTERS.S

@@ -0,0 +1,36 @@
+//
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//
+
+.intel_syntax noprefix
+
+//void amd64_SAVE_REGISTERS(registers)
+//
+//   This method pushes the 16 general purpose registers into the passed in array.
+//   By convention, the stack pointer will always be stored at registers[0]
+//
+//       void* registers[16];
+//       amd64_SAVE_REGISTERS(registers);
+//
+.globl amd64_SAVE_REGISTERS 
+amd64_SAVE_REGISTERS:   
+        mov [rdi+00h], rsp
+        mov [rdi+08h], rax
+        mov [rdi+10h], rbx
+        mov [rdi+18h], rcx
+        mov [rdi+20h], rdx
+        mov [rdi+28h], rbp
+        mov [rdi+30h], rsi
+        mov [rdi+38h], rdi
+        mov [rdi+40h], r8
+        mov [rdi+48h], r9
+        mov [rdi+50h], r10
+        mov [rdi+58h], r11
+        mov [rdi+60h], r12
+        mov [rdi+68h], r13
+        mov [rdi+70h], r14
+        mov [rdi+78h], r15
+        ret
+
+