All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey <1888165@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: [Bug 1888165] [NEW] loopz/loopnz clearing previous instruction's modified flags on cx -> 0
Date: Mon, 20 Jul 2020 00:15:49 -0000	[thread overview]
Message-ID: <159520414927.8137.962061150870003047.malonedeb@wampee.canonical.com> (raw)

Public bug reported:

If you run QBasic in qemu, printing a double-type single-digit number
will print an extra decimal point (e.g. PRINT CDBL(3) prints "3.") that
does not appear when running on a real CPU (or on qemu with -enable-
kvm). I tracked this down to the state of the status flags after a
loopnz instruction.

After executing a sequence like this in qemu:

	mov bx,1
	mov cx,1
	dec bx    ; sets Z bit in flags
A:	loopnz A  ; should not modify flags

Z is incorrectly clear afterwards. loopz does the same thing (but not
plain loop). Interestingly, inserting pushf+popf after dec results in Z
set, so loopnz/loopz does not always clear Z itself but is rather
interfering with the previous instruction's flag setting.

Version 5.1.0-rc0, x86-64 host.

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1888165

Title:
  loopz/loopnz clearing previous instruction's modified flags on cx -> 0

Status in QEMU:
  New

Bug description:
  If you run QBasic in qemu, printing a double-type single-digit number
  will print an extra decimal point (e.g. PRINT CDBL(3) prints "3.")
  that does not appear when running on a real CPU (or on qemu with
  -enable-kvm). I tracked this down to the state of the status flags
  after a loopnz instruction.

  After executing a sequence like this in qemu:

  	mov bx,1
  	mov cx,1
  	dec bx    ; sets Z bit in flags
  A:	loopnz A  ; should not modify flags

  Z is incorrectly clear afterwards. loopz does the same thing (but not
  plain loop). Interestingly, inserting pushf+popf after dec results in
  Z set, so loopnz/loopz does not always clear Z itself but is rather
  interfering with the previous instruction's flag setting.

  Version 5.1.0-rc0, x86-64 host.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1888165/+subscriptions


             reply	other threads:[~2020-07-20  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  0:15 Jeffrey [this message]
2020-07-20  0:33 ` [Bug 1888165] Re: loopz/loopnz clearing previous instruction's modified flags on cx -> 0 Jeffrey
2020-07-20  0:34 ` Jeffrey
2020-07-20 15:17 ` Richard Henderson
2020-07-26 20:01 ` Richard Henderson
2020-08-20 15:03 ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159520414927.8137.962061150870003047.malonedeb@wampee.canonical.com \
    --to=1888165@bugs.launchpad.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.