English, asked by talhanadeem02, 9 months ago

Write a program using 8086 assembly language (with proper comments) that accepts four characters entered using the keyboard. It checks if all these characters are decimal digits. If all of them are decimal digits, then program calculates the equivalent hexadecimal number on the screen. Make suitable assumptions, if any.

Answers

Answered by saptarshi005
1

Explanation:

DATA SEGMENT

MSG1 DB 10,13,’ENTER NUMBER HERE :- $’

MSG2 DB 10,13,’ENTERED VALUE IS : $’

MSG3 DB 10,13,’ENTERED VALUE IS NOT A NUMBER ! $’

MSG4 DB 10,13,’ENTERED VALUE NOT A 4 DIGIT VALUE ! $’

MSG5 DB 10,13,’ENTER NUMBER IN BINARY IS :- $’

FLAG DB 0H

NUM  DW ?

RES  DB 20 DUP (‘$’)

P1 LABEL BYTE

M1 DB 0FFH

L1 DB ?

P11 DB 0FFH DUP (‘$’)

DATA ENDS

DISPLAY MACRO MSG

MOV AH,9

LEA DX,MSG

INT 21H

ENDM

CODE SEGMENT

ASSUME CS:CODE,DS:DATA

START:

MOV AX,DATA

MOV DS,AX

DISPLAY MSG1

LEA DX,P1

MOV AH,0AH

INT 21H

DISPLAY MSG2

DISPLAY P11

CHECK1: CMP L1,04H

JNE NOT4D

LEA SI,P11

MOV CH,0

MOV CL,L1

DEC CL

CHECK2:

CMP [SI],30H

JB INCFLAG

CMP [SI],3AH

JB NOINC

INCFLAG:

INC FLAG

NOINC:

INC SI

LOOP CHECK2

CHECK3: CMP FLAG,0H

JNE NOTNUM

CONV:

LEA SI,P11

MOV AX,0H

MOV AL,[SI]

SUB AL,30H

MOV DX,1000

MUL DX

MOV NUM,AX

INC SI

MOV AX,0H

MOV AL,[SI]

SUB AL,30H

MOV DL,100

MUL DL

ADD NUM,AX

INC SI

MOV AX,0H

MOV AL,[SI]

SUB AL,30H

MOV DL,10

MUL DL

ADD NUM,AX

INC SI

MOV AX,0H

MOV AL,[SI]

SUB AL,30H

ADD NUM,AX

INC SI

MOV AX,NUM

LEA SI,RES

CALL HEX2BIN

DISPLAY MSG5

LEA DX,RES

MOV AH,9

INT 21H

JMP DONE

NOTNUM:

DISPLAY MSG3

JMP DONE

NOT4D:

DISPLAY MSG4

DONE:

MOV AH,4CH

INT 21H

CODE ENDS

HEX2BIN PROC NEAR

MOV CX,0

MOV BX,2

LOOP1: MOV DX,0

DIV BX

ADD DL,30H

PUSH DX

INC CX

CMP AX,1

JG LOOP1

ADD AL,30H

MOV [SI],AL

LOOP2: POP AX

INC SI

MOV [SI],AL

LOOP LOOP2

RET

HEX2BIN ENDP

END START

Hope it helps

Answered by Khushigk
0

Answer:

what is the best of luck to you

Explanation:

what is the best of luck to you and your family and friends and family welfare govt of India Today group to offer online learning to young people in the day of the day of the day of the day dear all

Similar questions