6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:54 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Another MS BASIC problem
PostPosted: Thu Nov 03, 2016 8:35 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
So I'm tinkering around and compiling MS BASIC for different platforms.

https://github.com/mist64/msbasic
http://www.pagetable.com/?p=46

When I get to the Apple platform, I get an error. (using ca65)

Code:
.out .sprintf("%s", "inline.s")
.out .sprintf("    INPUTBUFFER: %d", INPUTBUFFER)

INLIN:
  .ifdef APPLE
        ldx     #$DD
INLIN1:
        stx     $33
        jsr     L2900
        cpx     #$EF
        bcs     L0C32
        ldx     #$EF
L0C32:
        lda     #$00
        sta     INPUTBUFFER,x
        ldx     #<INPUTBUFFER-1
        ldy     #>INPUTBUFFER-1
        rts
  .endif


The output is:

Code:
inline.s
    INPUTBUFFER: 512
    INPUTBUFFER-1: 511
inline.s(38): Error: Range error (-1 not in [0..255])


In my "defines_apple.s" I have:

Code:
; inputbuffer
INPUTBUFFER     := $0200


So since $0200 = 512 decimal, this should be OK. But from the error you can see it is not.

In a previous attempt, I would just add " + 256" to the problem to fix the "-1" error. But I don't really think that is a fix.

I get how +256 causes the value to roll over. But, *WHY* is that needed?

I guess where I'm confused is why it was done like that at all. I wonder how much of that source code is actually from Microsoft vs. a de-compile of a ROM file.

Any information is appreciated.

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 03, 2016 11:19 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Try adding some parantheses
Code:
        ldx     #<(INPUTBUFFER-1)
        ldy     #>(INPUTBUFFER-1)

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 03, 2016 11:26 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 411
Location: Minnesota
cbmeeks wrote:
Try adding some parantheses


That should work. The problem is that ca65 assigns the "<" operator a higher precedence than "-", so "<inputbuffer" is "<$0200", which is zero. Zero minus one is minus one.

You could also assign the value "inputbuffer-1" to a symbol and use that symbol instead (ie., "<symbol", ">symbol").


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 04, 2016 1:24 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
That worked!

Thanks!


I believe ca65 just doesn't like negative numbers like the following:

Code:
.ifdef CONFIG_SMALL
        lda     #-6
.else
        lda     #-9
.endif


So adding "+ 256" fixes those as well.

It's pretty amazing to be able to create seven different versions of MS BASIC for these platforms.

I've been organizing the code a bit..separating out the platforms, etc.

Now that's working, the next move is to test out one of these BASIC's on a real computer.

Next, start working on my own version for my SBC. Heck, it might be fun to make another version for the L-Star.

@Jac, you interested? :-)

Thanks!

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 12, 2016 12:49 am 
Offline
User avatar

Joined: Thu Jun 23, 2011 2:12 am
Posts: 229
Location: Rancho Cucamonga, California
cbmeeks wrote:
Now that's working, the next move is to test out one of these BASIC's on a real computer.

Next, start working on my own version for my SBC. Heck, it might be fun to make another version for the L-Star.

@Jac, you interested? :-)

Thanks!


The OSI emulator for L-Star already runs Microsoft Basic, and the KimStar project can be used to run Microsoft Basic (a different version) on a MicroKim. I think OSI Basic is one of the oldest MS-Basics you can build, and there are known bugs that were fixed later. But it does fit in 8K ROM. The Basic for the KIM-1 (and many other variants) needed 9 KB of ROM space IIRC. Obviously for the L-Star it doesn't make much of a difference :-)

My Github contains an "AppleSoftBasic.rom.bin" but I forgot where I got that (edit: it's probably the version that Vince Briel put into the latest versions of the Replica 1, see here and here). AppleSoft Basic for the Apple II was a rebranded version of Microsoft Basic, and is also one of the possible build targets of the MS Basic source code.

Sooo... I guess you've set yourself a task and it's already done :-)

===Jac


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: