Question

Assembly Operations A very simple microcontroller has one register, X, which is initialised to 0, and supports only 3 types of microinstructions: LDI v: Load (store) the immediate value, v, into X- ADD v Add the immediate value v to X and store the result in X SQR: Square the value of and store the result in A program for this microcontroller is simply a sequence of n microinstructions, each being of one of the 3 types described. For example, the table below illustrates how the value of X would be affected by a short sequence of microinstructions. LDI 5 ADD 2 SQR ADD4 LDI-3 SQR 49 In an experiment, the microcontroller is going to be sent into outer space, where it will be exposed to high energy cosmic rays, which may cause it to skip one or more instructions in its program. The arithmetic computations and the storage into X have been hardened though, so even when an instruction is skipped, the value of X is retained, and the rest of the sequence continues to execute The researchers would like to know for a given program, executing on this microcontroller in space, what will be the largest possible value that could be stored in X by the time the program halts. Input Format The first line contains a single integer n The next n lines describe the program. Each of these lines contains an instruction as described in the problem. 1S n s 10 10 vs 10 Output Format Print the maximal value of X Sample Input 0 4 ADD 3 SQR
media%2F762%2F7621d0a0-9beb-4a98-bb15-66
media%2F60c%2F60c5b3bd-58cb-4666-b1ec-67
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the solution of above problem in below images 1 & 2 :

Image 1:

Solution.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.A

Image 2:

Solution.java eise instvalue[x] Integer.parseInt (input[1] for(int 0; x 〈 N; x++) { if(instruction [x].equals (LDI)) x { no

Add a comment
Know the answer?
Add Answer to:
Assembly Operations A very simple microcontroller has one register, X, which is initialised to 0, and...
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
  • Consider the following MIPS assembly language instructions: addi $1, $2, 100 swr $1, 0($2): addi $rt,...

    Consider the following MIPS assembly language instructions: addi $1, $2, 100 swr $1, 0($2): addi $rt, $rs, immediate # add immediate swr $rt, immedi ate ($rs) # store word write register These instructions are I-format instructions similar to the load word and store word instructions. The addi and swr instructions store a computed value to the destina- tion register $rt. The instructions do not require any physical hardware changes to the datapath. The effect of each instruction is given below....

  • Instruction set architecture R: register X, Y, Opl, Op2: Operand Quantity: constant value EA: Effective memory address Opcode Operation Name MOV X, Y XCH Opl, Op2 ADD X, Y SUB X,Y SAL Op, Quantity...

    Instruction set architecture R: register X, Y, Opl, Op2: Operand Quantity: constant value EA: Effective memory address Opcode Operation Name MOV X, Y XCH Opl, Op2 ADD X, Y SUB X,Y SAL Op, Quantity SAR Op, Quantity Shift Arithmetic Right on Op for Quantity SHR Op Quanti AND X, Y OR X, Y XOR X, Y NOT X LOADR, A LOAD R, (A STORE R, A STORE R, (A Description Move data from Y to X Exchange Op1 with Op2...

  • computer analysis

    Questions1.  The function L is defined as L(1) = 2,L(2) = 1,L(3) = 3,L(4) = 4 and for n ≥ 4,L(n + 1) = L(n) + L(n − 1) + L(n − 2)L(n − 3)i.e., the (n + 1)-th value is given by the sum of the n-th, n − 1-th and n − 2-th values divided by the n − 3-th value.(a)  Write an assembly program for computing the k-th value L(k), where k is an integer bigger than...

  • (java) Please implement your own Dequeue class which has following methods •boolean add(E e)= void addLast(E...

    (java) Please implement your own Dequeue class which has following methods •boolean add(E e)= void addLast(E e)  // two methods are the same. You could implement either one • •void addFirst(E e) • •E getFirst( ) = E peek( ) // two methods are the same. You could implement either one •E getLast( ) •E removeFirst() •E removeLast() Case 1 : Queue •Create a queue which is an instance of Dequeue. The queue should perform with given following input and print...

  • NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors...

    NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors - Irvine) that has two procedures, a main procedure and a procedure called Fib. The fib procedure is to uses a loop to calculate and printout the first N Fibonacci numbers. Fibonacci sequence is described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). The value of N is to be communicated to this...

  • Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme...

    Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme will work, but it is spectacularly inefficient. If both input strings have N characters, then the number of recursive calls will exceed 2N. To overcome this performance bug, we use dynamic programming. Dynamic programming is a powerful algorithmic paradigm, first introduced by Bellman in the context of operations research, and then applied to the alignment of biological sequences by Needleman and Wunsch. Dynamic programming...

  • The second phase of your semester project is to write pass one of a two‑pass assembler...

    The second phase of your semester project is to write pass one of a two‑pass assembler for the SIC assembler language program. As with Phase 1, this is to be written in C (not C++) and must run successfully on Linux. Pass one will read each line of the source file, and begin the process of translating it to object code. (Note: it will be to your advantage to have a separate procedure handle reading, and perhaps tokenizing, the source...

  • this is a C++ program! You will write a program that performs the following tasks for...

    this is a C++ program! You will write a program that performs the following tasks for a simple mathematical calculator: (1) Open a user-specified file for input. Prompt for the name of the file, read it into a string variable, echo print it to the terminal and then open it. If the file is not opened, enter into a loop that prints out an error message, resets the input file stream variable (see the hints section), obtains a new file...

  • My CSC 220 teacher has given this as a homework assignment and starting it has not...

    My CSC 220 teacher has given this as a homework assignment and starting it has not made much sense and am generally lost on this assignment help would be much appreciated. I put everything from the assignment power point slides she gave us in here so the expert has everything im working with as well. Dequeue Please implement your own Dequeue class which has following methods boolean add(E e)= void addLast(E e) void addFirst(E e) E getFirst( ) = E...

  • LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to...

    LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to a function and returning values. Everything is stored on the runtime stack so that space is used only when the function is executing. As a result the actual address of arguments and locals may change from call to call. However, the layout of the stack frame (activation record) is constant. Thus, the offests from the frame pointer (FP) to the parameters/locals are constant. All...

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
ADVERTISEMENT