During some testing of GLaTICK we discovered a curious "bug" in PC DOS 2000 / IBM DOS 7 having to do with DOS DATE/TIME support of `INT 1Ah` real-time clock functions. On an XT machine with a V20 CPU running these versions, when using DOS's DATE or TIME commands to set the clock (or any DOS `INT 21h` clock function) the RTC would be set with incorrect values. Specifically, if you set the time as 2023-04-18 12:05:00, the RTC would read back as 1417-04-12 0C-05:00.
After some debugging and tracing, it turns out that IBM DOS 7 and its decedents replaced the code that converts a byte value to a BCD value (which `INT 1Ah` expects) with the following:
Since `AAD imm` is not supported on V20 it will execute `AAD 10h` as `AAD 0Ah`, meaning that the `AAM` and `AAD 10h` negate each other and DOS ends up passing the binary value to `INT 1Ah` instead of the BCD value, resulting in the invalid times. This code saves 8 bytes (though is actually more clock cycles) compared to the normal (and well tested) shift-n-OR method.
Anyway, just thought I'd share so it can be documented for posterity.
640KB
After some debugging and tracing, it turns out that IBM DOS 7 and its decedents replaced the code that converts a byte value to a BCD value (which `INT 1Ah` expects) with the following:
Since `AAD imm` is not supported on V20 it will execute `AAD 10h` as `AAD 0Ah`, meaning that the `AAM` and `AAD 10h` negate each other and DOS ends up passing the binary value to `INT 1Ah` instead of the BCD value, resulting in the invalid times. This code saves 8 bytes (though is actually more clock cycles) compared to the normal (and well tested) shift-n-OR method.
Anyway, just thought I'd share so it can be documented for posterity.
640KB