[OpenBIOS] [PATCH] Adds the get-time word to the dictionary. It returns the current time and date on the stack.

Programmingkid programmingkidx at gmail.com
Sun Sep 23 23:57:22 CEST 2012


Made a few changes to the patch. Thank you Tarl for your suggestions.  

Signed-Off-By: John Arbuckle <programmingkidx at gmail.com>

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

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


More information about the OpenBIOS mailing list