How to do... If X = 1 AND Y = 1 Then ... in ASM
Chris_D
Posts: 305
Hi guys,
I sort of understand the CMP(s) function now and sort of understand the IF_C etc. functions and need to expand on them.· As the title shows...
·If X = 1 AND Y = 1 Then
is easy enough to understand in BASIC and perhaps even SPIN.· However, how would I go about this in ASM?
Chris
·
I sort of understand the CMP(s) function now and sort of understand the IF_C etc. functions and need to expand on them.· As the title shows...
·If X = 1 AND Y = 1 Then
is easy enough to understand in BASIC and perhaps even SPIN.· However, how would I go about this in ASM?
Chris
·
Comments
There are probably more optimal ways as well.
IF X = 1 THEN
IF Y = 1 THEN
In assembler this gives
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
-Phil
again a nice solution from you. But for a newbie you should have mentioned, that your solution will change the values of X and/or Y.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
you will see that the above requires 12 clocks to get to succeed or fail, while the djnz code takes 16 to get to succeed and 4 or 8 to get to fail. So the optimum choice will depend on the relative probabilities of the two cases.
-Phil
Fixed formatting.
Post Edited (Phil Pilgrim (PhiPi)) : 3/28/2009 9:06:30 PM GMT
I like your use of the djnz, however if you wanted something that followed more closely to ... If N=0 then ... or ... if N=1 then ... you could use the TJNZ or TJZ command.
·or..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Yup! But I think you meant, "If N<>0", rather than, "If N==1", right?
Actually, "If X==0 AND Y==0" is quicker with
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
-Phil
That's a lot of suggestions!· Thanks very much for all of them!
I will have to do some experimenting with the various examples so I can understand them but this should be enough to help me work out the structure for more complex decision making branching and such.
Chris