Oxygen Basic
Information => Development => Topic started by: Brian Alvarez on June 07, 2019, 01:24:52 PM
-
Hello Charles, thanks for the update. I haven't finished testing but test are going well so far.
One thing i noticed though was that the benchmark times for string comparison and concatenation
went up...
This engine catched a few errors i had in my code, for example, i had:
local g = 0
instead of:
long g = 0
In a couple of the stock functions.
That is nice. :)
One comment, this still fails at compilation time:
print str(31 / 7 OR 3) chr(13, 10)
-
Thanks Brian.
O2 doesn't like doing bitwise operations on float expressions. So none of these work:
'print str(31 / 7 OR 3) chr(13, 10)
'print 7.0 or 3
'int a= 7.0 or 3
'float a=7.0 or 3
but performing an integer division '\' instead of '/' will make your example work:
print str(31 \ 7 OR 3) chr(13, 10)
-
I see. Okay, the error description is not very intuitive but it makes sense.
I will then re-implement my aproach hoping the new update behaves better
with my code. :)
I will break statements and pre-compute them manually part by part. This will
make statements mostly unreadable by humans but, this way i can implement my
new feature... custom operators. Hopefully this will not explode in my face. :)
-
Maybe i found an issue... this outputs 7:
print 4 OR 3 CHR(13, 10)
This outputs 4:
print floor(31 / 7) CHR(13, 10)
This complains about the same issue:
print str(floor(31 / 7) OR 3) CHR(13, 10)
I am converting the division to integer prior to using th OR operator in it...
Im not sure where the issue is.
Added:
This works fine though....
FUNCTION flooor(double v) as int
return floor(v)
end function
print (flooor(31 / 7) OR 3) CHR(13, 10)
-
Maybe the issue that is sometimes preventing my routines from working properly is related to this?...
-
Division is a processor-intensive successive approximation, so it's best avoided wherever possible. It's similar to doing school detention-time long division. Even CPUs find it hard :)
However, I'm testing a patch to down-convert from float to integer accumulator , before a bitwise operation is attemted. This would apply to NOT AND OR XOR
-
Yes, it is Charles, but I have to test and get it to work for those cases where it is indispensable. :)
I havent seen the code for Oxygen, do you mind if i take a look at the part that works with operators? I am no expert at assembly,
but i know it enough. Does Oxygen compile with Oxygen? If so, maybe i can give you a hand. I rather work on Oxygen than
in that same area of PluriBASIC. In fact, if i finish that part, nothing would stop me from generating executables directly.... except
time maybe.
Anyway, i would like to add support for EQV, IMP, SHR and SHL, as well as adding a way to create custom operators and make them
work on 64 bit variables.
-
Sure.
Take a look at OXSC\pars.inc identop()
I'll add SHL SHR ROL ROR equivalent to << >> <<< >>>
wr=tword(s,i) : i=swd+lenw
if wr="and"
n=33 : prl=3 : goto idop
endif
if wr="or"
n=34 : prl=1 : goto idop
endif
if wr="xor"
n=35 : prl=2 : goto idop
endif
if wr="shl"
n=74 : prl=5 : goto idop
endif
if wr="shr"
n=75 : prl=5 : goto idop
endif
if wr="rol"
n=76 : prl=5 : goto idop
endif
if wr="ror"
n=77 : prl=5 : goto idop
endif
endif
endif
What are EQV and IMP? I dont think anyone uses them. Best avoided for code clarity.
-
With a few adjustments we can also have pow and mod as operators, as well as functions, without conflicting syntax:
a=asclc(a)
select a
case 0x61,0x6d,0x6f,0x70,0x72,0x73,0x78 'a m o p r s x
i=k
wr=tword(s,i) : i=swd+lenw
if (lenw<2)or(lenw>3)
goto idop 'NONE OF THE FOLLOWING
elseif wr="and"
n=33 : prl=3
elseif wr="or"
n=34 : prl=1
elseif wr="xor"
n=35 : prl=2
elseif wr="shl"
n=74 : prl=5
elseif wr="shr"
n=75 : prl=5
elseif wr="rol"
n=76 : prl=5
elseif wr="ror"
n=77 : prl=5
elseif wr="pow"
n=94 : prl=8
elseif wr="mod"
n=93 : prl=7
endif
end select
endif
-
First time I've seen CASE and ELSEIF in the same bed together. The best of both flow structures working together.
-
EQV and IMP are bitwise operators, but I would like to use them as logical operators. If AND and OR are & and |, then EQV and IMP would be like && and ||... as far as i can remember it was like that. But i dont remember very well.
-
Looks wierd to me. See the truth table.
https://stackoverflow.com/questions/927119/what-do-the-logical-functions-imp-and-eqv-do-in-vb6-has-anyone-found-a-real-wor
-
Look at this:
-
The bitwise part, i dont care. I have never used them for that. Just plan logical or/and would do.
-
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/imp-operator
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/eqv-operator
I can understand the use of EQV
bitwise:
A=not(B xor C)
logical:
if (B)xor(C) then A=0 else A=1