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

Bug #1888165 reported by Jeffrey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Richard Henderson

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.

Revision history for this message
Jeffrey (jmmorlan) wrote :
Revision history for this message
Jeffrey (jmmorlan) wrote :
Richard Henderson (rth)
Changed in qemu:
status: New → In Progress
assignee: nobody → Richard Henderson (rth)
Richard Henderson (rth)
Changed in qemu:
status: In Progress → Fix Committed
Revision history for this message
Thomas Huth (th-huth) wrote :
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.