[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clock, BASIC, and IIgs



In article <4plje3$2td@news.nevada.edu>, snit@nevada.edu (Snit) writes:

>
>Does anybody know how to access the clock from BASIC on a IIgs? ....
>Specificly, I am trying to
>record the times of a photosensor attached to PDL (0) into a text file
>that can be imported into a spreadsheet or stats program. ....
>

     One way is to go to the monitor and type-in the small machine
language routine listed below. Then BSAVE READ.TM.HEX,A$300,L$330.

     Your BASIC program begins with

 10 PRINT CHR$(4)"BLOAD READ.TM.HEX"

     When you want to get the current time just CALL 768 and PEEK(815) for
seconds, PEEK(816) for minutes, etc..      

     Machine code for a routine which CALLs ReadTimeHex and saves ...

Seconds: $32F PEEK(815)
Minutes:  $330  PEEK(816)
Hours:     $331  PEEK(817)
Year:       $332  PEEK(818)
Day:        $333  PEEK(819)
Month:    $334  PEEK(820)
Wkday:   $336  PEEK(822)

 
300: 18                 First, set Native mode with 16 bit registers
301: FB
302: C2 30 
304: 48                 Push 4 words of 'workspace' onto stack
305: 48
306: 48
307: 48
308: A2 03 0D       Put ReadTimeHex tool ID in X
30B: 22 00 00 E1  JSR long to dispatcher to do the Read
30F: 68                 Pull MinSec result word from Stack (Lo byte = Sec)
310: 8D 2F 03       Save MinSec result word at $32F
313: 68                 Pull YrHour result word from Stack (Lo byte =
Hours)
314: 8D 31 03       Save YrHour result word at $331
317: 68                 Pull MoDay result word from Stack (Lo byte = Day)
318: 8D 33 03       Save MoDay result word at $333
31B: 68                 Pull Wkday result word from Stack (Hi byte = day#
) 
31C: 8D 35 03       Save Wkday result word at $335
31F: E2 30            Restore Emulation mode with 8-bit registers
321: 38
322: FB
323: 60                Exit back to BASIC


Rubywand