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.

And or not etc in Oshonsoft

Status
Not open for further replies.
Hi,
I have lines like;
blah (apple OR banana OR orange OR peach)
and similarly:
blah (apple AND banana AND orange AND peach)

When using the suggestions does it matter if they are 'done' in different orders? In other words, if I first (apple OR banana) then (orange OR peach) then (res1 OR res2) or 'say' OR each fruit as I go along? Similarly for AND.
C.
I hate to bring this up as it confuses the situation. Some C code defines constants as binary then ANDs them together to pass to a function as a single byte.
E.G.
Code:
#define apple  0b1111110
#define banana 0b1111101
#define orange 0b1111011
#define peach  0b1110111

    return = somefunction(apple&pear);
Note also that C uses && and || when doing comparison operations.

Mike.
 
I hate to bring this up as it confuses the situation. Some C code defines constants as binary then ANDs them together to pass to a function as a single byte.
E.G.
Code:
#define apple  0b1111110
#define banana 0b1111101
#define orange 0b1111011
#define peach  0b1110111

    return = somefunction(apple&pear);
Note also that C uses && and || when doing comparison operations.

Mike.
Hi B,
I'm dealing with [& bitwise AND] and [| bitwise OR] and Oshonsoft Simulator, which uses it's own [BASIC] syntax. I can't read [c] very well.
C.
 
Hi,
I have just seen the examples of CASE and these =, <>, >, >=, <, <=. from Eric, and J, I'll have to look at them another time, but thanks.
C
 
hi C,
OSH list:
E

Dim tens As Byte
Dim units As Byte
Dim x As Byte

If tens > units Then
x = 0
Endif

If tens < units Then
x = 1
Endif

If tens <> units Then
x = 2
Endif

If tens = units Then
x = 3
Endif

If tens >= units Then
x = 4
Endif

If tens <= units Then
x = 5
Endif

If tens = > units Then 'OSH will not accept the '=' sign first
x = 6
Endif

If tens = < units Then 'OSH will not accept the '=' sign first
x = 7
Endif
 
Hi,
Can someone check the examples in the attachment in #27 please? I am not getting the results as shown.
C.
 
Hi Eric,
My mind is so blocked with OPERATORS, that I am not seeing the wood for the trees.
Thanks for your examples. Of course, I use these all of the time:facepalm:
C.

hi C,
OSH list:
E

Dim tens As Byte
Dim units As Byte
Dim x As Byte

If tens > units Then
x = 0
Endif

If tens < units Then
x = 1
Endif

If tens <> units Then
x = 2
Endif

If tens = units Then
x = 3
Endif

If tens >= units Then
x = 4
Endif

If tens <= units Then
x = 5
Endif

If tens = > units Then 'OSH will not accept the '=' sign first
x = 6
Endif

If tens = < units Then 'OSH will not accept the '=' sign first
x = 7
Endif
 
Hi,

bitwise AND
logical AND

logical NOT

I have a line with IF ((x AND y) AND (NOT (x AND z )))
How is this written in Oshonsoft?
EDITED!
C.
 
Last edited:
I gave that answer in post #15
Hi I,
I've re-read it and now it makes more sense.
dim res1 as byte
dim res2 as byte

res2 = a and b
res 1 = a and c
res1 = not res1

if res2 and res1 then......

I have difficulty with the bottom line. Would you 'spell' it out in English please, I can't understand e,g, [if res2] If res2 what?
C.
 
Oshonsoft does not accept parenthesis or bitwise operators or some values in If statements.
There have to be comparisons of variables or their values.

If res2 and res1 Then
means if both res2 res1 are non zero then...

can be written in Oshonsoft:
If res2 > 0 And res2 > 0 Then
 
can be written in Oshonsoft:
If res2 > 0 And res2 > 0 Then
Sorry.. correct if the arguments were boolean it would work..

Code:
dim aa as byte
dim ab as byte
dim ac as byte
dim res1 as byte
dim res2 as byte

res2 = aa and ab
res 1 = aa and ac
res1 = not res1

if res2>0 and res1>0 then
   PORTB = 255
else
   PORTB = 0 
endif

end
 
Hi,
I've written it in Oshonsoft. Can someone check the results in the Variables please?
I was unable to upload the file!
C.

'18LF2520 8MHz INT ANDNOTOR test 261417
'Define SIMULATION_WAITMS_VALUE = 1 'Comment in for SIM out for PIC
Define CLOCK_FREQUENCY = 8
Define SINGLE_DECIMAL_PLACES = 2
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08 'INT OSC
Define CONFIG2L = 0x1e 'BOR enabled
Define CONFIG2H = 0x00 'check
Define CONFIG3L = 0x00 'check
Define CONFIG3H = 0x80 '83?
Define CONFIG4L = 0x80 'Set for HVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
AllDigital
OSCCON = %01110010 'internal 8Mhz clock

Dim aa As Byte
aa = %10101011
Dim ab As Byte
ab = %00000110
Dim ac As Byte
ac = %00000011
Dim ad As Byte
ad = %00001010
Dim result1 As Byte
Dim result2 As Byte
Dim result3 As Byte

'IF ((aa and ab) AND (NOT (aa and ac ))) NOTE: [and is bitwise] [AND is Boolean] [NOT is Boolean]

result1 = aa And ab 'bitwise AND
result2 = aa And ac 'bitwise AND
result2 = Not result2 'Boolean NOT

If result1 > 0 And result2 > 0 Then 'Boolean AND
result3 = 255
Else
result3 = 0
Endif
End
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top