Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1073
  • Last Modified:

Urgent: 8086 assembly language program to read in and then print out a decimal integer

Write an 8086 assembly language program to read in and then print out a decimal integer
value.  That's it.  Below, is the samplemain program.

;main program   Not too useful since the work is done in procedures defined in other files

 .model small
 .stack 100h  ;allocate 100 hex bytes to the system stack
 .DATA   ; by the way, assembly is not case sensitive and white space is ignored
 prompt1 db 'enter an integer',0AH,0DH,'$'
 prompt2 db 0ah,0dh,'you entered:$'
 prompt3 db 0ah,0dh,'ALL DONE',0AH,0DH,'$'
include decout.asm; the output procedure
include decin.asm; the input proc
include macs.asm; a file of macros
start proc near
       mov ax,@DATA
              mov ds,ax
              message prompt1
              call dec_in; a function call in assembly
              message prompt2
               mov ax,bx
               call dec_out
              message prompt3
              mov ax,4C00h
              int 21h
start endp
end start

Please help

I have to show this at my project by evening ...so any help is greatly apreciated.

U can contact me at tony_r211@yahoo.com(Yahoo Messnger)
or tny_r88@hotmail.com (MSN Messenger)

  • 2
1 Solution
So what is wrong with your program ?
Alfred_hereAuthor Commented:
That is the sample code .

Thats not the program..this is actually for my cousin and he has to submit it by evening. I am not familiar with assembly language..please help..I am even ready to pay out if u want.
Mayank SAssociate Director - Product EngineeringCommented:
Its been a long time since I've done any 8086 programming. I used the following method to read in a multiple-digit number:

MOV CX, DIGITS ; number of digits to be read
MOV NUM, 0000H ; assuming it to be 2 bytes
     MOV AH, 01H
     INT 21H
     AND AL, 0FH
        mov BH, 00H
        MOV BL, AL
     MOV DX, NUM
     MUL DX, 10D
     MOV NUM, DX
     MOV AH, 00H
     ADD NUM, BX

There might have been some redundancy in the above code and I hope that you can correct it if there is any. Its been really very long since I did all this!

     MOV DL, ARG
     ADD DL, 30H
     MOV AH, 02H
     INT 21H
MOV SI, 0000H
     DIV AX, 10D ; Oops! Forgot where the remainder and quotient went :-( I guess the remainder is in DX and the quotient in AX
     MOV ARRAY[SI], DL ' Assuming ARRAY to be defined as an array of numbers, each taking one byte
     INC SI
     CMP AX, 0000H
     JNE LOOP2
     DEC SI
     CMP SI, 0000H
     JNE LOOP3
Hope that helps!

Mayank SAssociate Director - Product EngineeringCommented:
Recommendation: Accept mayankeagle's comment as answer.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now