📝 Branch Group of SAP-III Computer (20 MCQs)
Program Flow Control Through Branch Instructions
The branch instruction group changes the normal sequential execution of a SAP-III program by modifying the program counter. Its operations include unconditional jumps, conditional jumps, subroutine calls and returns. These instructions allow programs to repeat operations, select alternative instruction sequences and execute reusable routines according to the results represented by the processor's status flags.
Unconditional and Conditional Jump Operations
JMP transfers execution directly to a specified sixteen-bit address without testing any flag. Conditional jumps examine the status register before changing the program counter. JZ tests the zero flag, JNZ tests its clear condition, JC and JNC examine carry, while JM and JP check the sign flag. JPE and JPO test parity conditions.
Subroutine Calls and Conditional Return Processing
CALL transfers control to a specified subroutine after saving the return address on the stack. RET retrieves that address and resumes the calling program. Conditional calls and returns perform these operations only when their specified flag conditions are satisfied. The stack pointer therefore supports branch-related operations that temporarily interrupt the normal instruction sequence.
Example of Conditional Branching Using the Zero Flag
Consider MVI A,00H followed by ORA A and JZ TARGET. ORA A produces a zero result and sets the zero flag. JZ therefore loads TARGET into the program counter, and execution continues from that address instead of the next sequential instruction. This demonstrates decision-making based on a calculated result.
Role of Branching in Loops and Program Organization
Conditional jumps allow repeated execution of instructions until a counter, comparison or calculation produces the required condition. CALL and RET divide larger programs into reusable routines, reducing repeated instruction sequences. Branch instructions use the PC for program sequencing and the stack for return-address preservation, connecting decision-making with the processor's register and memory organization.
Misconceptions About Jump, Call and Return Instructions
'JMP checks the zero flag before branching' is incorrect because JMP is unconditional. 'CALL only changes the program counter' overlooks its saving of the return address on the stack. 'RET always jumps to address 0000H' is incorrect because it retrieves the previously saved return address through the stack pointer.
Branch Conditions and Program-Counter Tracing
Identify unconditional and conditional branch instructions and determine the flag condition required by each. Trace PC changes when a jump is taken or skipped, and explain how CALL and RET use stack memory. Examination questions may require evaluating JZ, JNZ, JC, JNC, JM or parity-based branches after a given arithmetic or logical operation.
Branching and Subroutine-Control Terminology
- JMP - Performs an unconditional jump.
- JZ - Jumps when zero flag is set.
- JNZ - Jumps when zero flag is clear.
- CALL - Transfers execution to a subroutine.
- RET - Restores the saved return address.
- Branch - Changes sequential program execution.
📝 All Branch Group of SAP-III Computer MCQs
Q1. A program needs to skip the next instruction if the accumulator is zero. Which SAP‑III branch instruction should be used?
📖 Explanation: The BZ (Branch if Zero) instruction tests the zero flag set by the accumulator; when the flag is true, execution jumps to the target address, effectively skipping the following instruction. BNZ branches when the accumulator is not zero, BC and BS test other conditions, so they would not produce the desired skip. Using BZ aligns with the required behavior and demonstrates proper use of the branch group in a simple scenario.
Q2. What is the primary purpose of the branch group in the SAP‑III instruction set?
📖 Explanation: The branch group contains instructions that alter program flow, such as unconditional and conditional jumps, based on condition‑code flags. Arithmetic operations belong to the arithmetic‑logic group, while data manipulation is handled by move or register groups. Changing the flow allows loops, conditionals, and sub‑routines, which is essential for any non‑trivial program. The other options describe unrelated functions, making C the correct choice.
Q3. Which 8‑bit microprocessor is directly descended from the SAP‑III architecture?
📖 Explanation: The Intel 8080 was designed as a commercial implementation of the SAP‑III concepts, preserving its instruction set including the branch group. The 8085 is an enhanced version of the 8080, while the 8086 is a 16‑bit processor with a different architecture, and the 8051 is a microcontroller with its own instruction set. Therefore, the 8080 is the direct descendant, reflecting the lineage from SAP‑III.
Q4. If a program uses the instruction BR 0x3C, what will be the next address executed?
📖 Explanation: BR is an unconditional branch that loads the program counter with the supplied address. Providing 0x3C means the CPU will fetch the next instruction from address 0x3C. Addresses 0x3B and 0x3D would be reached only by a relative branch offset, and 0x00 is the reset vector. Hence the correct next address is exactly 0x3C, illustrating direct addressing in the branch group.
Q5. Why does the SAP‑III BZ instruction depend on the zero flag rather than directly examining the accumulator?
📖 Explanation: The zero flag is a dedicated status bit that reflects whether the most recent arithmetic result was zero. Branch hardware can test this single bit quickly, avoiding the need to read the full accumulator value, which would be slower and more complex. Option A is false; the accumulator remains readable. Option C describes the flag’s origin, not the reason for using it. Option D is unrelated, making B the accurate explanation.
Q6. A program contains the sequence: LOAD A, SUB B, BZ LABEL1, ADD C, LABEL1: NOP. If A = 5 and B = 5, which instruction executes immediately after the BZ?
📖 Explanation: When A and B are equal, SUB B yields zero, setting the zero flag. The subsequent BZ tests this flag and, because it is true, branches to LABEL1. LABEL1 is placed after the ADD C instruction, so execution jumps directly to the NOP at LABEL1, skipping ADD C. Therefore, NOP runs next. The other options are either the instruction that gets skipped (ADD C) or earlier instructions that have already executed.
Q7. How does the branch group affect the overall execution time of a SAP‑III program compared to a program that uses only arithmetic instructions?
📖 Explanation: Branch instructions introduce control flow changes that may cause the CPU to fetch from non‑sequential addresses, potentially incurring additional fetch cycles. However, they also enable loops and conditionals, which can reduce the total number of executed instructions, thereby decreasing overall time. Thus the effect varies with program structure. The other statements are absolute claims that ignore these nuances, making C the correct balanced answer.
Q8. A relative branch instruction uses an 8‑bit signed offset. If the current PC is 0x20 and the instruction BRR -10 is executed, what address will be loaded into the PC?
📖 Explanation: BRR adds the signed offset to the address of the following instruction. After fetching BRR, the PC points to the next byte, which is 0x21. Adding -10 (0xF6 in two’s complement) gives 0x21 + (-10) = 0x17. Since the offset is applied to the next instruction address, the effective target becomes 0x17, which is represented as 0x1A in hexadecimal notation after rounding to the nearest byte boundary. Therefore, option C is correct.
Q9. Why does SAP‑III not include an indirect branch instruction like some later processors?
📖 Explanation: SAP‑III was designed for educational and low‑cost hardware, so its control unit was kept simple. Implementing an indirect branch requires additional address‑generation logic and registers, increasing transistor count and price. While indirect branches can be useful, they are not essential for basic programming, and the designers chose to omit them to maintain a straightforward architecture. The other options are either inaccurate or irrelevant.
Q10. Given the fragment: LOOP: LD A,0x10; SUB B; BZ END; BR LOOP; END: NOP. What high‑level construct does this sequence implement?
📖 Explanation: The code loads a value, tests a condition, and repeats the sequence until the zero flag becomes true, at which point it exits to END. This pattern matches a while‑loop where the body executes repeatedly while a condition is false. An if‑else would execute only once, a function call would involve a return address, and array indexing requires address calculation, none of which are present here.
Q11. When debugging a SAP‑III program, a student notices that the BZ instruction never branches, even though the accumulator contains zero. Which likely cause should be investigated first?
📖 Explanation: The BZ instruction checks the zero flag, not the accumulator directly. If a subsequent instruction (perhaps an unnoticed arithmetic operation) clears the flag before the branch is evaluated, the BZ will not take the jump despite the accumulator being zero. Checking the flag status is the first step. Options B and D involve hardware failures, which are less common, and option C contradicts the premise that the accumulator is zero.
Q12. How does the branch instruction BZ differ from the unconditional branch BR in terms of processor state changes?
📖 Explanation: BZ is a conditional branch; it examines the zero flag and only updates the program counter when the condition is true. BR is unconditional and always loads the PC with the target address regardless of any flags. Neither instruction directly modifies the accumulator or memory, so options A and C are incorrect, and they are not identical, making B the correct distinction.
Q13. A programmer wants to implement a subroutine call in SAP‑III using only branch instructions and the stack pointer. Which sequence correctly saves the return address and jumps to the subroutine?
📖 Explanation: The typical call sequence first pushes the current PC (return address) onto the stack, then performs an unconditional branch to the subroutine label. This ensures that when the subroutine finishes, a POP can retrieve the saved return address. Option B follows this order. Option A branches before saving, losing the return address; options C and D do not involve a proper call mechanism.
Q14. What role does the flag register play in the operation of the branch group in SAP‑III?
📖 Explanation: The flag register includes bits such as zero, carry, and sign, which reflect the outcome of the most recent arithmetic or logical operation. Branch instructions like BZ, BNZ, BC, and BS read these bits to decide whether to alter program flow. It does not store addresses, operand values, or clock control, making C the accurate description of its purpose.
Q15. A program uses the instruction BRR +5 at address 0x40. After execution, which address will the PC point to?
📖 Explanation: When BRR is fetched at 0x40, the PC increments to the next byte, 0x41, before adding the signed offset. Adding +5 yields 0x41 + 5 = 0x46. Therefore the PC will load 0x46, making option C correct. The other options result from miscalculating the offset or ignoring the post‑fetch increment.
Q16. Explain why the branch group must be carefully coordinated with interrupt handling in SAP‑III designs.
📖 Explanation: When an interrupt occurs, the processor saves the current PC and jumps to a fixed interrupt vector, which typically begins with a branch instruction directing execution to the appropriate service routine. If the branch group is not correctly designed, the vector may not transfer control properly, causing the system to fail to service the interrupt. Interrupts do not disable branches, nor do branches overwrite flags, and latency is indeed influenced by how quickly the branch can redirect execution.
Q17. A programmer replaces a conditional BZ with an unconditional BR to simplify code, but the program now enters an infinite loop. Which principle explains this failure?
📖 Explanation: The BZ instruction only branches when the zero flag is set, allowing the loop to terminate when the condition becomes false. By swapping it for BR, the program jumps regardless of the flag, so the loop condition never breaks, leading to an infinite loop. The other statements are false: BR does not affect flags, and conditional branches do not adjust offsets automatically.
Q18. Compare the branch architecture of SAP‑III with that of the Intel 8086. Which statement best captures a key difference?
📖 Explanation: SAP‑III’s branch instructions operate within an 8‑bit address space, limiting jumps to 256 locations and omitting segment registers. The 8086, by contrast, uses segment:offset addressing, allowing far jumps across a much larger memory space. Both processors support relative and absolute branches, and neither has indirect branches in SAP‑III. Neither architecture modifies flags via branch instructions, so option B correctly highlights the address‑space limitation.
Q19. A piece of code contains: BZ END; SUB A; BR LOOP; END: NOP. The programmer wants the same behavior but without using BZ. Which alternative sequence achieves this?
📖 Explanation: By inverting the condition, BNZ (Branch if Not Zero) will jump to END when the zero flag is not set, which is the opposite of BZ. To preserve the original flow, the rest of the sequence remains unchanged. Option A implements this inversion correctly. The other options either remove the conditional test altogether or alter the arithmetic operation, breaking the intended logic.
Q20. In a SAP‑III program, a branch instruction is causing the CPU to fetch from an unexpected address, leading to a crash. Which debugging step is most likely to locate the fault?
📖 Explanation: Branch instructions rely on correct opcode bits to determine the target address mode and offset. A corrupted opcode can cause the PC to load an unintended address, producing a crash. While flag status and stack pointer are important for other issues, the immediate symptom of an unexpected jump points to a possible opcode encoding error, making option A the most direct diagnostic step.