Test the least significant bit of the number. If it is 1, the number must be odd. If it 0 it must be even. To achieve this, place the value in B then use the ANI instruction:
ANI 01H
Thus if B is 01H, B is odd, otherwise it is even. Works for both positive and negative integers.
To separate odd and even numbers from an array of 10 numbers in the 8085 microprocessor, you can utilize a loop and the AND instruction. First, load each number from the array into a register and perform a bitwise AND operation with the value 1. If the result is 0, the number is even; if the result is 1, the number is odd. You can then store the odd numbers in one memory location and the even numbers in another, iterating through the entire array until all numbers are processed.
Lxi h, 2000h mov a,m mov b,a inx h mov a,m add b sta 2002h hlt
The ORA A instruction does not change the contents of the accumulator. It does, however, set flags to indicate something about the value of the accumulator. In particular, Z means the result is zero, N means it is negative, and P means it has an odd number of ones.
AND it to 1 and test for zero. All even numbers have 0 in the last bit.
27 is an odd number.
An odd number minus an odd number is an even number.
when an odd number is subtracted from an odd number the answer is an even number.
odd
it is an odd number
An odd number times an odd number is an odd number no matter which 2 odds you multiply.
an odd numberSubtracting an odd number from an even number will always result in an odd number.
It is an odd number.