Write a program using 8086 assembly language that reads two separate digits as input from the keyboard and converts them to equivalent packed BCD number. For example, if the two digits are - '3' and '5' then the packed BCD will be (35)h .
Answers
Answered by
1
Answer:
DATA SEGMENT
MSG1 DB “ENTER NUMBER : $”
DIGIT1 DB ?
DIGIT2 DB ?
BCD DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT1,AL
MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT2,AL
MOV AH,DIGIT1
MOV AL,DIGIT2
MOV CL,4
ROL AH,CL
ADD AL,AH
MOV BCD,AL
CODE ENDS
END START
Explanation:
Assembly programming language: The assembly programming language is a low-level language which is developed by using mnemonics. The micro-controller or microprocessor can understand only the binary language like 0's or 1's therefore the assembler convert the assembly language to binary language and store it the memory to perform the tasks.
- Algorithm :
- Load contents of memory location 2000 in register AL
- Copy contents of register AL in register AH
- Perform AND operation on register AL with 0F
- Assign 04 to CL Register
- Shift the contents of AH by executing SHR instruction using CL
- Perform OR operation on register AX with 3030
- Store the content of AX in memory location 3000
Similar questions