Reply
Old 04-18-2014, 11:05 PM   #1 (permalink)
 
Status: Senior Member
Posts: 719



Default write a program which will let the user enter a fraction of the form m/n m < n and will print the expansion to 6 decimal places.

Can someone please help me with this assembly language program? I know i'm missing something from the DEC_IN procedure(I'm working on figuring it out). but im really confused on my PRINT_FRAC, and REPEAT functions. This is my code that I have so far:

org 100h

section .data
PROMPT_1 DB "Enter the value of M = $"
PROMPT_2 DB 0DH,0AH,"Enter the value of N ( N>M ) = $"
PROMPT_3 DB 0DH,0AH,"Result = ( M/N ) = $"

section .bss
Mresw1
Nresw1

section .text

START1:
mov dx, PROMPT_1
mov ah, 9
int 21H
call DEC_IN
mov[M], bx
movdx, PROMPT_2
movah, 9
int21h
callDEC_IN
mov[N],bx
mov ah, 1
movdx, PROMPT_3
movah, 9
int21h
callPRINT_FRAC
movax,4C00h
int21h

DEC_IN:
pushax
movbx, 0
movah, 1
int21h
TOP1:
cmpal, 0Dh
jeOUT1
salbx, 1

int21h
jmpTOP1
OUT1:
popax
ret



PRINT_FRAC:

mov dl, "."
int 21H
pop ax
mov cs, bx
ret

REPEAT:
mov ax, 10
mul [M]
idiv[N]
xor dx, dx
div [N]
mov ax, dx
loop REPEAT
mov ah, 4ch
int 21h
Money07 is offline   Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write a program that prompts the user to enter a personís date of birth in numeric form such as 8-27-1980.T? Shweta Programming 2 01-25-2014 11:06 AM
Write a program to allow the user to enter in a number in the range 1 to 10 and then print out the....? TvShows3 Coding 2 11-09-2013 03:06 PM
Write the program that lets the user enter a series of integers.The user should enter -1 to signal the end.? emma Programming 0 04-11-2013 11:03 PM
round a floating point number to 3 decimal places and display answer in five decimal places in C language.? JohnyZone Programming Languages 1 01-30-2013 10:05 PM
how do i get an inputted data to print out to 2 decimal places in a C++ program Lipsheene Computer Programming 0 09-09-2011 10:11 PM