Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a RISC machine where each instructio... Start Learning for Free
Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the following
instruction sequence Instr. No. Instruction
i : add R2, R3, R4
i + 1 : sub R5, R6, R7
i + 2 : cmp R1, R9, R10
i + 3 : beq R1, Offset
If the target of the branch instruction is i, then the decimal value of the Offset is ____________ 
Correct answer is '(-16)'. Can you explain this answer?
Verified Answer
Consider a RISC machine where each instruction is exactly 4 bytes long...
Ans:(-16)
assume addresses start with 2000 for first instruction.
2000---add R2,R3,R4
2004--sub r5,r6,r7
2008---r1,r9,r10
2012--beq r1,offset //pc after instruction fetch of this instruction will be 2016,and branch target is 2000 ,offset will be (2016-16) = 2000
2016------next instruction
View all questions of this test
Most Upvoted Answer
Consider a RISC machine where each instruction is exactly 4 bytes long...
Given Information:
- Each instruction in the RISC machine is exactly 4 bytes long.
- Conditional and unconditional branch instructions use PC-relative addressing mode.
- The Offset specified in bytes is the distance to the target location of the branch instruction.
- The Offset is always with respect to the address of the next instruction in the program sequence.

Instruction Sequence:
1 : add R2, R3, R4
2 : sub R5, R6, R7
3 : cmp R1, R9, R10
4 : beq R1, Offset

Explanation:
- In the given instruction sequence, the branch instruction is located at line 4 and has a target at line i.
- The offset is the distance in bytes from the branch instruction to the target location.
- Since each instruction is 4 bytes long, the offset can be calculated as the difference between the target line and the branch line, multiplied by 4.

Calculating the Offset:
- The branch instruction is at line 4 and the target is at line i.
- The offset in bytes can be calculated as (i - 4) * 4.

Calculating the Offset for the given Answer:
- The given answer is (-16).

(-16) = (i - 4) * 4

Solving for i:
- Divide both sides of the equation by 4:
- (-16) / 4 = (i - 4) * 4 / 4
- -4 = i - 4
- Add 4 to both sides of the equation:
- -4 + 4 = i - 4 + 4
- 0 = i

Conclusion:
- The decimal value of the offset is -16, which means the target of the branch instruction is located at line 0.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer?
Question Description
Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer?.
Solutions for Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer?, a detailed solution for Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? has been provided alongside types of Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the followinginstruction sequence Instr. No. Instructioni : add R2, R3, R4i + 1 : sub R5, R6, R7i + 2 : cmp R1, R9, R10i + 3 : beq R1, OffsetIf the target of the branch instruction is i, then the decimal value of the Offset is ____________Correct answer is '(-16)'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev