Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program counter (PC) points to the memory address of the next instruction(s)

ID: 3788725 • Letter: T

Question

The program counter (PC) points to the memory address of the next instruction(s) that the processor load from the memory How does the PC value change after fetching a 32-bit instruction? How does PC change after executing a 16-bit instruction? An arithmetic and logic unit (ALU) performs integer and logic operations. Implement the logic of a simple ALU that performs 2-bit addition and subtraction. Assume that the operands are A _1 A _0 and B _1 B _0, and the output is C _1 C _0. The operation code 0 has only one bit, which selects addition or subtraction.

Explanation / Answer

The 1st question is answered as below:

16 bit instruction is stored in 2 Bytes and 32 bit instruction is stored in 4 bytes.

When the program is running sequentially, the program counter(PC) gets incremented by 2 bytes in case of 16 bit instruction and 4 bytes in case of 32 bit instruction.

So for a 16 bit, it will be multiples of 2 and for 32 bit it will be multiples of 4.

Generally, in new machines if it is a 16-bit machine, then there is 16bit instruction running on it with a 2byte program counter, When program is written specifically for that machine. the program counter is incremented by 1.

PC <- PC +1

Similarly if it is 32 bit machine, the program specifically written for this machine, will have each instruction 32bit,

and the program counter incrementing will be shown as

PC <-PC+1 if the program counter is also 32 bit (1 word) long.

If the instruction is 32bit and the machine is 16bit, then the address has to be incremented by 2.

Depending on whether the instruction has any operands, the program counter gets incremented. So the spaces occupied by operands are taken into consideration while incrementing the program counter.

Control Innstructions change the contents of the program controller differently.

1. If there is a Jump instruction, then it will load the given address in Program Counter for the next instruction.

2. If there is a branch instruction, it will load the new address in Program Counter only if the condition is True.

In hardware, it is faster to load the next address and only if it is a control instruction then overwrite it.