compiling programme IJVM

compiling programme IJVM

I TRY AND COMPILE THE PROGRAMME BELOW BUT HAS ERROR APPEAR ALL THE TIME,,CAN ANYONE CORRECT THE CODE AND WRITE UP THE NEXT METHOD FOR POWER IN THE PROGRAME AS WELL...URGENT

// Program to read two single digit numbers and display // a.sum // b.difference (a-b or b-a, whichever gives a positive value) // c.products (axb) // d.power (ab)

.constant OBJEREF 0x40 // for calling method ten 10 // for multiplication and division when dealing with multiple digits .end-constant

.main

.var a b .end-var

start: BIPUSH 69 'E' OUT BIPUSH 110 'n' OUT BIPUSH 116 't' OUT BIPUSH 101 'e' OUT BIPUSH 114 'r' OUT BIPUSH 32 OUT BIPUSH 116 't' OUT BIPUSH 119 'w' OUT BIPUSH 111 'o' OUT BIPUSH 32 OUT BIPUSH 110 'n' OUT BIPUSH 117 'u' OUT BIPUSH 109 'm' OUT BIPUSH 98 'b' OUT BIPUSH 101 'e' OUT BIPUSH 114 'r' OUT BIPUSH 115 's' OUT BIPUSH 58 ':' BIPUSH 10 OUT

inp1: IN // read character input from memory/buffer DUP // duplicate top stack (inputed char) for comparing BIPUSH 0 // push o for comparison with null IF_ICMPEQ null // read next char if no input(null) DUP // else, duplicate top stack OUT // print character that being read BIPUSH 48 // convert char ASCII to real value ISUB ISTORE a // store in a GOTO inp2 // read second number

null: POP // if null,loop to read again GOTO inpl

inp2: IN // read second number DUP // duplicate top stack (inputed char) for comparing BIPUSH 0 IF_ICMPEQ null2 // push 0 for comparison with null DUP // else, duplicate top stack OUT // print character that being read BIPUSH 48 // convert char ASCII to real value ISUB ISTORE b // store in b

   GOTO add          // go to add a and b

null: POP // if null, loop to read again GOTO inp2

//addition add: LDC_W OBJREF ILOAD a // add a and b ILOAD b INVOKEVIRTUAL ADDITION BIPUSH 48 // convert sum to ASCII equivalent for printing IADD OUT // print the sum of the two numbers

   BIPUSH 83 'S'
   OUT
   BIPUSH 117 'U'
   OUT
   BIPUSH 109 'M'
   OUT
   BIPUSH 61 '='
   OUT
   BIPUSH 0 
   OUT
   OUT

   BIPUSH 10
   OUT
   GOTO sub

//subtraction sub: LDC_W OBJREF ILOAD A ILOAD B INVOKEVIRTUAL SUBTRACTION BIPUSH 48 IADD

  BIPUSH 68 'D'
  OUT
  BIPUSH 105 'i'
  OUT
  BIPUSH 102 'f'
  OUT
  BIPUSH 102 'f'
  OUT
  BIPUSH 101 'e'
  OUT
  BIPUSH 114 'r'
  OUT
  BIPUSH 101 'e'
  OUT
  BIPUSH 110 'n'
  OUT
  BIPUSH 99  'c'
  OUT
  BIPUSH 101 'e'
  OUT
  BIPUSH 61  '='
  OUT
  BIPUSH 0
  OUT
  OUT

  BIPUSH 10
  OUT
  GOTO mult

//multiplication
mult:LDC_W OBJREF ILOAD A ILOAD B INVOKEVIRTUAL MULTIPLICATION BIPUSH 48 IADD

BIPUSH 80 'P'           //* Prints product
OUT
BIPUSH 114 'r'
OUT
BIPUSH  111 'o'
OUT
BIPUSH 100  'd'
OUT
BIPUSH 117  'u'
OUT
BIPUSH 99   'c'
OUT
BIPUSH 116  't'
OUT
BIPUSH 61  '='
OUT

