Question

Using Windows 32 framework , write an assembly language program; Write a recursive procedure to find...

Using Windows 32 framework , write an assembly language program;

Write a recursive procedure to find the greatest common divisor of
two non negative numbers. You should use Euclidean algorithm and this is typically
discussed in CSC 230. Your procedure:
❼ Needs to follow cdecl protocol.
❼ Needs to take two parameters.
❼ Should return -1, if the parameters are negative.
❼ Should return gcd, if the parameters are non negative.
Your main procedure should do the followings.
❼ Read two integers using input macro.
❼ Call above gcd procedure after appropriately passing parameters.
❼ Display an appropriate message using output macro if procedure returns -1 or
❼ Display the valid result returned from your procedure using the output macro.
Euclid Algorithm:
         gcd(m, 0) = m
         gcd(m, n) = gcd(n, m mod n)

Homework Answers

Answer #1

1). ANSWER :

GIVENTHAT :

Assembly code for gcd of two numbers .(M,N).

.MODEL SMALL
.STACK 100H

.DATA
PROMPT_1 DB 'Enter the value of M = $'
PROMPT_2 DB 0DH,0AH,'Enter the value of N = $'
PROMPT_3 DB 0DH,0AH,'The GCD of M and N is = $'

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT_1
MOV AH, 9
INT 21H

CALL INDEC

PUSH AX   

LEA DX, PROMPT_2
MOV AH, 9
INT 21H

CALL INDEC   

MOV BX, AX   

POP AX

@REPEAT:   
XOR DX, DX   
DIV BX   

CMP DX, 0
JE @END_LOOP

MOV AX, BX   
MOV BX, DX   
JMP @LOOP

@END_LOOP:   

LEA DX, PROMPT_3
MOV AH, 9
INT 21H

MOV AX, BX

CALL OUTDEC   

MOV AH, 4CH   
INT 21H
MAIN ENDP

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
language: JAVA the Problem Below are a series of problems you need to solve using recursive...
language: JAVA the Problem Below are a series of problems you need to solve using recursive methods. You will write a program that will read commands from an input file, with each command referring to one of the recursive problems to be executed. Each command will be followed (on the same line of input) by the respective parameters required for that problem. (15 points for main method) DescArrayCheck   Write a recursive method that checks whether an array of integers -...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the program title and programmer’s name. Then get the user’s name, and greet the user. • Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46]. • Get and validate the user input (n). • Calculate and display all of the Fibonacci numbers up to and including the nth...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If ( n is even) { n = n / 2; } else { n = 3 * n + 1; } In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...