1;; Copyright 2020 the V8 project authors. All rights reserved. 2;; Use of this source code is governed by a BSD-style license that can be 3;; found in the LICENSE file. 4 5;; MASM syntax 6;; https://docs.microsoft.com/en-us/cpp/assembler/masm/microsoft-macro-assembler-reference?view=vs-2019 7 8public PushAllRegistersAndIterateStack 9 10.code 11PushAllRegistersAndIterateStack: 12 ;; Push all callee-saved registers to get them on the stack for conservative 13 ;; stack scanning. 14 ;; 15 ;; We maintain 16-byte alignment at calls. There is an 8-byte return address 16 ;; on the stack and we push 72 bytes which maintains 16-byte stack alignment 17 ;; at the call. 18 ;; Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention 19 ;; 20 ;; rbp is callee-saved. Maintain proper frame pointer for debugging. 21 push rbp 22 mov rbp, rsp 23 push 0CDCDCDh ;; Dummy for alignment. 24 push rsi 25 push rdi 26 push rbx 27 push r12 28 push r13 29 push r14 30 push r15 31 ;; Pass 1st parameter (rcx) unchanged (Stack*). 32 ;; Pass 2nd parameter (rdx) unchanged (StackVisitor*). 33 ;; Save 3rd parameter (r8; IterateStackCallback) 34 mov r9, r8 35 ;; Pass 3rd parameter as rsp (stack pointer). 36 mov r8, rsp 37 ;; Call the callback. 38 call r9 39 ;; Pop the callee-saved registers. 40 add rsp, 64 41 ;; Restore rbp as it was used as frame pointer. 42 pop rbp 43 ret 44 45end 46