Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

emulate: save/restore host flags in fastop_dispatch #216

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/emulate_ops.asm
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ global fastop_dispatch
; src1 - stack2 (saved to non-volatile esi)
; src2 - stack3 (saved to non-volatile edi)
; flags - stack4 (saved to non-volatile ebp)
%define stack_arg(index) [esp + 4*04h + 04h + (index*04h)]
%define stack_arg(index) [esp + 5*04h + 04h + (index*04h)]
fastop_dispatch:
push ebx
push esi
push edi
push ebp
pushf
mov ebx, stack_arg(1)
mov esi, stack_arg(2)
mov edi, stack_arg(3)
Expand All @@ -216,6 +217,7 @@ fastop_dispatch:
pushf
pop dword [ebp]
mov [ebx], reg_dst
popf
pop ebp
pop edi
pop esi
Expand All @@ -230,8 +232,9 @@ fastop_dispatch:
; src1 - rdx (saved to volatile r10)
; src2 - rcx (saved to volatile r11)
; flags - r8 (accessed directly)
%define stack_arg(index) [rsp + 0*08h + 08h + (index*08h)]
%define stack_arg(index) [rsp + 1*08h + 08h + (index*08h)]
fastop_dispatch:
pushf
mov r10, rdx
mov r11, rcx
mov reg_dst, [rsi]
Expand All @@ -243,6 +246,7 @@ fastop_dispatch:
pushf
pop qword [r8]
mov [rsi], reg_dst
popf
ret
%undef stack_arg

Expand All @@ -253,9 +257,10 @@ fastop_dispatch:
; src1 - r8 (accessed directly)
; src2 - r9 (accessed directly)
; flags - stack4 (saved to non-volatile r12)
%define stack_arg(index) [rsp + 1*08h + 08h + (index*08h)]
%define stack_arg(index) [rsp + 2*08h + 08h + (index*08h)]
fastop_dispatch:
push r12
pushf
mov r10, rcx
mov r11, rdx
mov r12, stack_arg(4)
Expand All @@ -268,6 +273,7 @@ fastop_dispatch:
pushf
pop qword [r12]
mov [r11], reg_dst
popf
pop r12
ret
%undef stack_arg
Expand Down