Saturday, May 30, 2009

Write a subroutine of 8086 assembly language that coverts a 2 digit number entered by keyboard to equivalent binary in DX register

Write a subroutine of 8086 assembly language that coverts a 2 digit number entered by keyboard to equivalent binary in DX register, provided both the entered digits are numeric. Test this subroutine through an assembly program. The main program must get the result in DX register and put it in a memory location.


DATA SEGMENT
MSG 1 DB ‘ENTER 2 DIGIT NUMBER $’
PORT DW?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AH, 09H
MOV DX, OFFSET MSG1
INT 21H ; TO PRINT MSG1
MOV AH, 01H
INT 21H
SUB AL, ‘0’
MOV BH, OAH
MVL BH
MOV BL, AL
MOV AH, 01H
INT 21H
SUB AL, ‘0’
ADD BL, AL
OUT PORT, BL

CODE ENDS
END START

1 comment: