Answer to Question #262510 in Electrical Engineering for rishi

Question #262510

Design a circuit of the General register organization in which 16 registers are there from R0 to R15.

(a) Perform the following microoperation and explain the operation in the steps through the diagram properly: - ADD R13, R7, R10.

(b) Explain the control word as per the register configuration given above.



1
Expert's answer
2021-11-08T08:49:32-0500

R0-R12: can be used during common operations to store temporary values, pointers (locations to memory), etc.

R13 Is the stack pointer sp. It cannot be used for any other purpose. The value stored in sp must be the same as the value when the called function exits

R14 Is the link register lr. If you save the return address, you can use r14 for other purposes between calls, and restore it when the program returns

R15: PC (Program Counter). The Program Counter is automatically incremented by the size of the instruction executed.


This function should interpret its parameter as a N2 instruction, use the bit operators to extract its fields (see the description and diagram in Section 2.4), and print the instruction's components on a single output line. However, if the instruction is invalid according to the criteria below, nothing at all should be printed and the function should just return 0. Otherwise, if the instruction is valid, the function should return I after printing the instruction, in this format:

• The instruction's opcode (the opcode field of the parameter, meaning its leftmost five bits) should be printed using its name in the table in Section 2.4 (plus, minus, times, div, etc.), spelled exactly as shown there. For example, if the value of the opcode field is the enum value PLUS (which has the value 0), then plus should be printed. If the opcode field is MINUS darn minus should be printed, etc.

• Following the opcode, the extension and register operands that are actually used by the instruction should be printed, with the extension (if it is used) followed by the register operands that are used, in the order register, register,, and register,. For example, a not instruction uses the first two registers as operands, an those two should be printed, with the first register operand followed by the second one. A sys instruction uses the extension (usually-see the next sentence) and the first register as operands, no the extension should be printed first, than the register operand. (If the value of the extension field is 4 in a sys instruction than the register field should not be printed, because the system call to halt a program does not have a register operand.) Register names should be printed in decimal with an R immediately preceding the register number. For example, registers 0, 1, and 3 would be printed as RI, RI, and R3. For sys, the only instruction that uses the extension, the extension should just be printed as a single decimal digit between 0 and 4.

• If an instruction uses a memory address operand or an immediate operand that operand should be printed last, in decimal. If it is a memory address it should be printed using exactly five places, with addresses less than 10000,0 printed using as many leading zeros as necessary so they occupy exactly four places. For example, the address 216,0 should be printed as 00216. (This can trivially be performed with pr intf () formatting options covered in discussion.) Note that immediate operands of li instructions should not be printed with any leading zeros, except zero itself should be printed as 0. Only memory address operands should have leading Os if needed. The printed fields must be separated with one or more whitespace characters (meaning tabs or spaces); the exact number of whitespace characters is up to you. The printed instruction should not have any whitespace before the opcode or following the last field printed. A newline should not be printed after the instruction. For example, the call print_inst ruct ion (0x38710000) should print something like shl R3 R4 R2, where the exact number of spaces or tabs separating the four things printed is up to you (one or more). As mentioned before, some values that can be stored in a 32-bit N2 word or register don't represent valid N2 instruc-tions, and if its parameter represents an invalid instruction this function should just return 0 without printing anything. An instruction would be invalid in any of these cases:

• The value in its opcode field is invalid. There me only 27 instructions (hence °Nodes) on the N2 (with enum values between PLUS and SOS), no any value outside of that range doesn't represent an actual opcode.

• If a register operand that is actually used by the instruction has an invalid number. There are only seven registers on the N2 with numbers 0-6 (and symbolic constant names RO through R6 defined in machine. h), an the value 7 doesn't represent a valid register number.

• If it is an instruction that uses the address or constant field to store a memory address and the value of the field is not evenly divisible by 4. As will come up later, machines often have alignment requirements such that any data item must begin at a memory address that is a multiple of the size in bytes of that item. Since the N2 has this requirement, and everything on the N2 occupies a 4—byte word, everything must begin at an address that is divisible by 4.

Note: if the parameters represent an instruction that uses the address or constant field for storing a memory address its value must be divisible by 4. But if the instruction is an 11 instruction, which is using the field to represent a immediate (constant) value, it does not have to be divisible by 4.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS