?
Solved

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

Posted on 2003-03-31
6
Medium Priority
?
946 Views
Last Modified: 2012-08-13
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,'$'
.CODE
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)


0
Comment
Question by:Alfred_here
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 11

Expert Comment

by:dimitry
ID: 8241147
So what is wrong with your program ?
0
 

Author Comment

by:Alfred_here
ID: 8241174
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.
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 1600 total points
ID: 8260287
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
LOOP1:
     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
     LOOP LOOP1

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!

SHOWDIGIT MACRO ARG
     MOV DL, ARG
     ADD DL, 30H
     MOV AH, 02H
     INT 21H
ENDM
..
..    
MOV AX, NUM
MOV SI, 0000H
LOOP2:
     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
     
LOOP3:
     DEC SI
     SHOWDIGIT ARRAY[SI]
     CMP SI, 0000H
     JNE LOOP3
         
         
Hope that helps!

Mayank.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10143808
Recommendation: Accept mayankeagle's comment as answer.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question