World's most popular travel blog for travel bloggers.

[Solved]: use of unconditional transfer of control instruction

, , No Comments
Problem Detail: 

I did not understand why unconditional transfer of control instruction is used in cpu.So if we already know we have to jump to an instruction and skip some instruction irrespective of any condition then why do we not avoid writing those instruction as they will not be executed and replace them with instruction that will be executed after jump instruction

Asked By : WSS

Answered By : David Richerby

To implement if-then-else, when you get to the end of the "then" branch, you need to jump unconditionally past the "else" branch. The breaks in a C switch statement are also unconditional jumps.

You could probably also implement tail recursion by replacing "call" instructions with jumps.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/19672

0 comments:

Post a Comment

Let us know your responses and feedback