Deprecated: Implicit conversion from float-string "1528607881.753" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1528607881.753" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1528607881.753" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1528607881.753" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1528607881.753" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1528806163.322" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1528806163.322" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1528806163.322" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1528806163.322" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1528806163.322" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1528812046.083" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1528812046.083" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1528812046.083" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1528812046.083" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1528812046.083" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1528814936.381" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1528814936.381" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1528814936.381" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1528814936.381" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1528814936.381" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Branch Instruction / GATE Overflow for GATE CSE
500 views

1 Answer

Best answer
1 votes
1 votes

Offset in branch instruction means the amount of displacement which has to be done in memory location from the current location of the instruction pointer. Consider an example:

100 MOV 104, C
101 MOV 103, B
102 CMP A, B
103 JNZ 106
104 MOV 103, C
105 MOV 107, D
106 MOV 109, BAX
107 MOV 110, EAX

Now as you can see JNZ (Jump Not Zero) will jump to address 106 in case the result of above instruction (CMP) is not zero. After the instruction JNZ is being fetched, and before it is executed, the Instruction Pointer (IP) is incremented to 104. The compiler (mostly) does not generate machine code with absolute addresses, since the code is liable to be relocated to any address. Instead, it would generate JNZ with an offset address. Offset is amount if displacement to be done from the address which is currently in IP when instruction is being executed. Since there is 104 in IP, so offset in JNZ would be +2 i.e will take it to 106 as desired. 

Offset in Virtual address can mean two things since it is composed of [Page Offset | Byte within a page i.e byte offset]. Memory has a page table which contains all pages. Page offset is a index in this table. A page contains several bytes. These are Byte #0, Byte #1.. etc. Byte offset is a index to one of the bytes.

So, basically offset is an displacement to be done. In case of branch instruction, offset is amount of displacement to be done in memory address, while in case of virtual address, it is amount of displacement to be done in page table (for page offset)

selected by

Related questions


Deprecated: Implicit conversion from float-string "1543725441.969" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1543725441.969" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1543725441.969" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1543725441.969" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1541577877.917" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1541577877.917" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1541577877.917" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1541577877.917" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
514
views
1 answers
1 votes
Na462 asked Dec 2, 2018
514 views
Assume that the base register contains 32856. The program counter is currently having a value of 25687 memory location. What is the branch address if the address field of...
563
views
1 answers
0 votes
3.1k
views
3 answers
5 votes
Xylene asked Jun 6, 2017
3,092 views
I have a doubt regarding the implementation of BSA instruction. I read that BSA instruction can be implemented as :-T4:- m[AR] < PC; AR< AR+1T5:- PC< AR; SC< 0He...
1.1k
views
1 answers
0 votes
khushtak asked Oct 19, 2015
1,144 views
Among the branch instructions 30% conditional and 70% of them does not satisfy the condition ( branch not taken). If there is no stall due to them. What is average instru...
Total PHP MySQL Other RAM
Time (ms) % Time (ms) % File count Time (ms) % Query count Time (ms) % Amount %
Setup 4.6 3% 3.2 2% 72 1.7 1% 2 0.0 0% 569k 50%
Control 20.5 16% 1.5 1% 5 19.3 15% 12 0.0 0% 188k 16%
View 1.7 1% 1.7 1% 12 0.0 0% 0 0.0 0% 97k 8%
Theme 90.0 74% 5.4 4% 15 84.7 69% 3 0.0 0% 264k 23%
Stats 4.7 3% 0.1 0% 0 4.7 3% 1 0.0 0% 0k 0%
Total 121.5 100% 11.9 9% 104 110.3 90% 18 0.0 0% 1121k 100%