From 7cfc81639453fcbd04d4f689a7e35fc892d7c0eb Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 11 Aug 2020 23:54:25 +0000 Subject: [PATCH] dsforth: added forgotten S>F FossilOrigin-Name: 3405472e6a5460286cc55b6e4e2b5c56126e8950f0c685ae38b31b39962a5ff2 --- dsforth/math_float.zas | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/dsforth/math_float.zas b/dsforth/math_float.zas index 57d3a8d..caf3774 100644 --- a/dsforth/math_float.zas +++ b/dsforth/math_float.zas @@ -40,6 +40,7 @@ $FORTH_WORD FDEPTH $FORTH_END_WORD FDEPTH +$IF 0 $FORTH_CODE_WORD (FCALL) ;; k8 ;; ( cmd -- ) @@ -53,6 +54,7 @@ $FORTH_CODE_WORD (FCALL) pop bc jp i_next $FORTH_END_CODE_WORD (FCALL) +$ENDIF dsforth_call_calc_code: pop hl @@ -241,12 +243,12 @@ $FORTH_CODE_WORD F2DUP $FORTH_END_CODE_WORD F2DUP -;; maximum length of the string "CSTR>F" can parse +;; maximum length of the string "STR>F" can parse ;; we need to use internal buffer, hence the limitation DSFORTH_FP_MAX_STR_LEN equ 24 ;; very slow string-to-fp -$FORTH_CODE_WORD CSTR>F +$FORTH_CODE_WORD STR>F ;; k8 ;; ( addr count -- ) pop de ; length @@ -303,7 +305,7 @@ $FORTH_CODE_WORD CSTR>F ld hl,#1330 ld (.tempbuf),hl jr .doit -$FORTH_END_CODE_WORD CSTR>F +$FORTH_END_CODE_WORD STR>F ;; this converts floating number from the top @@ -311,7 +313,7 @@ $FORTH_END_CODE_WORD CSTR>F ;; it should be safe to call it, but don't use this if F>S or F>U are suffice ;; also note ROM bug: the stack may contain one trash value on exit ;; this routine takes care of that bug -$FORTH_CODE_WORD F>CSTR +$FORTH_CODE_WORD F>STR ;; k8 ;; ( -- addr count ) ;; puts the string as counted string into internal buffer @@ -376,7 +378,7 @@ dsforth_fp_print_buffer_addr equ $-2 ;; print-fp will never use more than 14 bytes, but let's play safe dsforth_fp_print_buffer: defs 18,0 -$FORTH_END_CODE_WORD F>CSTR +$FORTH_END_CODE_WORD F>STR $FORTH_CODE_WORD U>F @@ -410,6 +412,35 @@ $FORTH_CODE_WORD F>U $FORTH_END_CODE_WORD F>U +$FORTH_CODE_WORD S>F +;; k8 +;; ( u -- ) +;; put signed int to calculator stack + exx + pop bc + bit 7,b + jr nz,.negative + call #2D2B ; STACK_BC + exx + jp i_next +.negative: + ; negate it + ld de,bc + ld hl,0 + and a + sbc hl,de + ld bc,hl + call #2D2B ; STACK_BC + ; and negate on the calculator stack + exx + push bc + rst #28 + defb #1B ; neg + defb #38 ; end-calc + pop bc + jp i_next +$FORTH_END_CODE_WORD S>F + $IF 0 ;; this clamps value to [-32768..32767] range $FORTH_WORD F>S -- 2.11.4.GIT