Question

Using the generic three-, two-, one-, and zero-address instruction sets (like in the notes), create programs...

Using the generic three-, two-, one-, and zero-address instruction sets (like in the notes), create programs to calculate (A+3)*B+C*5. You can assume that memory-memory operations are allowed. You may also define temporary locations if needed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

zero address instrutions

PUSH A //Top of Stack <- A
PUSH 3 //Top of Stack <- immediate value 3
ADD   //Top of Stack <- (A + 3)
PUSH B //Top of Stack <- B
MUL //Top of Stack <- (A + B)*3
PUSH C //Top of Stack <- C
PUSH 5 //Top of Stack <- immediate value 5
MUL //Top of Stack <- C * 5
ADD       //Top of Stack <- (A + B)*3 + c * 5


one address instructions

ADD 3       //AC <- AC + 3
MUL B       //AC <- AC *B
STA T       //M[T] <- AC
LDA C       //AC <- M[C]
MUL 5       //AC <- AC * 5
ADD T       //AC <- AC + M[T]

Here AC is nothing but Register A which is also called as accumulator
T is used to store temporary memory location.

two address instructions

ADD A,#3   //A = A + 3
MUL B       //A = (A + 3) * B
MOV R1,A   //R1= (A + 3) * B
MOV A,#5   //A = 5
MUL C       //A = C*5
ADD A,R1   //A = (A + 3) * B + c * 5

THREE ADDRESS INSTRUCTIONS

ADD A,A,#3   // A= A+3
MUL R1,A,B   // R1= (A+3)*B
MUL C,C,#5   // C= C * 5
ADD A,R1,C   // A= (A+3)*B + c * 5

Add a comment
Know the answer?
Add Answer to:
Using the generic three-, two-, one-, and zero-address instruction sets (like in the notes), create programs...
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
  • Using the generic three-, two-, one-, and zero-address instruction sets (like in the notes), create programs...

    Using the generic three-, two-, one-, and zero-address instruction sets (like in the notes), create programs to calculate (A+3)*B+C*5. You can assume that memory-memory operations are allowed. You may also define temporary locations if needed.

  • The AVR provides a rich instruction set to support high-level languages. The AVR address- ing modes...

    The AVR provides a rich instruction set to support high-level languages. The AVR address- ing modes also simplify the access of complex data structures. The AVR has a version of the ADD instruction that includes the C flag as one of the source operands, which enables multiple- precision addition operation. The AVR also has a version of the SUB instruction that includes the C flag as one of source operands and hence is used to perform multiprecision subtraction operation. The...

  • b. A microprocessor has an instruction set that consists of 117 instructions, which need fetch, decode, read operand, execute, write and interrupt stages. Assume that as an average, each stage requir...

    b. A microprocessor has an instruction set that consists of 117 instructions, which need fetch, decode, read operand, execute, write and interrupt stages. Assume that as an average, each stage requires three micro- operations to complete. Also, assume that the control memory is N bits wide (i.e., control field bits + address selection field bits + address-one bits + address-two bits N bits). The control field bits are 15 and there are 15 flags to be monitored. i. How many...

  • 1. One of the reasons why the MARE architecture is very inefficient is because it only has 1AC As...

    I need answer for qustion (2) 1. One of the reasons why the MARE architecture is very inefficient is because it only has 1AC Assuming that you have access to many other ACs (AC, AC1, AC2, etc) Assume that in the new MARIE Architecture, you can do ADD 105 AC1 This means: Value @ x105 ACAC or suB 104 AC2 → This means: Valus @ x 104 + AC → AC2 How would your program (Lab #s, Question 1, also...

  • Part 1: A pipelined computer completes instructions more quickly by having more than one instruction at...

    Part 1: A pipelined computer completes instructions more quickly by having more than one instruction at a time "in the pipeline." Explain what problem branch instructions cause with instruction pipelining. Describe one approach to overcoming this problem. Part 2: RISC computers generally execute more instructions per second than CISC computers. Describe the penalty or trade-off paid when adopting the RISC architecture. Part 3: When a cache hit to a cache on the CPU chip occurs on a memory write the...

  • Some processors have two sets of registers, one for integer operations and one for floating point...

    Some processors have two sets of registers, one for integer operations and one for floating point (fp) operations. The registers used in integer operations are always saved and restored during every context switch whether it is preemptive multithreading or non-preemptive multithreading(since they are also used for calculations for instructions, such as memory address calculation, branch target calculation etc.) However, for most machines it is not very clear what will happen to the floating-point registers. Below you are given 5 different...

  • This part requires you to write two programs, compile them, and execute them - just like...

    This part requires you to write two programs, compile them, and execute them - just like our lab questions.  You may access these questions as many times as you need to and you have the entire duration of the test to complete these problems. You must submit the program code and the sample outputs for each problem - just like lab. These questions are worth 6 points each. 1.      C++ Write a program that reads 20 data values from a data...

  • Using the Windows Starter Visual Studio project create the following two programs. 1. Write a program...

    Using the Windows Starter Visual Studio project create the following two programs. 1. Write a program that will loop three times and raise the number 25 to the third power (25pts). (25*25*25) Note: Make sure you have a large enough memory for the final number 2. Write a program using a whileSum that adds one to the index until it is five (25pts). Sample:         mov sum, 0     ; sum := 0         mov ecx, 1     ; count := 1 whileA:...

  • Create a program that performs the following operations: 1. Prompt for and accept a string of...

    Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....

  • Requirements Create an Address Book class in Java for general use with the following behaviors: 1....

    Requirements Create an Address Book class in Java for general use with the following behaviors: 1. Constructor: public Address Book Construct a new address book object. • A contact has four fields: first name, last name, email and phone. (There could be more information for a real contact. But these are sufficient for the assignment.) . The constructor reads from the disk to retrieve previously entered contacts. If previous contacts exist, the address book will be populated with those contacts...

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