Page 3 of 3

Re: EhBasic memory locations

Posted: Mon Nov 28, 2016 9:23 am
by Klaus2m5
Quote:
One last issue I've got, FRE(0) reports a negative number (-24xxx something) when I give EhBasic more RAM than configured now.
The problem is in LAB_AYFC. The resulting unsigned 16 bit integer is converted as a 16 bit signed integer to a 32 bit float. I will fix that later. I have to go now!

Re: EhBasic memory locations

Posted: Mon Nov 28, 2016 4:17 pm
by barrym95838
ArnoldLayne wrote:
... One last issue I've got, FRE(0) reports a negative number (-24xxx something) when I give EhBasic more RAM than configured now.
No worries, mate! Like Klaus said, it's just a signed 16-bit integer thing.
fre0.JPG
Mike B.

Re: EhBasic memory locations

Posted: Mon Nov 28, 2016 7:40 pm
by ArnoldLayne
Alright, I'll crank it up! :-)

Re: EhBasic memory locations

Posted: Tue Nov 29, 2016 10:51 am
by Klaus2m5
The first version of this patch did not work, as it made logical operations with compare result = true (-1) impossible. To print the proper value for free bytes you should use

Code: Select all

? FRE(0)-(FRE(0)<0)*$10000
When FRE(0) returns a negative value $10000 is added.

If you really want to deviate from the beaten path, you can add a routine to convert unsigned integers and jump to it from the functions that you want to respond with an unsigned number. Possible candidates are FRE(), SADD(), VARPTR() and DEEK().

Code: Select all

; save and convert unsigned integer AY to FAC1

LAB_UAYFC
      LSR   Dtypef            ; clear data type flag, $FF=string, $00=numeric
      STA   FAC1_1            ; save FAC1 mantissa1
      STY   FAC1_2            ; save FAC1 mantissa2
      LDX   #$90              ; set exponent=2^16 (integer)
      SEC                     ; always positive
      JMP   LAB_STFA          ; set exp=X, clear FAC1_3, normalise and return


Re: EhBasic memory locations

Posted: Sun Dec 11, 2016 8:13 pm
by ArnoldLayne
Ok, since it's only a signedness thing, I'm ok with as it is. I was initially concerned that FRE(0) returning a negative value might be because something in my memory configuration is still broken. However, I am happy that this is not the case and the weird behaviour I got from EhBasic were due to some strange hardware issues which are fixed (well, sort of) now.

So, thank you very much for helping me out.
I'll be moving on and implementing LOAD and SAVE. There will be questions. :-)