BIPUSH 0
OUT
OUT

    BIPUSH 10
OUT
GOTO start

stop:

   OUT
   HALT

.end-main

//addition .method ADDITION(a,b)

.var // local variable of method sum .end-var

  ILOAD a
  ILOAD b
  IADD
  ISTORE sum

  ILOAD sum     // return value by putting on stack before returning
  IRETURN

.end-method

//difference .method SUBTRACTION(a,b)

.var // local variable of method difference .end-var

   ILOAD a
   ILOAD b
   ISUB 
   ISTORE difference

   ILOAD difference
   IRETURN

.end-method

//multiply .method MULTIPLICATION(a,b) .var product
counter total .end-var

L1: Iload a Iload b BIPUSH 0 BIPUSH 0 ISUB

  ISTORE counter
  BIPUSH 0
  BIPUSH 0
  ISUB
  DUP
  ISTORE total

  GOTO L2

L2: ILOAD counter ILOAD a IF_ICMPEQ L3 ILOAD total ILOAD b IADD

  ISTORE total
  BIPUSH 1
  BIPUSH 0
  ISUB
  ILOAD counter
  IADD
  ISTORE counter

  GOTO L2

L3: ILOAD total

  IRETURN

.end-method

View Answers









Related Tutorials/Questions & Answers:
compiling programme IJVM
compiling programme IJVM  I TRY AND COMPILE THE PROGRAMME BELOW BUT HAS ERROR APPEAR ALL THE TIME,,CAN ANYONE CORRECT THE CODE AND WRITE UP THE NEXT METHOD FOR POWER IN THE PROGRAME AS WELL...URGENT // Program to read two single
IJVM
in IJVM. For example, if two numbers 2 and 3 are on the stack, the power function... value and b being the value on top). Write an IJVM code segment... are allowed to use existing IJVM instructions only. Include appropriate comments
Advertisements
IJVM
in IJVM. For example, if two numbers 2 and 3 are on the stack, the power function... value and b being the value on top). Write an IJVM code segment... are allowed to use existing IJVM instructions only. Include appropriate comments
IJVM
IJVM  using IJVM..can anybody help me in this question User should be prompted to enter two non-negative numbers (say, a and b where a >0 and b > 0) line by line and then press the enter key. Your program should
programme
programme  Using an ATM, customer can access their bank accounts in order to credit/debit cash and check their account balances.You have to write c programme to implement a simple ATM for 15 customers. Initially you have to store
IJVM
java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method
java programme
java programme   i have to write a java programe that calculates the average of 10 students in Test 1 ,Test 2 and Test 3....Values of the marks in all the test for a student should be hardcore.Ialso have to tell the maixmum
compiling
program not compiling
program not compiling  Hello can you help me with this program,I am trying to add a loop at the end of the program but it is not compiling,thank you. import java.util.*; import java.text.*; class HardwareItems { String code
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
compiling .class files
compiling .class files  how do i compile .class files using eclipse
hotel management programme in c language?
hotel management programme in c language?  hotel management programme in c language
Compiling Error - Java Beginners
Compiling Error  cant able to compile java servlet file in the command prompt? WHY? but i can compile normal java file give me answer to fix my problem
Compiling package in command line
Compiling package in command line  Hi friends, i am totally new to java programming, i am basic learner in java. My query is, How to compile java... how to compile it. Thanks & Regards, Sham   Compiling Java
programme - Java Beginners
programme  java programme to implement stack operation?use stack to check whether a given string is polidrome or not  Hi Friend, Please visit the following link to get the stack implementation: http
process of compiling and running java program
process of compiling and running java program  Explain the process of compiling and running java program. Also Explain type casting
Compiling a Servlet - JSP-Servlet
Compiling a Servlet  Respected sir, I just want to know how to compile a servlet coding? I need it in a sequential way so that I can understand it at the very first time as I am new to this technology
Compiling Error - Java Beginners
Compiling Error  cant able to compile java servlet file in the command prompt? WHY? but i can compile normal java file give me answer to fix my problem.  Hi Friend, Do you have servlet-api.jar in the lib folder
data and analytics graduate programme
data and analytics graduate programme  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data and analytics graduate programme Try to provide me good examples
JAVA programme - Java Interview Questions
JAVA programme  Perpare a class "package_example" following the basic functionality of "string" type in JAVA.Use of dynamic character arrays for such class is encouraged.Following is expected from the programme: a.Use of 3
error while compiling - Java Beginners
error while compiling  i am facing problem with compiling and running a simple java program, can any one help me, the error i am getting is javac is not recognised as internal or external command  Check if you JAVA_HOME
Error While Compiling - Java Beginners
Error While Compiling  Hi All I Am a beginner and i face the following problem while compiling can anyone help me. C:\javatutorial\example> javac HelloWorld.java 'javac' is not recognized as an internal or external
ModuleNotFoundError: No module named 'django-compiling-loader'
ModuleNotFoundError: No module named 'django-compiling-loader'  Hi...: No module named 'django-compiling-loader' How to remove the ModuleNotFoundError: No module named 'django-compiling-loader' error? Thanks   
error in compiling j2me apllication - Applet
error in compiling j2me apllication  hi, in my j2me application for video,m getting only the audio.i ll send the code. package src.video_streaming; import javax.microedition.media.Manager; import
compiling a uploaed java file - JSP-Servlet
compiling a uploaed java file  How a uploaded java source file is automatically compiled(i.e converted to .class file) in server using jsp/servlet
Placement Programme
Java programme
c programme
Compiling and Interpreting Applications in Java
following topics: Compiling Java Program Interpreting Java Program... and then use the command prompt to run the example code. Compiling Java ProgramADS_TO_REPLACE_1 For compiling Java program, first your code must write the code using
Compiling and Running Java program from command line
Compiling and Running Java program from command line - Video tutorial... of compiling and running java program from command line. We have also video... to explain you the process of compiling and running the Java program from command
How to add a file in GZIP file format in Java programme.
How to add a file in GZIP file format in Java programme.  Hi please help me. How to add a file GZIP File format in Java program. If example or suggest link for reference then it will be good. thanks,   Hi
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... . But the value of check variable is not maintained in the programme . we can
i have got error while compiling simple tag handler
i have got error while compiling simple tag handler   javac.servlet.jsp not found! tell me what are the jar files required to run simple tag handler class   The package you have used javac.servlet.jsp does not exist
lucky no programme - Java Beginners
Java programme - Java Beginners
JAVA programme - JDBC
Java programme - Date Calendar
please solve the programme
Problem on JAVA Programme
applet images sleeping programme - Applet
java programme - Java Server Faces Questions
Compiling Objective C
Compiling Objective C     ... program on windows and Max OS x machine. Compiling Objective C program is necessary as it generates the executable program that can run. Compiling Objective C
Compiling and testing the application
Compiling and testing the application       In this application we will compile and deploy... compile: [javac] Compiling 18 source files to C:\tomcat\apache
Compiling a Pattern with Multiple Flags
Compiling a Pattern with Multiple Flags       In this section you will learn how to compile a pattern... for compiling pattern with multiple flags i.e. explained ahead. Program Result:ADS
Compiling MXML files with FlexBuilder
Compiling MXML files with FlexBuilder  ... getting flex builder i know you are ready for learning the coding and compiling...;   For compiling press F11 or click on Run -> Run
DEVELOPING & DEPLOYING A PACKAGED EJB
' is very important in Enterprise Java. Compiling and Deploying such packaged servlets... the correct procedure, in compiling and deploying. These have already been... in facility for package. Marty Hall has provided a very nice note on compiling
Java Square Root And Cube Root Example
. In this example we will use JDK 1.6 and the Eclipse IDE for writing, compiling
MySQL allowMultiQueries JSP Example
as a database, Eclipse as an IDE for compiling and the Tomcat 7 server
How to Get Referer URL Servlet
in Java Servlet. In this example we will use the Eclipse IDE for compiling

Ads