奇数位和偶数位
Problem statement:
问题陈述:
To find whether an 8 bits number is even or odd using 8085 Microprocessors.
使用8085微处理器查找8位数字是偶数还是奇数。
Given number is EVEN number if its lower bit is 0 i.e. low otherwise number is ODD.
如果给定数字的低位为0,则为偶数,否则为低。
To check whether the number is odd or even, we basically perform AND operation with 01 by using ANI instruction. If number is even then we will get 00 otherwise 01 in accumulator.
要检查数字是奇数还是偶数,我们基本上使用ANI指令对01执行AND操作。 如果数字为偶数,则累加器中将得到00,否则为01。
We use 11 to represent odd number and 22 to represent even number.
我们用11代表奇数,用22代表偶数。
Algorithm:
算法:
Load the accumulator with the first data.
向累加器加载第一个数据。
Perform AND operation with 01 on first data using ANI Instruction.
使用ANI指令对第一个数据执行01的AND操作。
Check if zero flag is set then set the value of accumulator to 22 otherwise 11 to accumulator.
检查是否设置了零标志,然后将累加器的值设置为22,否则将11设置为累加器。
Now load the result value in memory location.
现在将结果值加载到内存位置。
Program:
程序:
LDA 2050
ANI 01
JZ **
MVI A 11
JMP ***
** MVI A 22
***STA 3050
HLT
Observation:
观察:
INPUT:
2050:05
3050:11
OUTPUT:
3052:02
3053:00
Hence we successfully find whether 8 bits number is even or odd.
因此,我们成功地找到8位数字是偶数还是奇数 。
翻译自: https://www.includehelp.com/embedded-system/check-for-even-or-odd-8-bits-number-using-8085-microprocessor.aspx
奇数位和偶数位