1

Consider the following program segment on a hypothetical processor . enter image description here


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 :

I referred this link

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 ?

Garner
  • 113
  • 6

1 Answers1

1

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.

Martin Rosenau
  • 1,166
  • 5
  • 7
  • 1
    If interrupts are disabled by software, nothing will happen within HALT instruction. – Anonymous Dec 31 '16 at 08: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 ? – Garner Dec 31 '16 at 08:30
  • 1
    Yes, @Garrick, you are right. An interrupt is processed only after current instrucion has completed – Claudio Avi Chami Dec 31 '16 at 10:53
  • Depending on the implementation, HALT may not be so benign... https://en.wikipedia.org/wiki/Halt_and_Catch_Fire#Intel_x86 – Bruce Abbott Dec 31 '16 at 19:18