Jump to content
IGNORED

Variables of 4


atari2600land

Recommended Posts

If (variable&%00000011) = 0 is true. If either bits 0 or 1 are set, it's not a multiple of 4. You'd need to check if the variable = 0 directly if you wanted to skip that condition.

 

In inline assembly, this is accomplished by

LDA variable

BEQ Is_Zero ;to skip the =zero condition

AND #%00000011 ;throw away the 6 upper bits

BEQ Is_Multiple_Of_Four ;if true

or

BNE Is_Not_Multiple_Of_Four ;if false

Edited by Nukey Shay
Link to comment
Share on other sites

Instead of trying to use this:

 

  if (a && %00000011)=0 && u{0} && v=1 then x=2
  if (e && %00000011)=0 && u{0} && v=1 then x=2
  if (i && %00000011)=0 && u{0} && v=1 then x=2
  if (m && %00000011)=0 && u{0} && v=1 then x=2

 

 

 

What about using this instead:

 

  temp5 = (a & %00000011) : if !temp5 && u{0} && v=1 then x=2
  temp5 = (e & %00000011)  : if !temp5 && u{0} && v=1 then x=2
  temp5 = (i & %00000011)  : if !temp5 && u{0} && v=1 then x=2
  temp5 = (m & %00000011)  : if !temp5 && u{0} && v=1 then x=2

Edited by Random Terrain
Link to comment
Share on other sites

Hmm...the use of multiple conditions on the same line might be the problem? Maybe try enclosing the entire expression between parenthesis?

 

ex:

if ((a&%00000011)=0) && u{0} && v=1 then x=2

That doesn't want to compile either (using either type of AND).

Link to comment
Share on other sites

if (a&%00000011)<1 && u{0} && v=1 then x=2 :?

 

This is getting nuts.

That doesn't seem to work either, but both of these compile:

 

temp5 = (a & %00000011) : if temp5=0 && u{0} && v=1 then x=2

temp5 = (e & %00000011) : if temp5=0 && u{0} && v=1 then x=2

temp5 = (i & %00000011) : if temp5=0 && u{0} && v=1 then x=2

temp5 = (m & %00000011) : if temp5=0 && u{0} && v=1 then x=2

 

 

 

 

temp5 = (a & %00000011) : if !temp5 && u{0} && v=1 then x=2

temp5 = (e & %00000011) : if !temp5 && u{0} && v=1 then x=2

temp5 = (i & %00000011) : if !temp5 && u{0} && v=1 then x=2

temp5 = (m & %00000011) : if !temp5 && u{0} && v=1 then x=2

Edited by Random Terrain
Link to comment
Share on other sites

Hang on a second...you are constantly rechecking the same conditions. Remove them from the sequence...

 

 

  if !u{0} then skip_the_rest
 if v<>1 then skip_the_rest
 if (a&3)=0 then set_x
 if (e&3)=0 then set_x
 if (i&3)=0 then set_x
 if (m&3)<>0 then skip_the_rest
set_x:
 x=2
skip_the_rest:

Edited by Nukey Shay
Link to comment
Share on other sites

My mistake! I did find this from a few years ago :-

 

http://www.atariage.com/forums/topic/100416-conditional-statements-with-score/page__view__findpost__p__1218564

 

By SeaGtGruff saying that bitwise operators don't work in "if" statements. However I don't know if that behaviour has been changed.

If you use the latest build, bitwise AND is supported in "if" statements with some restrictions. For example, you can do "if a & 3 then" but cannot check it against a value. To invert the condition, you need to use "else."

 

This should work:

 if !u{0} then skip_the_rest
 if v<>1 then skip_the_rest
 if a&3 then skip_the_rest else set_x
 if e&3 then skip_the_rest else set_x
 if i&3 then skip_the_rest else set_x
 if m&3 then skip_the_rest
set_x
 x=2
skip_the_rest

Link to comment
Share on other sites

Can you !a&3 :? That would avoid adding the extra "else" code.

Not currently. bB can evaluate a single bit or a condition between two simple operands and can't currently do anything with those operands (like invert them as you suggest.) Someday I may allow full expressions within conditions as this will vastly improve the language.

 

Anyway, the code may be rewritten as follows, I think:


 if !u{0} then skip_the_rest
 if v<>1 then skip_the_rest
 if a&3 || e&3 || i&3 || m&3 then skip_the_rest
 x=2
skip_the_rest

However, I am not sure if this will save any space over the above code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...