Академический Документы
Профессиональный Документы
Культура Документы
LEDCOD: PUSH H
LXI H, CODE
ADD L
MOV L, A
MOV A, M
STAX B
POP H
RET
CODE: 3F
06
5B
4F
66
6D
7D
07
7F
6F
00
BINARY TO ASCII AND ASCII TO BINARY CODE CONVERSION:
The American Standard Code for Information Interchange (ASCII) is used commonly in data communication.
It is a seven-bit code and its 128 combinations are assigned different alphanumeric characters. The ASCII keyboard
is a standard input device for entering programs in a microcomputer. When an ASCII character is entered, the
microprocessor receives the binary equivalent of the ASCII hex number, For example, when the ASCII key for digit 9
is pressed, the microprocessor receives the binary equivalent of 39H which must be converted to binary 1001 for
arithmetic operations. Similarly, to display a digit 9 at the terminal, the microprocessor must send out the ASCII hex
code (39H). These conversions are done through software.
Binary to ASCII hex code conversion.
LXI SP, STACK
LXI H, XX50H
LXI D, XX60H
MOV A, M
MOV B, A
RRC
RRC
RRC
RRC
51
CALL LOOP
STAX D
INX D
MOV A, B
CALL LOOP
STAX D
HLT
LOOP: ANI 0FH
CPI 0AH
JC CODE
ADI 07H
CODE: ADI 30H
RET
ASCII Hex to binary conversion:
To convert an ASCII Hex number into its binary equivalent, a calling program places the ASCII number in the
accumulator, and the subroutine should pass the conversion back to the accumulator.
Example:
ASCBIN : SUI 30H
CPI 0AH
RC
SUI 07H
RET
BCD ARITHMETIC OPERATIONS
BCD ADDITION:
The addition of two BCD numbers may not represent an appropriate BCD value. The microprocessor cannot
recognize BCD numbers. It adds any two numbers in binary. In BCD addition, any number larger than 9 is invalid
and needs to be adjusted by adding 6 in binary.
DAA
A special instruction called DAA (Decimal Adjust Accumulator) performs the function of adjusting a BCD
sum in the 8085 instruction set. This instruction uses the Auxiliary Carry flip-flop to sense that the value of the least
four bits is larger than 9 and adjusts the bits to the BCD value. Similarly, it uses the Carry flag to adjust the most
significant four bits.
BCD SUBTRACTION:
Two BCD numbers can be subtracted by using the procedure of 100’s complement, similar to 2’s complement.
The 100’s complement of a subtrahend can be added to a minuend. For example, 82-48=34 can be performed as
follows:
100’s complement of subtrahend 52 (100-48)
Add minuend +82
------------
134 The sum is 34 and carry is ignored.
------------
52