Each instruction that have a wz effect specified will modify the z flag. Its state will remain unchanged untill the next instruction with the wz effect specified.
That mean that you can have several if_z lines that will all react to the last line that had the wz effect specification thus affecting it
This may be a better way to accomplish what you want.
mov dira, InputPins
:loop waitpne MediaPresentMask, MediaPresentMask ' wait for pin to go to low
and SlackSensor1Mask,ina wz
if_nz mov outa , #LED18 ' turn on LED18 if pin high
and SlackSensor2Mask,ina wz
if_nz mov outa , #LED20 ' turn on LED20 if pin high
jmp #:loop
Will the next wz effect specified, clear Z if that is the case?
The next wz will update the Z flag as per the instruction results. However, it is possible to "chain" flags by prefixing the wz instruction with if_z or if_nz as appropriate and construct AND/OR logic.
Still not working.
I hold button 1 in, and then press button 2 or 3.
pub main
cognew (@start,0)
dat
start org 0
mov dira, DirOfThePins
:loop waitpeq Sensor1, Sensor1 ' wait for pin1 to go to high
and Sensor2,ina wz
if_nz mov outa , LED18 ' turn on LED18 if pin2 high
and Sensor3,ina wz
if_nz mov outa , LED20 ' turn on LED20 if pin3 high
jmp #:loop
LED18 long %100_0000_0000_0000_0000
LED20 long %10_000_0000_0000_0000_0000
Sensor1 long %10 ' Pin 1, button input goes high
Sensor2 long %100 ' Pin 2, button input goes high
Sensor3 long %1000 ' Pin 3, button input goes high
DirOfThePins long %1_1111_0000_0000_0000_0000 ' Pins 20..16 as outputs , LEDS
It maybe something is also on the INA, making my AND statements bad. Therefore not setting the Z flag.
Whoops, you want the TEST instruction, not the AND instruction otherwise you're overwriting Sensor2/3 with the AND result.
You're also not resetting OUTA. Hmm...
start org 0
mov dira, DirOfThePins
:loop waitpeq Sensor1, Sensor1 ' wait for pin1 to go to high
test Sensor2,ina wz
muxnz outa, LED18 ' turn on LED18 if pin2 high
test Sensor3,ina wz
muxnz outa, LED20 ' turn on LED20 if pin3 high
jmp #:loop
DirOfThePins long %1_1111_0000_0000_0000_0000 ' Pins 20..16 as outputs , LEDS
LED18 long %0_0100_0000_0000_0000_0000
LED20 long %1_0000_0000_0000_0000_0000
Sensor1 long %0_0000_0000_0000_0000_0010 ' Pin 1, button input goes high
Sensor2 long %0_0000_0000_0000_0000_0100 ' Pin 2, button input goes high
Sensor3 long %0_0000_0000_0000_0000_1000 ' Pin 3, button input goes high
Comments
Each instruction that have a wz effect specified will modify the z flag. Its state will remain unchanged untill the next instruction with the wz effect specified.
That mean that you can have several if_z lines that will all react to the last line that had the wz effect specification thus affecting it
Will the next wz effect specified, clear Z if that is the case?
ericball, Ill checkout your code. THANK YOU VERY MUCH.
Mine was not working
I hold button 1 in, and then press button 2 or 3.
Therefore not setting the Z flag.
OK. I got some ideas. I'll be back.
You're also not resetting OUTA. Hmm...