checking two input pin states in assembly
ionymous
Posts: 29
I am coding in assembly.
I have two input pins I am interested in, lets say pin 5 and 6.
The other inputs are in unknown states... I have not tied them to ground, and many are for peripherals since I'm using a development board.
I'm using "and" to mask the inputs I care about, and then "xor" with "wz" to determine if the bits I care about are set.
Here's an example:
Is this a good way to do it, or is there a better way?
Thanks
Ion
I have two input pins I am interested in, lets say pin 5 and 6.
The other inputs are in unknown states... I have not tied them to ground, and many are for peripherals since I'm using a development board.
I'm using "and" to mask the inputs I care about, and then "xor" with "wz" to determine if the bits I care about are set.
Here's an example:
mov temp1, ina 'Get the current inputs and temp1, bothInputs 'Mask the inputs I care about xor temp1, bothInputs wz,nr 'Check if both inputs are high if_z jmp #BothInputsAreHigh xor temp1, justInput5 wz,nr 'Check if just input 5 is high if_z jmp #JustInput5IsHigh bothInputs long %110_0000 justInput5 long %010_0000 temp1 long 0
Is this a good way to do it, or is there a better way?
Thanks
Ion
Comments
The test for both inputs by the Carry works only with 2 inputs, if you have more bits, then your methode with xor is the right one.
And be aware that:
test maskreg,ina is not the same as test ina,maskreg
the second does not work as expected, because the INA has to be the source register.
Andy