Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:12 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Guide to writing portable reusable code

     Page 3 of 3    
Author Message
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 01:35pm 17 Sep 2020
Copy link to clipboard 
Print this post

  TassyJim said  
One of the biggest gotchas is signed integers of different bit length.

They are very common when talking to external devices.
Functions like
function signed16(x)
...snip

are handy things to have in the toolbox.


I did SgnX() for precisely this reason. I was dealing with the usual signed INTs (7,15,31) plus a couple of oddies (6 and the wasteful 9 a whole byte for an extra bit+sign! ).

It extends the sign bit of any length integer to make a MMBasic compliant version.

http://www.fruitoftheshed.com/MMBasic.Sign-Extend-an-Integer.ashx
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 01:41pm 17 Sep 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Ok, this is still a work in progress, and in particular I need to work on the examples, but I've been starting to put this together and wanted to share and give folks a chance to comment.


I did a similar article on FotS wiki. Might give you some input - or something to throw rotten fruit at
http://www.fruitoftheshed.com/MMBasic.Some-Hints-Tips-for-writing-efficient-code.ashx
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 01:55pm 17 Sep 2020
Copy link to clipboard 
Print this post

Hi mkopack73,

Your response prompted me to dust off a few books I have and do a little checking on base 0 for arrays. Commodore C64, Commodore Pet, TRS-80, GW-Basic, QuickBasic and Apple basic all default to base 0 for arrays. Also, judging from a BBC micro listing I have, so did that. As far as I can see the 8-bit machines did not have the OPTION BASE directive to alter that.

The earliest version of MMBasic on Geoff's site for the mono Maximite includes the OPTION BASE directive and it's been a part of MMBasic ever since as far as I know so that's not Peter's doing.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:53pm 17 Sep 2020
Copy link to clipboard 
Print this post

  Turbo46 said  The earliest version of MMBasic on Geoff's site for the mono Maximite includes the OPTION BASE directive and it's been a part of MMBasic ever since as far as I know so that's not Peter's doing.


Are we still talking about this ?

According to "The BASIC Handbook, 2nd Edition" it is part of ANSI Standard BASIC. Before that (?) it may have come from something called "Harris BASIC-V".

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:01pm 17 Sep 2020
Copy link to clipboard 
Print this post

  thwill said  ... ANSI Standard BASIC ...


https://en.wikipedia.org/wiki/True_BASIC:

"By the early 1980s, tens of millions of home computers were running some variation of Microsoft BASIC, which had become the de facto standard. The ANSI efforts eventually became pointless, as it became clear that these versions were not going to have any market impact in a world dominated by MS. Both versions were eventually ratified, but saw little or no adoption and the standards were later withdrawn."
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 03:35pm 17 Sep 2020
Copy link to clipboard 
Print this post

Yes Tom,

This whole base 0|1 business is a storm in a teacup. Over analysed, over discussed and over explained. Geoff's documents are all that are needed.

I just don't like being told that I am wrong when I know I'm not.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:46pm 17 Sep 2020
Copy link to clipboard 
Print this post

  Turbo46 said  I just don't like being told that I am wrong when I know I'm not.


Fair enough, I missed that occurrence, as it happens me neither
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 04:06pm 17 Sep 2020
Copy link to clipboard 
Print this post

  Turbo46 said  Yes Tom,

This whole base 0|1 business is a storm in a teacup. Over analysed, over discussed and over explained. Geoff's documents are all that are needed.

I just don't like being told that I am wrong when I know I'm not.

Bill


Huh, looks like you're right. I pulled out the old Commodore 64 User's Guide and looked it up and yeah, it was 0-indexed... I don't know why I have it in my head that it was 1-based... something from back in that era must have been for me to remember it this way. Pascal maybe (looking online, it looks like that might be what I'm thinking of, although it allows you to specify whatever you want for lower and upper bound indexes) ? Or an older version of BASIC I'm thinking of?   Ah, it's FORTRAN that uses 1-index! That's probably what I'm thinking of...

Something HAD to have been 1 based for the option to even come up...

Even then I think it's dumb that you dimension based on the LAST index vs the SIZE you want, but whatever.

It's still a concern when writing reusable code on this machine and still needs to be addressed in some way, so we haven't gotten rid of the reasoning for the section in the document I wrote, nor the mitigation approach suggested.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 04:13pm 17 Sep 2020
Copy link to clipboard 
Print this post

  CaptainBoing said  
  mkopack73 said  Ok, this is still a work in progress, and in particular I need to work on the examples, but I've been starting to put this together and wanted to share and give folks a chance to comment.


I did a similar article on FotS wiki. Might give you some input - or something to throw rotten fruit at
http://www.fruitoftheshed.com/MMBasic.Some-Hints-Tips-for-writing-efficient-code.ashx



Ah, nice.. Yes some good things in there!
 
Womble

Senior Member

Joined: 09/07/2020
Location: United Kingdom
Posts: 267
Posted: 09:13pm 17 Sep 2020
Copy link to clipboard 
Print this post

  Nimue said  Interesting thread on re "The BASIC Handbook"  << -- any other books from "back in the day" that are worth a look?

Nimue, you may find "Programming in GW-Basic" by P. K. McBride useful for ideas for your students.  Originally published in 1989, and reprinted a number of times since, it is available on Google Books and can be previewed there.  Not cheap, but you may have luck locating a used copy on ebay or abe books.

I just bought another copy on ebay as I cannot find my original.  It was the first programming book I bought circa 1990 when I acquired my first PC.  If I find my original copy I will PM you, but it is probably buried in one of the 40+ boxes of books in my loft.

Regards

Womble
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025