1/* 2 * PROJECT: ReactOS SDK 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: ReactOS AMD64 architecture asm macros 5 * COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) 6 */ 7 8#include <macamd64.inc> 9 10MACRO(GENERATE_EXCEPTION_FRAME) 11 12 /* Allocate a KEXCEPTION_FRAME on the stack */ 13 /* -8 because the last field is the return address */ 14 sub rsp, KEXCEPTION_FRAME_LENGTH - 8 15 .allocstack (KEXCEPTION_FRAME_LENGTH - 8) 16 17 /* Save non-volatiles in KEXCEPTION_FRAME */ 18 mov [rsp + ExRbp], rbp 19 .savereg rbp, ExRbp 20 mov [rsp + ExRbx], rbx 21 .savereg rbx, ExRbx 22 mov [rsp +ExRdi], rdi 23 .savereg rdi, ExRdi 24 mov [rsp + ExRsi], rsi 25 .savereg rsi, ExRsi 26 mov [rsp + ExR12], r12 27 .savereg r12, ExR12 28 mov [rsp + ExR13], r13 29 .savereg r13, ExR13 30 mov [rsp + ExR14], r14 31 .savereg r14, ExR14 32 mov [rsp + ExR15], r15 33 .savereg r15, ExR15 34 movaps [rsp + ExXmm6], xmm6 35 .savexmm128 xmm6, ExXmm6 36 movaps [rsp + ExXmm7], xmm7 37 .savexmm128 xmm7, ExXmm7 38 movaps [rsp + ExXmm8], xmm8 39 .savexmm128 xmm8, ExXmm8 40 movaps [rsp + ExXmm9], xmm9 41 .savexmm128 xmm9, ExXmm9 42 movaps [rsp + ExXmm10], xmm10 43 .savexmm128 xmm10, ExXmm10 44 movaps [rsp + ExXmm11], xmm11 45 .savexmm128 xmm11, ExXmm11 46 movaps [rsp + ExXmm12], xmm12 47 .savexmm128 xmm12, ExXmm12 48 movaps [rsp + ExXmm13], xmm13 49 .savexmm128 xmm13, ExXmm13 50 movaps [rsp + ExXmm14], xmm14 51 .savexmm128 xmm14, ExXmm14 52 movaps [rsp + ExXmm15], xmm15 53 .savexmm128 xmm15, ExXmm15 54 .endprolog 55ENDM 56 57MACRO(RESTORE_EXCEPTION_STATE) 58 59 /* Restore non-volatile registers */ 60 mov rbp, [rsp + ExRbp] 61 mov rbx, [rsp + ExRbx] 62 mov rdi, [rsp + ExRdi] 63 mov rsi, [rsp + ExRsi] 64 mov r12, [rsp + ExR12] 65 mov r13, [rsp + ExR13] 66 mov r14, [rsp + ExR14] 67 mov r15, [rsp + ExR15] 68 movaps xmm6, [rsp + ExXmm6] 69 movaps xmm7, [rsp + ExXmm7] 70 movaps xmm8, [rsp + ExXmm8] 71 movaps xmm9, [rsp + ExXmm9] 72 movaps xmm10, [rsp + ExXmm10] 73 movaps xmm11, [rsp + ExXmm11] 74 movaps xmm12, [rsp + ExXmm12] 75 movaps xmm13, [rsp + ExXmm13] 76 movaps xmm14, [rsp + ExXmm14] 77 movaps xmm15, [rsp + ExXmm15] 78 79 /* Clean stack and return */ 80 add rsp, KEXCEPTION_FRAME_LENGTH - 8 81 82ENDM 83