Author: wmb Date: Mon Jan 16 22:05:14 2012 New Revision: 2827 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2827
Log: strings.fth - added new function $dnumber .
Modified: forth/lib/strings.fth
Modified: forth/lib/strings.fth ============================================================================== --- forth/lib/strings.fth Mon Jan 16 22:05:10 2012 (r2826) +++ forth/lib/strings.fth Mon Jan 16 22:05:14 2012 (r2827) @@ -5,7 +5,6 @@ headerless
d# 260 buffer: string2 -: save-string ( pstr1 -- pstr2 ) string2 "copy string2 ;
headers : $number ( adr len -- true | n false ) @@ -16,6 +15,22 @@ endcase ;
+headerless + +\ A single to double helper. +\ Sign extends the single if signed? is true +: ?n>d ( n signed? -- d ) if s>d else 0 then ; + +headers +: $dnumber ( signed adr len -- true | d false ) + $dnumber? ( signed 0 | signed n 1 | signed d 2 ) + case + 0 of drop true endof + 1 of swap ?n>d false endof + 2 of rot drop false endof + endcase +; + headerless : $hnumber ( adr len -- true | n false ) push-hex $number pop-base ; headers