From e8c1dc1bac078fd898acd0667799beb5c2476bb7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 16 Oct 2024 06:56:55 +0200 Subject: [PATCH] Fix flags on the AAM and AAD instructions. --- src/cpu/808x.c | 7 +++++-- src/cpu/x86_ops_bcd.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 990f9ae87..807ae9b6b 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -3154,8 +3154,10 @@ execx86(int cycs) #else cpu_src = pfq_fetchb(); #endif - if (x86_div(AL, 0)) - set_pzs(16); + if (x86_div(AL, 0)) { + cpu_data = AL; + set_pzs(8); + } break; case 0xD5: /*AAD*/ wait(1, 0); @@ -3169,6 +3171,7 @@ execx86(int cycs) add(8); AL = cpu_data; AH = 0x00; + set_pzs(8); break; case 0xD6: /*SALC*/ wait(1, 0); diff --git a/src/cpu/x86_ops_bcd.h b/src/cpu/x86_ops_bcd.h index b4779ab3e..a04dea65a 100644 --- a/src/cpu/x86_ops_bcd.h +++ b/src/cpu/x86_ops_bcd.h @@ -24,7 +24,7 @@ opAAD(uint32_t fetchdat) base = 10; AL = (AH * base) + AL; AH = 0; - setznp16(AX); + setznp8(AL); CLOCK_CYCLES((is486) ? 14 : 19); PREFETCH_RUN(is486 ? 14 : 19, 2, -1, 0, 0, 0, 0, 0); return 0; @@ -39,7 +39,7 @@ opAAM(uint32_t fetchdat) base = 10; AH = AL / base; AL %= base; - setznp16(AX); + setznp8(AL); CLOCK_CYCLES((is486) ? 15 : 17); PREFETCH_RUN(is486 ? 15 : 17, 2, -1, 0, 0, 0, 0, 0); return 0;