in CO and Architecture retagged by
1,574 views
1 vote
1 vote

What should I assume as the size of HALT instruction ? HALT instruction comes under which type of instruction

in CO and Architecture retagged by
by
1.6k views

4 Comments

@deepanshu I don't have any reference for my answer, I have just read this stuff so I know it.
Posting it as answer would not be appropriate.
0
0
I1: 3000
I2: 3008
I3: 3012
I4: 3016
I5: 3024
I6: 3028
I7: 3030

So when interrupt occurs at I6, program counter contains 3030 right? so return address should be 3030 correct?
0
0
yes i too think 3030 is correct!
0
0

1 Answer

3 votes
3 votes
Best answer

I1: 3000 - 3007 // since it is a memory transfer op.

I2: 3008 - 3011// it is an ALU oper.
I3: 3012 - 3015 // it is also an ALU por.
I4: 3016 - 3023 // memory transfer opr.
I5: 3024 - 3027 // ALU oper.
I6: 3028 - 3029 // branch operation
I7: 3030-3033 // ALU Opr.

Halt is an un-conditional branch to the same instruction, i.e, It is a branch instruction.

further more irrespective of whether interrupt occurs during execution of instruction or after execution of instruction next address instruction will be saved to the stack:

So 3030 will be stored in the stack.

reference:  https://gateoverflow.in/1058/gate2004-63

selected by

16 Comments

bro just little info of how u get 3000-3008 is good just explain when 8  when 4
0
0
How PC will have address of the same instruction?? It always stores the address of the next instruction so won't it be equal to 3030 during execution of I6!!
0
0
No. it's different in the case of Halt instruction.
0
0

Do you have any reference? @Ashwani Yadav I haven't found in any standard book so far. Can you share any standard material which claim Halt is unconditional branch statement to itself? 

0
0

@2019_Aspirant No brother i'have just remembered it after seeing multiple questions over it and all are solved in the same way as told above.

0
0

pls refer this link https://gateoverflow.in/1058/gate2004-63

Here it is said that the starting address of the next instruction will be loaded into the PC. So answer should be 3030, isnt it?

1
1
0
0

@Somoshree Datta 5 I am still confused after reading lots of stuff again!

If an interrupt occurs then during the fetch cycle the program counter is incremented (3030) and then during execution the program counter again takes the address of the halt instruction (3028) and Interrupt will be processed after the execution of halt and at that point of time the PC will have the value 3028 and is pushed into the stack.

The references saysa;

If an interrupt (including NMI) is used to resume execution after a HLT instruction, the saved instruction pointer (CS:EIP) points to the instruction following the HLT instruction.

what if reset is used to exit from halted state?

at the same time I have another doubt too! if the address of the halt state is saved into the stack when interrupt will again push the stack address into the PC the system will again enter into the halt state ! and so there is no sense of pushing the address of the halt instruction into the stack and address of the next instruction should be pushed!

 

0
0

@Somoshree Datta 5 and it is also not mention that the interrupt is used to get the system out of halted state! what if it is some other interrupt?

0
0

What i knew about halt instruction is that it freezes the value of Program Counter. Since Program Counter is not getting updated and keeps its value as its is, fetching of any instruction is not possible.

Now since PC gets updated during the fetch phase, so at the end of the fetch phase of HALT instruction, PC will get updated to 3030. Thereafter an external interrupt needs to be fired to resume its execution. So it will resume its execution from the value stored in PC, i.e. 3030.

So I guess the answer should always be 3030 irrespective of which interrupt resumes the execution.

https://en.wikipedia.org/wiki/HLT_(x86_instruction)

 

0
0

halt instruction is that it freezes the value of Program Counter

Yes It do so ! by again setting the PC to 3028(here) and again during fetch of Halt it will become 3030 but after execution phase it will again become 3028.
Thats how the PC freezes! @Somoshree Datta 5

0
0

yes i too think 3030 is correct!

refer https://gateoverflow.in/1058/gate2004-63

0
0

should I change the answer then? @Gate Fever  @Somoshree Datta 5 

0
0
yes,change it
0
0

@Gate Fever Correct now?

0
0
yes
0
0

Related questions