write easy assembly code.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write easy assembly code. 

Sample Run
Greatest Common Divisor (GCD)
<<<<<<<
Enter the 1st integer (>0): -1
Error, incorrect input. Try again!
Enter the 1st integer (>0): 30
Enter the 2nd integer (>0): 0
Error, incorrect input.
Enter the 2nd integer (>0): 55
Try again!
GCD (30,55):
START;
a -> b := 25
a=30,b=55 -> a < b -> b
a=30,b=25 -> a > b -> a
a=5,b=25
a=5,b=20
a=5,b=15
a=5,b=10
a=5,b=5
:= b
:= a
- b -> a
:= 5
-> a < b -> b := b
a -> b := 20
-> a < b -> b := b
a -> b := 15
-> a < b -> b := b
a -> b := 10
-> a < b -> b := b
a -> b := 5
-> a
= b -> return a
END;
The greatest common divisor of 30 and 55 is 5
Transcribed Image Text:Sample Run Greatest Common Divisor (GCD) <<<<<<< Enter the 1st integer (>0): -1 Error, incorrect input. Try again! Enter the 1st integer (>0): 30 Enter the 2nd integer (>0): 0 Error, incorrect input. Enter the 2nd integer (>0): 55 Try again! GCD (30,55): START; a -> b := 25 a=30,b=55 -> a < b -> b a=30,b=25 -> a > b -> a a=5,b=25 a=5,b=20 a=5,b=15 a=5,b=10 a=5,b=5 := b := a - b -> a := 5 -> a < b -> b := b a -> b := 20 -> a < b -> b := b a -> b := 15 -> a < b -> b := b a -> b := 10 -> a < b -> b := b a -> b := 5 -> a = b -> return a END; The greatest common divisor of 30 and 55 is 5
Write an assembly language program that requests input from the keyboard for two
positive integers greater than 0 then it calculates and displays the greatest common
divisor (GCD). The greatest common divisor (GCD) of two integers (numbers), is the
largest number that divides them both without a reminder. For example, 21 is the GCD
of 252 and 105 (because 252 = 21 × 12 and 105 = 21 × 5). Since 21 is the greatest common
number that divides both integers it is the GCD.
Your
program must define and use the following procedures:
Procedure Main: This is the main procedure of the program which makes the correct
sequence of calls to other procedures and displays the program title as shown in the
sample run.
Procedure Read_Numbers: This procedure prompts for input and reads the value of
two positive integers. This procedure makes use of the procedure Check_Value
(defined below) which checks if a value is out of range and displays the error message.
If the returned value in BL is 0 (error) then it must prompt for the input again.
Procedure Check_Value: This procedure takes as input parameters an integer value
in EAX, a minimum value in EBX. If the value of EAX is greater than the value of
EBX, this procedure returns in BL the value 1. Otherwise, it displays the error
message “Error, incorrect input. Try again!" and returns in BL the value 0.
Procedure GCD: This procedure takes as input parameters in EAX and EBX
representing the two input integers and finds the greatest common divisor (GCD)
using the following algorithm (subtraction method). In addition, this procedure
provides a trace of execution as shown in the sample run.
function gcd (a, b)
while a # b
if a > b
а :3 а -b
else
b := b - a
return a
Transcribed Image Text:Write an assembly language program that requests input from the keyboard for two positive integers greater than 0 then it calculates and displays the greatest common divisor (GCD). The greatest common divisor (GCD) of two integers (numbers), is the largest number that divides them both without a reminder. For example, 21 is the GCD of 252 and 105 (because 252 = 21 × 12 and 105 = 21 × 5). Since 21 is the greatest common number that divides both integers it is the GCD. Your program must define and use the following procedures: Procedure Main: This is the main procedure of the program which makes the correct sequence of calls to other procedures and displays the program title as shown in the sample run. Procedure Read_Numbers: This procedure prompts for input and reads the value of two positive integers. This procedure makes use of the procedure Check_Value (defined below) which checks if a value is out of range and displays the error message. If the returned value in BL is 0 (error) then it must prompt for the input again. Procedure Check_Value: This procedure takes as input parameters an integer value in EAX, a minimum value in EBX. If the value of EAX is greater than the value of EBX, this procedure returns in BL the value 1. Otherwise, it displays the error message “Error, incorrect input. Try again!" and returns in BL the value 0. Procedure GCD: This procedure takes as input parameters in EAX and EBX representing the two input integers and finds the greatest common divisor (GCD) using the following algorithm (subtraction method). In addition, this procedure provides a trace of execution as shown in the sample run. function gcd (a, b) while a # b if a > b а :3 а -b else b := b - a return a
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Properties of Different Architectures
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education