Jasmin-2.4 is a java assembler, it can be down loaded here....https://sourceforg
ID: 3886390 • Letter: J
Question
Jasmin-2.4 is a java assembler, it can be down loaded here....https://sourceforge.net/projects/jasmin/.....
1. cd to the jasmin directory (jasmin-2.4 the directory that contains the jasmin.jar file)
2. see the examples in the examples subdirectory
3. Use example HelloWorld.j from your Canvas Announcements. (The HelloWorld.j in the jasmin examples directory doesn't work). Modify the first line of code to be .class public HelloWorld (this will cause the class file to be put in the jasmin-2.4 directory instead of the examples subdirectory)
Don't let your editor save the file with a .txt suffix!
4.open a cmd window
5. Issue the command set CLASSPATH= directory> (this step should only need to be done one time per session)
6. To assemble the HelloWorld.j example:
java -jar jasmin.jar examplesHelloWorld.j
7. To run the HelloWorld example: java HelloWorld
Assignment:
See the Count.j example for how to print integers, then modify the HelloWorld.j example to write a jasmin program to display today's date in the following format:
Today is Month day, year........................ I need to edit code to run in command prompt and show the current month, day and year
heres the file that need to be modified
; Demo how to print ints and strings
; Prints "Hello 1 World!"
;
.class public HelloWorld
.super java/lang/Object
;
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 2
; 1 - the PrintStream object held in java.lang.System.out
getstatic java/lang/System/out Ljava/io/PrintStream;
astore_1
ldc "Hello "
aload_1
swap
invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
bipush 1
invokestatic java/lang/String/valueOf(I)Ljava/lang/String;
aload_1
swap
invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
aload_1
ldc " World!"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
..................................................This is the count.j file.................................................
.class public examples/Count
.super java/lang/Object
;
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
; set limits used by this method
.limit locals 4
.limit stack 3
; setup local variables:
; 1 - the PrintStream object held in java.lang.System.out
getstatic java/lang/System/out Ljava/io/PrintStream;
astore_1
; 2 - the integer 10 - the counter used in the loop
bipush 10
istore_2
; now loop 10 times printing out a number
Loop:
; compute 10 - ...
bipush 10
iload_2
isub
invokestatic java/lang/String/valueOf(I)Ljava/lang/String;
astore_3
; ... and print it
aload_1 ; push the PrintStream object
aload_3 ; push the string we just created - then ...
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; decrement the counter and loop
iinc 2 -1
iload_2
ifne Loop
; done
return
.end method
Explanation / Answer
include these lines in your code to run the code in command prompt i.e for every input you provide
int i=integer.parseInt(args[0]);
string s=args[1]
to show date and time
import java.util.date;
DateFormat dd = new SimpleDateFormat("dd/mm/yy HH:mm:ss");
Date dateobj1= new Date();
System.out.println(dd.formst(dateobj1));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.