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

A forum for users of EhBASIC (Enhanced BASIC), a portable BASIC interpreter for 6502 microcomputers written by Lee Davison.
Post Reply
User avatar
Ruud
Posts: 259
Joined: 12 Dec 2003
Location: Heerlen, NL
Contact:

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

Post 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

???

Code: Select all

    ___
   / __|__
  / /  |_/     Groetjes, Ruud 
  \ \__|_\
   \___|       URL: www.baltissen.org

User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

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

Post 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

???
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

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

Post 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.
6502 sources on GitHub: https://github.com/Klaus2m5
User avatar
Ruud
Posts: 259
Joined: 12 Dec 2003
Location: Heerlen, NL
Contact:

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

Post 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!

Code: Select all

    ___
   / __|__
  / /  |_/     Groetjes, Ruud 
  \ \__|_\
   \___|       URL: www.baltissen.org

User avatar
Ruud
Posts: 259
Joined: 12 Dec 2003
Location: Heerlen, NL
Contact:

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

Post by Ruud »

Klaus2m5 wrote:
I will fix the code in my patched up version with credit to Ruud.
Herzlichen Dank!

Code: Select all

    ___
   / __|__
  / /  |_/     Groetjes, Ruud 
  \ \__|_\
   \___|       URL: www.baltissen.org

Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

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

Post by Klaus2m5 »

Fixed as proposed in my patched up version of EhBASIC 2.22p5 on GitHub.
https://github.com/Klaus2m5/6502_EhBASI ... er/patched
6502 sources on GitHub: https://github.com/Klaus2m5
Post Reply