d@alice.UUCP (07/22/87)
Here's a public thank you to everyone who replied, and a summary to the net of what I found out. WHERE TO FIND THE TIME ---------------------- (all numbers in hex unless otherwise noted) There is a location in memory that most DOS's increment every 55 milliseconds. It is at segment 40, address 6C. In BASIC, you'd read it like this: def seg=&h40 tick=peek(&h6c) You can also use the built-in clock in a few different ways. Most Microsoft-based BASICS provide the handy INP(port) function. Using this table: 71 tenths of a second 72 unit seconds 73 10s of seconds 74 unit minutes 75 10s of minutes 76 unit hours 77 10s of hours 78 unit days 79 10s of days 7a day of week (1-7) 7b unit months 7c 10s of months 7d leap year 7e (stop/start - for out, not inp) 7f year you can use the INP function to read in anything you want. Note that what is returned is usually in the top eight bits of a sixteen bit word, so you may have to convert to what you want by going (foo\256) mod 128. You could also use the INT86 call in QuickBASIC, and stick a hex 2c in the first eight bits of the A register while doing an interrupt 21 hex. DIM clockin%(7),clockout%(7) clockin%(0) = &h2c00 ' stick hex 2c into the first eight bits ' of what will be passed into the A register CALL INT86(&h21,varptr(clockin%(0)),varptr(clockout%(0))) You get the goodies back in clockout%(), with generally two piece of information per byte. To extract the high part of the word, (foo\256) mod 128 works To extract the low part, foo mod 128 works. (See page 148-149 in the QuickBASIC manual.) Thanks to everyone who replied. And why did I go through all this trouble? So I could get my time down to tenths of a second instead of seconds. Note that while my AT&T manuals claim accuracy down to hundredths of a second, the hundredths always come back in multiples of 10. -- # Daniel Rosenberg / AT&T Bell Labs / Murray Hill / New Jersey # These opinions are necessarily mine, not my employer's. # UUCP: {ihnp4 || research || allegra}!alice!d HORN: 201/582-3059 (work) # INTERNET: d%alice%btl@csnet-relay or d@alice.att.com --More--