1
\$\begingroup\$

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 ?

\$\endgroup\$
1
\$\begingroup\$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.