Find Jobs
Hire Freelancers

MiniJava..

€8-30 EUR

Kapalı
İlan edilme: 4 yıldan fazla önce

€8-30 EUR

Teslimde ödenir
We want to develop a simulator for a subset of the MiniJVM code. The following commands are to be implemented: arithmetic operations: ADD, SUB Loading constants: CONST i Allocate storage space ALLOC i Load/Store: LOAD i, STORE i Comparison operators: LESS Jump instructions: JUMP i, FJUMP i End of program: STOP Each operation is to be implemented in its own class, which inherits from the abstract class Instruction. A simulator has an array of instructions code and a stack. The stack stores int-values. For the sake of simplicity, this task uses ints as an internal representation of truth values. The stack of the simulators has a fixed capacity, which is defined during instantiation. The stackPointer of the stack points to the uppermost occupied cell. In addition, an instance of Simulator has a programCounter that stores the index of the next command to be executed and holds an attribute that stores whether a HALT was executed. The files are already present in the template. The abstract class Instruction is already defined like the classes Simulator and Stack. Edit the following tasks: Create the classes for the instructions in the predefined files. Select the class names so that they match the predefined file name. The classes should inherit from the abstract class Instruction. The objects of the classes that represent the instructions for CONST i, ALLOC i, LOAD i, STORE i, JUMP i, FJump i should each have an int attribute that stores the parameter i of the command. In the classes for each of these commands, create a public constructor that expects an int parameter and initializes the respective attribute with it. For each concrete class of instructions, implement the method public void execute(Simulator simulator), which changes the stack according to the command. The behavior of execute(...) for the different instructions is as follows: ADD: Takes the two top elements from the stack and sets the result of the addition on the stack. SUB: Takes the two top elements a, b from the stack and sets the result of b - a to the stack. CONST i: Loads the constant i to the stack. ALLOC i: Increases the stack pointer by i. You can use Stack's alloc method to do this. LOAD i: Reads the value from the index i of the stack and places it on the stack. STORE i: Takes the top value from the stack and stores it at index i of the stack. LESS: Takes the two uppermost elements a, b from the stack and places the result of the comparison b < a as int coded on the stack. The truth value true should be coded by a 1, the truth value false by a 0. JUMP i is to implement a jump to the command at index i. FJump i Takes the top element of the stack. If the value of this element is 0, a jump to the command at index i is to be executed. Otherwise no jump is executed and the program flow continues normally. HALT is to terminate the program. The halted attribute of the simulator should be set to true. Hints: To access the stack of the simulator instance, use the getStack() object method. In particular, a stack instance has the following methods that you can use during implementation: pop() : Returns the element at the stack pointer and decrements the stack pointer. push(int value): Increments the stack pointer by one and stores value at the new index of the stack pointer. alloc(int count): Increases the stack pointer by count. setValueAtIndex(int index, int value): Sets the value at index to value. The program counter of the simulator can be set with setProgrammCounter(...). You can assume that the stack sizes and instruction sequences of the MiniJVM code that are tested with will not produce stack overflow or stack underflow when correctly implemented. Do not change the code of instruction, stack and simulator.
Proje No: 22690778

Proje hakkında

3 teklif
Uzaktan proje
Son aktiviteden bu yana geçen zaman 4 yıl önce

Biraz para mı kazanmak istiyorsunuz?

Freelancer'da teklif vermenin faydaları

Bütçenizi ve zaman çerçevenizi belirleyin
Çalışmanız için ödeme alın
Teklifinizin ana hatlarını belirleyin
Kaydolmak ve işlere teklif vermek ücretsizdir
3 freelancer bu proje için ortalama €42 EUR teklif veriyor
Kullanıcı Avatarı
Hello sir, i can help you working on your JVM simulator, i have experience in java, and i read the description of your problem
€67 EUR 3 gün içinde
0,0 (0 değerlendirme)
0,0
0,0
Kullanıcı Avatarı
I'll complete your project satisfactorily. You will get quality work at an affordable price. I can start work right away. I will be looking forward to hearing from you. Thank you.
€30 EUR 1 gün içinde
0,0 (0 değerlendirme)
0,0
0,0

Müşteri hakkında

   GERMANY bayrağı
Munich, Germany
3,9
4
Ödeme yöntemi onaylandı
Kas 22, 2019 tarihinden bu yana üye

Müşteri Doğrulaması

Teşekkürler! Ücretsiz kredinizi talep etmeniz için size bir bağlantı gönderdik.
E-postanız gönderilirken bir şeyler yanlış gitti. Lütfen tekrar deneyin.
Kayıtlı Kullanıcı İlan Edlien Toplam İş
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Ön izleme yükleniyor
Coğrafik konum için izin verildi.
Giriş oturumunuzun süresi doldu ve çıkış yaptınız. Lütfen tekrar giriş yapın.