Modifying "TODAY" function in SuperCalc 4
Year 2000 Error Correction

Procedure by Erich Wagner, Bob Thomson
rjthomson@attbi.com
ew_ctl@compuserve.com

Ref:   article at: http://www.toggle.org/html/0011ART9.HTM

Users of the vintage 1986 DOS spreadsheet program SuperCalc 4 , and possibly other SC versions were afflicted at the turn of the century with the failure of the "TODAY" function, a command which inserts the current date into a spreadsheet cell, and permits current date dependant calculations of other dates and date related information to be updated without user input. 

The Y2K failure, according to the cited article, orginated in careless programming of a date validation function, which accepted only dates from 1900 through 1999, with no provision for override by the user.  This meant that the function failed, ungracefully, after December 31, 1999, and that manual input of the current date was required when calculations based on, or display of that date were desired.   Since the failure of the function resulted in the constant display of a date of January 1, 2000 + 23,206,492 days (November 30, 65535), an automated "work around" was not possible - the necessary adjustment decreased one day with each passing day.

Bob Thomson's article, based on correspondence with Erich Wagner, provides a procedure for using the Windows "Debug" function to change the valid range of dates to include dates through 2100, thus correcting the failure of the function.

I've the later SC4 version described in the article  and was able to "cookbook" the changes described in Bob Thomson's article successfully. 

The changes described below were tested out and implemented, Monday, July 19, 2004 - my first experience using debug since 1983, when I used the debug function in CPM to make formatting changes to Micropro's WordStar word processor.    I first began using SuperCalc with my first computer, a 1982 Osborne I, which had SuperCalc 2 bundled, and still use a monthly financial spreadsheet I developed at that time.   I believe that was the last personal computer made which came with adequate user documentation. 

Procedure:

Erich Wagner's second instruction to Bob Thomson was to:

"Try this:
                                                  DEBUG SC4.COM
                                                  S CS:0 FFF0 2A CD 21
In my first trial case (run in the Command window of Win98SE) those commands returned:
118D:EEE2

then:
-U 118D:EEE2
returned:
118D:EEE2 2ACD          SUB     CL,CH
118D:EEE4 2181F96C      AND     [BX+DI+6CF9],AX
118D:EEE8 07            POP     ES
118D:EEE9 722F          JB      EF1A
118D:EEEB 81F9D007      CMP     CX,07D0
118D:EEEF 7329          JNB     EF1A
118D:EEF1 FECE          DEC     DH
118D:EEF3 7825          JS      EF1A
118D:EEF5 80FE0C        CMP     DH,0C
118D:EEF8 7320          JNB     EF1A
118D:EEFA FEC6          INC     DH
118D:EEFC FECA          DEC     DL
118D:EEFE 781A          JS      EF1A
118D:EF00 80FE1F        CMP     DH,1F

Which indicated to me that in this case I would index EEEB by 2, and change the value from 700hex to 834hex as follows:
-e EEED 34 08
followed by the n, w, and q commands; all as Bob Thomson and Erich W. wrote in the article.


SECOND TRIAL (Command window, WinXP):
F:\SC4dir>debug sc4t.com
-S CS:0 FFF0 2A CD 21
0B36:EEE2
-U 0B36:EEE2
0B36:EEE2 2ACD          SUB     CL,CH
0B36:EEE4 2181F96C      AND     [BX+DI+6CF9],AX
0B36:EEE8 07            POP     ES
0B36:EEE9 722F          JB      EF1A
0B36:EEEB 81F9D007      CMP     CX,07D0
0B36:EEEF 7329          JNB     EF1A
0B36:EEF1 FECE          DEC     DH
0B36:EEF3 7825          JS      EF1A
0B36:EEF5 80FE0C        CMP     DH,0C
0B36:EEF8 7320          JNB     EF1A
0B36:EEFA FEC6          INC     DH
0B36:EEFC FECA          DEC     DL
0B36:EEFE 781A          JS      EF1A
0B36:EF00 80FE1F        CMP     DH,1F
-e EEED 34 08
-n SC4t.com
-w 100
Writing 0FB00 bytes
-q


F:\SC4dir>

Based on the correct display of the current date using the "TODAY" function in the trial copy of the program, I implemented the change:

IMPLEMENTATION (Command window, WinXP):
F:\SC4dir>debug sc4.com
-S CS:0 FFF0 2A CD 21
0B36:EEE2
-u OB36:EEE2
   ^ Error
