[OpenBIOS] [PATCH] Adds the get-time word to the dictionary. Used to obtain the current time.

Programmingkid programmingkidx at gmail.com
Sun Sep 23 19:26:11 CEST 2012


The get-time word is a word that is used to obtain the current time. It is used on Apple's Open Firmware. 

signed-off-by: John Arbuckle <programmingkidx at gmail.com>


---
 forth/system/main.fs |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/forth/system/main.fs b/forth/system/main.fs
index 122ab1f..6867cf3 100644
--- a/forth/system/main.fs
+++ b/forth/system/main.fs
@@ -58,3 +58,24 @@ variable DIAG-list
 
   outer-interpreter
 ;
+
+\ Returns the time  ( -- second minute hour day month year )
+: get-time
+   " get-time"           ( addr len )
+   " rtc" open-dev   ( addr len device )
+   dup	                   ( addr len device device )
+   
+   0=  if   \ if the real-time clock isn't available
+      cr
+      3drop               ( ) 
+      true                   ( flag )
+      abort" Sorry but get-time isn't available for your system. "
+   then
+   
+   dup                      ( addr len device device )
+   >R                        ( addr len device )          ( R: device ) 
+   $call-method      ( addr len device -- )      ( R: device )
+   R>                        ( device )                          ( R: )
+   close-dev            ( device -- )
+;
+
-- 
1.7.5.4




More information about the OpenBIOS mailing list