Page 1 of 1

Found a bug or am I wrong (or is it already known)?

Posted: Fri Feb 15, 2019 6:47 pm
by Ruud
I downloaded the (what I think) original source code from two different sites. Here I found this:

LAB_2DB6
LDA Itempl ; get temporary integer low byte
LDY Itemph ; get temporary integer high byte
CPY #<Ram_base+1 ; compare with start of RAM+$100 high byte
BCC LAB_GMEM ; if too small go try again

It is the line starting with CPY that puzzles me, shouldn't it have been:

CPY #>Ram_base+1 ; compare with start of RAM+$100 high byte

???

Re: Found a bug or am I wrong (or is it already known)?

Posted: Fri Feb 15, 2019 8:46 pm
by GARTHWILSON
It looks like you're right.

Ruud, to keep the white space, you need to put [code] and [/code] around the code. Also, replace tabs with spaces, since the forum software messes them up sometimes. You might need to copy and paste into a text editor to see what you're doing better, then copy from there and paste to the forum when you're happy with it. What you'll get is as shown here:

Code: Select all

LAB_2DB6
        LDA     Itempl          ; get temporary integer low byte
        LDY     Itemph          ; get temporary integer high byte
        CPY     #<Ram_base+1    ; compare with start of RAM+$100 high byte
        BCC     LAB_GMEM        ; if too small go try again

It is the line starting with CPY that puzzles me, shouldn't it have been:

        CPY     #>Ram_base+1    ; compare with start of RAM+$100 high byte

???

Re: Found a bug or am I wrong (or is it already known)?

Posted: Sat Feb 16, 2019 8:53 am
by Klaus2m5
This section of the code is supposed to prevent the user from doing really stupid things:
1. Ram_top is configured smaller then Ram_base
2. The memory test does not find any memory above Ram_base
3. The user enters too little memory at the "Memory size ?" prompt

Since Ram_base should be page aligned the compare is with $01 and should always fall through which means the bug disables the sanity check.

I will fix the code in my patched up version with credit to Ruud.

Re: Found a bug or am I wrong (or is it already known)?

Posted: Sun Feb 17, 2019 5:00 pm
by Ruud
GARTHWILSON wrote:
Ruud, to keep the white space, you need to put [code] and [/code] around the code. ....
You are never too old to learn something. Thank you!

Re: Found a bug or am I wrong (or is it already known)?

Posted: Sun Feb 17, 2019 5:07 pm
by Ruud
Klaus2m5 wrote:
I will fix the code in my patched up version with credit to Ruud.
Herzlichen Dank!

Re: Found a bug or am I wrong (or is it already known)?

Posted: Mon Jan 13, 2020 1:40 pm
by Klaus2m5
Fixed as proposed in my patched up version of EhBASIC 2.22p5 on GitHub.
https://github.com/Klaus2m5/6502_EhBASI ... er/patched