ZX80 comparators with negative ressults...
ZX80 comparators with negative ressults...
Hi, I was messing around with some Tiny BASIC codes and porting them to ZX80.. and found that <,>,=,<> operators used as comparators gives "-1" if true as a result
PRINT 5<6 gives -1
I tried with ZX81 and result is 1(positive) if condition is true. ZX80 4K BASIC has some relevant diferencies with later Sinclair Basics as logic operators being bitwise or arrays being base 0, but I never expected this , and missed it from the manual, if it is documented there.
I guess I can fix it using PRINT (-(5<6)) OR PRINT ABS(5<6), both are slow and memory consuming, remember ABS is not tokenized on ZX80 and brackets are mandatory.
is there any logical explanation or justification for this behavior, was it common ? and do you know a better workaround?
Ps. Tiny Basic is somehow as limited (or worst) than ZX80 basic. 16bit signed integers only. uses a lot abbreviations and multi sentence lines but is not so difficult to make it work on ZX80.. I guess..
PRINT 5<6 gives -1
I tried with ZX81 and result is 1(positive) if condition is true. ZX80 4K BASIC has some relevant diferencies with later Sinclair Basics as logic operators being bitwise or arrays being base 0, but I never expected this , and missed it from the manual, if it is documented there.
I guess I can fix it using PRINT (-(5<6)) OR PRINT ABS(5<6), both are slow and memory consuming, remember ABS is not tokenized on ZX80 and brackets are mandatory.
is there any logical explanation or justification for this behavior, was it common ? and do you know a better workaround?
Ps. Tiny Basic is somehow as limited (or worst) than ZX80 basic. 16bit signed integers only. uses a lot abbreviations and multi sentence lines but is not so difficult to make it work on ZX80.. I guess..
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
- 1024MAK
- Posts: 5145
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX80 comparators with negative ressults...
As far as the ZX80, ZX81 and ZX Spectrum BASICs are concerned, anything other than zero is ‘true’. Including negative numbers.
Mark
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: ZX80 comparators with negative ressults...
Yes. But I am talking about the result of a true expression ...
LET A=A+(C=B) won't work the same on ZX80 than on ZX81.. let alone logical operators as they are bitwise..
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
- 1024MAK
- Posts: 5145
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX80 comparators with negative ressults...
Setting aside the logical operators. Yes, I agree, the returned value may be inconsistent with what people expect. And yes, it means some code cannot be transferred between the different machines without modification.
It’s certainly not the first time that I have seen a BASIC return -1 for true though. Microsoft BASIC as used on the Commodore 64 returns -1 for true and zero for false.
You could argue that it’s the ZX81 that’s non-standard.
I prefer the ZX80’s bit wise logical operators.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: ZX80 comparators with negative ressults...
Thomson To7/70 (TO/MO series/ Basic 1 Microsoft)
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: ZX80 comparators with negative ressults...
You do boolean testing and the result is either TRUE or FALSE. If you want a universal code you should test with ABS ( A>1)
Re: ZX80 comparators with negative ressults...
Wow.. really surprised!!!!!
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
Re: ZX80 comparators with negative ressults...
Commodore basic is Microsoft basic.. so I guess there is not a surprise there.
I guess MSX basic report true as -1 too?
Tiny Basic was a kind of a "open source" proyect in response to the Microsoft basic being heavy and expensive.. they used the (c)copyleft and wrong reserved marks.... as far as I saw tiny used 1 for true.. Sinclair BASIC was a later "renegade" in that matter.. I wouldn't be surprised that they had several coincidences...
I guess MSX basic report true as -1 too?
Tiny Basic was a kind of a "open source" proyect in response to the Microsoft basic being heavy and expensive.. they used the (c)copyleft and wrong reserved marks.... as far as I saw tiny used 1 for true.. Sinclair BASIC was a later "renegade" in that matter.. I wouldn't be surprised that they had several coincidences...
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
- 1024MAK
- Posts: 5145
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX80 comparators with negative ressults...
Just for the record, a ZX Spectrum produces the same results as the ZX81 results (as shown above).
Acorn 6502 BBC BASIC (tested on an Acorn Electron) and Amstrad CPC BASIC (tested on a CPC 6128) produce the same results as Microsoft BASIC on a Commodore 64 or PET.
Mark
Acorn 6502 BBC BASIC (tested on an Acorn Electron) and Amstrad CPC BASIC (tested on a CPC 6128) produce the same results as Microsoft BASIC on a Commodore 64 or PET.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
- 1024MAK
- Posts: 5145
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX80 comparators with negative ressults...
A Sinclair QL running SuperBASIC produces the same results as the ZX81 results (as shown above).
Mark
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.