# What happens If the interrupt occurs during the execution of HALT instruction?

Consider the following program segment on a hypothetical processor .

I have this question in my course CS201. Suppose this processor has 32 bits Load/Store operations, ALU operations is 16 bits and Branch instruction is 16 bits. Program has been loaded in the memory with a starting address of 3000 (which is in decimal) .

Assuming Byte addressing, If the interrupt occurred during the execution of halt instruction, then the return address pushed onto the stack will be ?

My Try :

http://x86.renejeschke.de/html/file_module_x86_id_134.html

According to this link, The return address saved on the stack must be of instruction after the HALT instruction, which gives me the saved address as

3000 + 4 + 2 + 2 + 2 + 4 + 2 + 2 = 3018

Hence, Stack saves 3018 .

But, I don't have the answer with me, so I can't confirm it.

Am I going Right ?

The return address saved on the stack must be of instruction after the HALT instruction

Of course. Otherwise the CPU would go into a HALT instruction again after returning from the interrupt.

Suppose this processor has 32 bits Load/Store operations, ALU operations is 16 bits and Branch instruction is 16 bits.

Some information is missing: Either the information, that "HALT" is a "branch" instruction on the given CPU (on modern automotive CPUs "HALT" is a special instruction class, not "branch") or the information how long "HALT" is.

3000 + 4 + 2 + 2 + 2 + 4 + 2 + 2 = 3018

Assuming "HALT" is also 16 bits long: Yes, it's correct.

• If interrupts are disabled by software, nothing will happen within HALT instruction. Dec 31 '16 at 8:29
• Thanks for the answer !! Just one doubt "Interrupt comes during the halt instruction" and "Interrupt comes after halt instruction", both are same ? I think so, because interrupts are always processed after completion of instruction. Am I right here ? Dec 31 '16 at 8:30
• Yes, @Garrick, you are right. An interrupt is processed only after current instrucion has completed Dec 31 '16 at 10:53
• Depending on the implementation, HALT may not be so benign... en.wikipedia.org/wiki/Halt_and_Catch_Fire#Intel_x86 Dec 31 '16 at 19:18