-U 0B36:EEE2
0B36:EEE2 2ACD          SUB     CL,CH
0B36:EEE4 2181F96C      AND     [BX+DI+6CF9],AX
0B36:EEE8 07            POP     ES
0B36:EEE9 722F          JB      EF1A
0B36:EEEB 81F9D007      CMP     CX,07D0
0B36:EEEF 7329          JNB     EF1A
0B36:EEF1 FECE          DEC     DH
0B36:EEF3 7825          JS      EF1A
0B36:EEF5 80FE0C        CMP     DH,0C
0B36:EEF8 7320          JNB     EF1A
0B36:EEFA FEC6          INC     DH
0B36:EEFC FECA          DEC     DL
0B36:EEFE 781A          JS      EF1A
0B36:EF00 80FE1F        CMP     DH,1F
-e EEED 34 08
-n SC4.COM
-w 100
Writing 0FB00 bytes
-q


F:\SC4dir>


Additional Information:

As noted, I followed the procedure in the article as a recipe, without understanding of the meaning of or context for them.   Despite the fact that the changes worked, and corrected the date problem in my copy of SC4, I wrote to the authors of the procedure, to see if I could get more information.  Erich Wagner went to considerable lengths to reply to my note, and provided additional information about the procedure and about "Debug" generally:

Bob Thomson's writeup included this statement:
"So I made a backup copy of SC4.COM, indexed  CB23 by 2, and changed the value from 700hex to 834hex as follows:"
I asked what condition of the debug process requires, the indexing (incrementing) of the displayed address value for the date validation compare command by 2?  Mr. Wagner's response was that:
The reason Bob wrote about ""Indexing by 2"" is that having found the address of the compare instruction one has to skip over the "compare" part of the instruction to get to the value which is being compared against.  Thus in your case you found the compare instruction at EEEB but EEEB actually points to the 81 part of the compare instruction ("81F9D007", ed.); EEEC points to the F9 part of the compare instruction and EEED and EEEE to the actual number (07D0 bzw 0834) being compared with the CX register of the microprocessor, which needs changing.
I infer that the command -e EEED 34 08   changes the value at EEED from D0 to 34 and the value at EEEE from 07 to 08.  The reason for the reversal in order of the numbers in execution of the compare instructin is beyond me, but apparently has to do with the basic processes  in which the machine executes instructions. 

I also inquired about the meaning of Mr. Wagner's instruction, as described in the article:  "Try this:
                                                  DEBUG SC4.COM
                                                  S CS:0 FFF0 2A CD 21"
Mr. Wagner replied that:
The way I suggested to find the date checking part involved the debug command
S CS:0 FFF0 2A CD 21
which boils down to:
Search (S)
from Code Segment offset zero (CS:0)
for the next approx 64,000 bytes (FFF0)
for this pattern: 2A CD 21 (the machine code for getting date from DOS)
Erich Wagner also responded to my request for background on Debug and its use generally.  I have taken the liberty of highlighting his general caution about the use of the debug function:
Debug was a supplementary program to DOS, its commands are listed in MS-DOS manuals for versions 1.25 to 5.0. I think DOS 6 and 6.22 listed its command syntax in the online help system (e.g. help debug). From the command prompt DEBUG /? or debug <enter> ? should present a list of commands.

From DOS 7 (aka Win95) onwards all reference to it seems to be dropped. Any old DOS manual should have it. The definitive book of that era is the MS-DOS Encylopedia (Microsoft Press) from about 1987 which had about 1200 pages and cost about $200 then.

I must say Debug is really intended for machine code programmers who know what they're doing. I think MS included it as a last ditch way of patching applications when all else fails. You can do serious damage with debug - so please be very careful - and never use the W (write to disk) command unless you are confident you know what will happen.
OK, good, I am happy.  I don't really understand more than I did before, but somehow I feel as if I do.  And it gives me hooks to hang other new information on in the future, as well as tools with which to locate the information.

I am also searching for a website or book source for the SC4 Manual.   I have limped along with the trifold command summary card for nearly 20 years.   Erich Wagner recommends Mastering SuperCalc4 by Greg Harvey (Sybex) but I have not yet found a source for it on the net - though I have posted a "wish list" item for it at Amazon.com.  Searches I used for SC4 books are:

 http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=%22Using+SuperCalc+4%22+Wiley&btnG=Search

 http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=%22Using+SuperCalc+4%22+book&btnG=Search
 
http://www.amazon.com/exec/obidos/search-handle-url/index=books&field-keywords=SuperCalc4/ref=br_sub_/002-8198993-3871265 

http://www.amazon.com/gp/product/offer-listing/0471859923//002-8198993-3871265?condition=all
http://www.amazon.com/gp/product/offer-listing/0395477867//002-8198993-3871265?condition=all

I hope that this posting helps other SuperCalc 4 users find and use Erich Wagner procedure as described inBob Thomson's article to correct the Year 2000 problem in the handling of the "Today" function.

July 19, 2004, rev. 07/27/2004
Jim Pivonka
http://www.jimpivonka.com