Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

******************using 8086 assembly language**********************************

ID: 3593139 • Letter: #

Question

******************using 8086 assembly language***********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

write a program which will:

Display an appropriate prompt.

Input a signed base 8 integer from the keyboard

If an invalid character (that is, not in the range '0'-'7') is input, erase the character by printing a backspace char (ASCII code 8), a blank (' ') and another backspace and do not attempt to convert the invalid character.

Convert the characters as they are input into the equivalent binary number stored in register BX

Overflow processing is NOT necessary.

Display another appropriate prompt.

Output the base-2 form of the binary number in register BX.

If the user indicates a negative number is being input, remember that fact, read the number as an absolute value, then negate it when input is finished.

Sample input/output:

    Enter a base-8 number: 10
    The binary number is: 0000000000001000

Another input/output sample:

   Enter a base-8 number: -1234
    The binary number is: 1111110101100100

Explanation / Answer


DATA SEGMENT
db equ 07h
cr equ 0dh
MSG2 DB,cr,lf "BINARY NUMBER IS : "
STR1 DB 20 DUP(40)
STR2 DB 20 DUP(40)
Number DW 100
LINE DB 10,13,'$'
DATA ENDS

output MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STR1
MOV AX,NO
MOV BH,00
MOV BL,2
L1:DIV BL
ADD AH,'0'
MOV BYTE PTR[SI],AH
MOV AH,00
INC SI
INC bx
CMP AL,00
JNE L1

MOV cx,bx
LEA SI,STR1
LEA DI,STR2
MOV CH,00
ADD SI,CX
DEC SI

L2:MOV AH,BYTE PTR[SI]
MOV BYTE PTR[DI],AH
DEC SI
INC DI
LOOP L2

ouput LINE
output MSG2
output STR2
MOV AH,4CH
INT 21H
CODE ENDS
END START