Re: unsigned to float

From: silverdr_at_wfmh.org.pl
Date: Tue, 15 Oct 2019 10:51:52 +0200
Message-Id: <C5D58E29-389B-4E73-957D-A01144C6C4A1_at_wfmh.org.pl>
> Den 2019-10-14 kl. 19:05, skrev silverdr_at_wfmh.org.pl:
>> I need to do some FP calculations (one division, several multiplications) and wanted to use available BASIC routines. There's for example the GIVAYF routine that converts from 16 bit ints into FAC float format. Things work fine as long as I have "signed" ints on the input. What I need is "unsigned" so that I could use the whole 16 bit range. Suggestions appreciated.
>> 
> 
> Here is a possibly inefficient way to do it:
> 
> LDA #$01
> LDY #$00
> JSR $B391 ; Store a constant $0100 into FAC
> JSR $BC0C ; Transfer to AFAC
> LDY #high_byte
> JSR $B3A2 ; Store Y 0-255 into FAC
> JSR $BA30 ; Multiply FAC by AFAC, store in FAC
> JSR $BC0C
> LDY #low_byte
> JSR $B3A2
> JSR $B86A ; Add FAC with AFAC, store in FAC
> JSR $AABC ; Print FAC (for verify that the routine works)
> RTS

Thank you Anders. Right, this should work as a workaround for GIVAYF limitation. What I was hoping for though, is that there is an unsigned equivalent of GIVAYF or a special entry point somewhere in the ROM that would do the trick directly. It looks like an obvious thing to be somewhere there but OTOH ints are signed in BASIC so maybe there was no need for one.

-- 
SD! 
Received on 2020-05-29 23:08:40

Archive generated by hypermail 2.3.0.