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

Commit de01cba

Browse files
authored
Merge pull request #216 from jarveson/fix-host-flags
emulate: save/restore host flags in fastop_dispatch
2 parents 7214275 + 1b53207 commit de01cba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/emulate_ops.asm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,13 @@ global fastop_dispatch
197197
; src1 - stack2 (saved to non-volatile esi)
198198
; src2 - stack3 (saved to non-volatile edi)
199199
; flags - stack4 (saved to non-volatile ebp)
200-
%define stack_arg(index) [esp + 4*04h + 04h + (index*04h)]
200+
%define stack_arg(index) [esp + 5*04h + 04h + (index*04h)]
201201
fastop_dispatch:
202202
push ebx
203203
push esi
204204
push edi
205205
push ebp
206+
pushf
206207
mov ebx, stack_arg(1)
207208
mov esi, stack_arg(2)
208209
mov edi, stack_arg(3)
@@ -216,6 +217,7 @@ fastop_dispatch:
216217
pushf
217218
pop dword [ebp]
218219
mov [ebx], reg_dst
220+
popf
219221
pop ebp
220222
pop edi
221223
pop esi
@@ -230,8 +232,9 @@ fastop_dispatch:
230232
; src1 - rdx (saved to volatile r10)
231233
; src2 - rcx (saved to volatile r11)
232234
; flags - r8 (accessed directly)
233-
%define stack_arg(index) [rsp + 0*08h + 08h + (index*08h)]
235+
%define stack_arg(index) [rsp + 1*08h + 08h + (index*08h)]
234236
fastop_dispatch:
237+
pushf
235238
mov r10, rdx
236239
mov r11, rcx
237240
mov reg_dst, [rsi]
@@ -243,6 +246,7 @@ fastop_dispatch:
243246
pushf
244247
pop qword [r8]
245248
mov [rsi], reg_dst
249+
popf
246250
ret
247251
%undef stack_arg
248252

@@ -253,9 +257,10 @@ fastop_dispatch:
253257
; src1 - r8 (accessed directly)
254258
; src2 - r9 (accessed directly)
255259
; flags - stack4 (saved to non-volatile r12)
256-
%define stack_arg(index) [rsp + 1*08h + 08h + (index*08h)]
260+
%define stack_arg(index) [rsp + 2*08h + 08h + (index*08h)]
257261
fastop_dispatch:
258262
push r12
263+
pushf
259264
mov r10, rcx
260265
mov r11, rdx
261266
mov r12, stack_arg(4)
@@ -268,6 +273,7 @@ fastop_dispatch:
268273
pushf
269274
pop qword [r12]
270275
mov [r11], reg_dst
276+
popf
271277
pop r12
272278
ret
273279
%undef stack_arg

0 commit comments

Comments
 (0)