Computer Science, asked by Diya17530, 11 months ago

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 pesh20gathoni
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 :
  1. Load contents of memory location 2000 in register AL
  2. Copy contents of register AL in register AH
  3. Perform AND operation on register AL with 0F
  4. Assign 04 to CL Register
  5. Shift the contents of AH by executing SHR instruction using CL
  6. Perform OR operation on register AX with 3030
  7. Store the content of AX in memory location 3000

Similar questions