Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

signed integers with Oshon ???

Status
Not open for further replies.

MalcolmZA

New Member
Folks,

Does anyone have a trick or two up their sleeve for using 16 bit signed integers on Oshon Basic ?
I've got a small program to write in a PIC12F683 which uses a few negative numbers.
Using the SINGLE data type causes the memory to exceed the chip's 2k limit.

At the moment my only options seem to be using a different chip and buying a newer programmer.
Or using a different compiler.

Cheers
Malcolm ZA
 
If you post your code people may be able to suggest improvements that will enable it to fit in 2k.

Mike.
 
Hi Mike,

There are multiple places in the code where I subtract two variables and the result can be negative.
Oshon's only 16 bit data type is an unsigned word.. 0-65535.
They have a single precision floating point data type, but that consumes program and data space at an alarming rate.

Using a WORD variable, the result from 8 - 10 is 65534, where as the result using SINGLE data type gives a more predictable -2.

The only solution I see is to do a comparison prior to each subtraction, if A is > than B then reverse them in the equation
and set a flag bit to indicate the result is negative. Much like we did in the PLC's on the ark.

I was wondering if there's a more elegant solution.

Cheers
Malcolm ZA

1616239658254.png
 
Oshonsoft is horrendous for negative numbers... I use

if number and 0x8000 then set negative.. for Ints and 0x8000000 for longs..

Breut I don't really use Oshonsoft any more..
You're are quite right.
What I really like about Oshon is simulator and all the tools it has.
And the speed I can get simple programs running.
 
Last edited:
I was wondering if there's a more elegant solution.
Use another compiler.. Vladimirs compiler is very good but lacks several things... As I can do most of the stuff in assembly, I get around, but as I program in C as well... I tend to use that..

PicBasic Pro, Swordfish Basic, proton basic... All these are better compilers..

One is called great cow.... Very good but support was supposed to be ending!! However! it hasn't
 
I am a Swordfish Basic advocate. It's a very competent language, but limited to PIC18F-series micros. The Swordfish Special Edition is free to download and use with extremely generous limits on program size, to the point that many users never graduate to the full paid version.
 
I also vouch for swordfish basic. Fantastic compiler. Personally, knowing C gives you a huge selection of micros and compilers.

Mike.
 
I've just been looking int Great Cow.... WOW!! they cover ALL 8 bits in the pic and AVR and Tiny micros... They have an extensive library even colour TFT's... Both normal an Graphical compiler... I haven't tried the graphical compiler, but it looks decent....

BTW graphical ide means "click/select" programming... No knowledge required..
 
Great Cow Basic (GCB) is good, and just about the same efficiency as Oshonsoft. However, in exchange for giving negative integers, it seems to lack real (floating) variables.
I've converted the odd program from Oshonsoft to GCB, small ones, and program space used seems a tad better with GCB
Can't win them all...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top