EhBasic memory locations

A forum for users of EhBASIC (Enhanced BASIC), a portable BASIC interpreter for 6502 microcomputers written by Lee Davison.
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

Re: EhBasic memory locations

Post 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!
6502 sources on GitHub: https://github.com/Klaus2m5
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: EhBasic memory locations

Post 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.
ArnoldLayne
Posts: 109
Joined: 28 Dec 2014
Location: Munich, Germany
Contact:

Re: EhBasic memory locations

Post by ArnoldLayne »

Alright, I'll crank it up! :-)
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

Re: EhBasic memory locations

Post 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

6502 sources on GitHub: https://github.com/Klaus2m5
ArnoldLayne
Posts: 109
Joined: 28 Dec 2014
Location: Munich, Germany
Contact:

Re: EhBasic memory locations

Post 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. :-)
Post Reply