1 Replies - 709 Views - Last Post: 28 October 2019 - 06:12 AM Rate Topic: -----

#1 babojye   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-October 19

Need help converting from java to assembly

Posted 27 October 2019 - 08:30 PM

Fairly new to Pep9. I am needing help converting the Java code to Assembly pep 9

I tried to use a function and pass information to and from the function using the stack but having a hard time.


import java.util.Scanner;
public class Q2 {
   public static int multiply(int a, int b ) {
     int sum;
     sum=0;
     while (b>0) {
       sum=sum+a;
       b=b-1;
     }
     return sum;
   }

public static void main(String s[]) {
   Scanner scanner = new Scanner(System.in);
   int x,y,result;
   System.out.print("Enter two integers:");
   x=scanner.nextInt();
   y=scanner.nextInt();
   result=multiply(x,y);
   System.out.println("result is "+result);
   }
}

This post has been edited by andrewsw: 28 October 2019 - 06:12 AM
Reason for edit:: added missing code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Need help converting from java to assembly

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: Need help converting from java to assembly

Posted 28 October 2019 - 06:12 AM

Please wrap code in code tags when posting.

Please provide your attempt at the assembly and describe what you mean by "having a hard time".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1