Generalise parse-hex

Add parse-nhex word reusing existing parse-ints and use that in
parse-hex instead of an independent implementation. The parse-nhex
name matches Apple OF, while SLOF calls the same operation
hex-decode-unit so adding this word increases compatibility with other
OF implementations.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
diff --git a/forth/device/package.fs b/forth/device/package.fs
index 1e01e20..f83ef7a 100644
--- a/forth/device/package.fs
+++ b/forth/device/package.fs
@@ -212,35 +212,6 @@
   left-split
 ;
 
-\ parse ints "hi,...,lo" separated by comma
-: parse-ints ( str len num -- val.lo .. val.hi )
-  -rot 2 pick -rot
-  begin
-    rot 1- -rot 2 pick 0>=
-  while
-    ( num n str len )
-    2dup ascii , strchr ?dup if
-      ( num n str len p )
-      1+ -rot
-      2 pick 2 pick -    ( num n p str len len1+1 )
-      dup -rot -         ( num n p str len1+1 len2 )
-      -rot 1-            ( num n p len2 str len1 )
-    else
-      0 0 2swap
-    then
-    $number if 0 then >r
-  repeat
-  3drop
-
-  ( num ) 
-  begin 1- dup 0>= while r> swap repeat
-  drop
-;
- 
-: parse-2int ( str len -- val.lo val.hi )
-  2 parse-ints
-;
-
   
 \ 
 \ 5.3.4.4 Mapping tools
diff --git a/forth/lib/string.fs b/forth/lib/string.fs
index f97db23..be77491 100644
--- a/forth/lib/string.fs
+++ b/forth/lib/string.fs
@@ -122,10 +122,42 @@
 \ string to number conversion
 \ -----------------------------------------------------
 
-: parse-hex ( str len -- value )
-  base @ hex -rot $number if 0 then swap base !
+\ parse ints "hi,...,lo" separated by comma
+: parse-ints ( str len num -- val.lo .. val.hi )
+  -rot 2 pick -rot
+  begin
+    rot 1- -rot 2 pick 0>=
+  while
+    ( num n str len )
+    2dup ascii , strchr ?dup if
+      ( num n str len p )
+      1+ -rot
+      2 pick 2 pick -    ( num n p str len len1+1 )
+      dup -rot -         ( num n p str len1+1 len2 )
+      -rot 1-            ( num n p len2 str len1 )
+    else
+      0 0 2swap
+    then
+    $number if 0 then >r
+  repeat
+  3drop
+
+  ( num )
+  begin 1- dup 0>= while r> swap repeat
+  drop
 ;
 
+: parse-2int ( str len -- val.lo val.hi )
+  2 parse-ints
+;
+
+: parse-nhex ( str len num -- values )
+  base @ >r hex parse-ints r> base !
+;
+
+: parse-hex ( str len -- value )
+  1 parse-nhex
+;
 
 \ -----------------------------------------------------
 \ miscellaneous functions