Question

Write a subroutine code to divide two positive numbers by repeated subtraction method. For exampl...

Write a subroutine code to divide two positive numbers by repeated subtraction method. For example, to divide 100 over 8 by subtracting 8 from 100 until the reminder be less than 8, then count the times of the subtractions, to give the result. The first number, second number, and then the result locations must follow the calling code.

I need the solution using assembly language not java or c++, please..!!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code in Marie will be:

    Input
    Store   A
    Input
    Store   B

Loop,   Load    A  
    Subt    B
    Store   A
    Skipcond 800
    Jump    Endloop
    Load    X
    Add     One
    Store   X
    Jump Loop

IncrementX, Load    X
    Add     One
    Store   X
    Load    A
    Subt    B
    Store   A

Endloop, Load   A
    Skipcond 000 
    Jump    IncrementX

    Load    X
    Output   
    Halt
A,  DEC     0
B,  DEC     0
X,  DEC     0
One, DEC    1

Code in ARM :

MOV     R1,#128   ;divide R1 by R2
 MOV     R2,#4     ;
 MOV     R0,#0     ;initialise counter
.subtract
 SUBS    R1,R1,R2  
 ADD     R0,R0,#1  ;
 BHI     subtract  ;
Add a comment
Know the answer?
Add Answer to:
Write a subroutine code to divide two positive numbers by repeated subtraction method. For exampl...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a subroutine code in ASSEMBLY LANGUAGE (Mano format) to divide two positive numbers by repe...

    Write a subroutine code in ASSEMBLY LANGUAGE (Mano format) to divide two positive numbers by repeated subtraction method. For example, to divide 100 over 8 by subtracting 8 from 100 until the reminder be less than 8, then count the times of the subtractions, to give the result. The first number, second number, and then the result locations must follow the calling code. PLEASE WRITE YOUR ANSWER IN ASSEMBLY LANGUAGE ONLY.

  • CMPE 263-SPRING 2019-HW-3 Hint. For all the codes required, run them in the Basic Computer Simulator...

    CMPE 263-SPRING 2019-HW-3 Hint. For all the codes required, run them in the Basic Computer Simulator with two print screens, one shows code, registers, memory involved before run, and the second after run. Without them, the mark will reduce to ½. Q2. Write a subroutine code to divide two positive numbers by repeated subtraction method. For example, to divide 100 over 8 by subtracting 8 from 100 until the reminder be less than 8, then count the times of the...

  • must be written in assembly code Write an MSP430 assembly language subroutine, REP_FREE, to examine the...

    must be written in assembly code Write an MSP430 assembly language subroutine, REP_FREE, to examine the elements of an array of positive word-size numbers stored at location ARRAY_IN. The array is already sorted in an ascending order. The first element is the number, n,which is the length of the array. The subroutine will copy the elements from location ARRAY_IN to location ARRAY_OUT. While copying, if an element appears more than once (repeated), then the repeated copies are ignored. In essence,...

  • 8. The following algorithm can be used to carry out division of two non- negative numbers by repeated subtraction. initialize quotient to o WHILE dividend >- divisor DO increment quotient subtr...

    8. The following algorithm can be used to carry out division of two non- negative numbers by repeated subtraction. initialize quotient to o WHILE dividend >- divisor DO increment quotient subtract divisor from dividend END WHILE Use this algorithm to write (assembly) code to divide the contents of %eax by the contents of %ebx and store the product in %edx. 8. The following algorithm can be used to carry out division of two non- negative numbers by repeated subtraction. initialize...

  • write a java program that prompts a user to enter two different numbers, divide the first...

    write a java program that prompts a user to enter two different numbers, divide the first number by second and prints the result

  • CMPE 263-SPRING 2019-HW-3 Hint. For all the codes required, run them in the Basic Computer Simula...

    CMPE 263-SPRING 2019-HW-3 Hint. For all the codes required, run them in the Basic Computer Simulator with two print screens, one shows code, registers, memory involved before run, and the second after run. Without them, the mark will reduce to ½. Q3. Assume in locations A and B resides two 8 bit signed magnitudenumbers. Write an assembly subroutine code to multiply them and saves the result in C location. Start your code from 100. The code should be general for...

  • Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...

    Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two integer numbers as input and ask the user if he need to compute addition, subtraction, remainder, division, or multiplication then print the result. Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), …. And so on. The output must be something like: Enter the first integer number: 5 Enter the second integer number: 3 Which operation? 1...

  • In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is...

    In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me show the computations for a=210 and b=45. Divide 210 by 45, and get the result 4 with remainder 30, so 210=4·45+30. Divide 45 by 30, and get the result 1 with remainder 15, so 45=1·30+15. Divide 30 by 15, and get the result 2 with remainder...

  • Write a program to compute the product of two positive integers by repeated addition. Note: You...

    Write a program to compute the product of two positive integers by repeated addition. Note: You are not allowed to use either multiplication or division operator. Understanding the Meaning of Multiplication: Multiplication of whole numbers can be thought of as repeated addition. // not allowed to use multiplication or division operator For example, suppose that a parking lot has 6 rows of parking spaces with 8 spaces in each row. How many parking spaces are in the lot? rows To...

  • Give the solution using Python programming for following with explanations: a. Take two numbers and display...

    Give the solution using Python programming for following with explanations: a. Take two numbers and display which number is positive and which number is negative. b. Take two numbers divide and display quotient and reminder. c. Take two numbers and check if they are same or not same. a. Write four differences between high level language and low level language? b. Write all the rules of naming any variables in python and provide at least one example for each rule?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT