skiselev / 8088_bios

BIOS for Intel 8088 based computers
GNU General Public License v3.0
522 stars 65 forks source link

Saving date/time in DOS saves invalid (?) date/time #75

Open ConiKost opened 1 month ago

ConiKost commented 1 month ago

I am using a NuXTv2 with 8088 Bios. If I do run date and time command within IBM PC-DOS 2000 (aka 7.0 Rev1), 8088 BIOS reports an invalid date/time: 1418-09-15 00:23:29.

Any ideas, what could go wrong?

skiselev commented 1 month ago

No idea what's wrong :) Is the clock set correctly? Does it report correct date and time on boot?

What's the version of 8088 BIOS? I suppose you're using the RTC built-in on the NuXT 2 motherboard?

ConiKost commented 1 month ago

Is the clock set correctly? Does it report correct date and time on boot?

Only for the moment, after date and time commands are run. After reboot, it's gone. Then it reports 1418-09-15 00:23:29 in BIOS. DOS reports 1980.

What's the version of 8088 BIOS?

Newest binary image from Git

I suppose you're using the RTC built-in on the NuXT 2 motherboard?

Yes.

skiselev commented 1 month ago

I'll try to reproduce it on my end.

640-KB commented 1 month ago

This is actually a known bug in PC DOS 7, where they tried to save a few code bytes by using an AAD instruction with a non-10 operand (undocumented and not officially supported) to convert the date between BCD and binary. While all of the Intel chips they tested supported this, it was not implemented in the V20 - instead of multiplying by 16, the date digits get multiplied by 10. You end up with dates in hex, so for 2024: 20 = 14h, 24 = 18h which is what you are seeing.

Here's a post about it, and there's also a patched version of PC DOS that fixes this.

https://forum.vcfed.org/index.php?threads/discovered-rtc-bug-in-pc-dos-2000-ibm-dos-7.1242785/

Not an 8088_bios bug, it's a PC DOS 7 V20 bug!

ConiKost commented 1 month ago

@640-KB Wow. Thank you for the information. I really wasn't aware of such problem with PC-DOS 7/2000 with NEC V20. Do your patched version changes language on non english versions of PC-DOS? If I do understand correctly, setting one time with MS-DOS 6.22 from floppy boot disk should also work?

@640-KB @skiselev I do wonder, if some workaround could be implemented on BIOS level?

640-KB commented 1 month ago

@640-KB Wow. Thank you for the information. I really wasn't aware of such problem with PC-DOS 7/2000 with NEC V20. Do your patched version changes language on non english versions of PC-DOS? If I do understand correctly, setting one time with MS-DOS 6.22 from floppy boot disk should also work?

Those patched versions were against the images from PCjs.org, which were both English. I'm not certain, but I would not expect IBMBIO.COM to be interchangeable across different language versions.

And yes, the issue only occurs setting the date from DOS since the reverse operation of reading the date uses AAM 10h which does work on the V20 as it does on the Intel CPUs. Booting one time to DOS 6.22 (or any DOS that's 3.2 or later or FreeDOS) or the patched English version of PC-DOS would work. I believe you can also set the date from the 8088_bios setup or (for fun if you have one) try putting in an 8088 CPU and set the date with your PC-DOS 7/2K, which would do it as well.