What causes the different instruction offset between gdb/linux and debug/dos?

In summary, an instruction offset in assembly language is a numerical value that represents the distance between the current instruction and the target instruction. It is calculated by subtracting the address of the current instruction from the address of the target instruction and can be negative if the target instruction is located before the current instruction. An instruction offset is important in assembly language as it allows the programmer to control the flow of execution. It differs from a jump or branch instruction in that it is relative to the current instruction and specifies the location of the next instruction to be executed, while a jump or branch instruction specifies the exact address of the next instruction and is absolute.
  • #1
dduardo
Staff Emeritus
1,905
3
I notice with gdb/linux each instruction is offset by 5 while debug/dos each instruction is offset by 3. What is linux doing that dos isn't?
 
Computer science news on Phys.org
  • #2
Is it consistently 3 or 5? Do you know how the programs were compiled? Are they on the same machine?
 
  • #3
Yes, under dos it is always 3 and under linux it is always 5. I'm running the same two programs on different computers and assembling and linking them with different programs

dos/masm/ml/debug
linux/nasm/ld/gdb
 

1. What is an instruction offset in assembly language?

An instruction offset in assembly language is a numerical value that represents the distance between the current instruction and the target instruction. It is used to determine the location of the next instruction to be executed.

2. How is an instruction offset calculated in assembly language?

An instruction offset is calculated by subtracting the address of the current instruction from the address of the target instruction. This value is then converted into a hexadecimal value and added as an offset to the instruction.

3. Why is an instruction offset important in assembly language?

An instruction offset is important in assembly language because it allows the programmer to control the flow of execution. By specifying the offset, the programmer can determine which instruction will be executed next.

4. Can an instruction offset be negative in assembly language?

Yes, an instruction offset can be negative in assembly language. This occurs when the target instruction is located before the current instruction in memory. In this case, the offset will be subtracted from the current instruction's address to determine the location of the target instruction.

5. How does an instruction offset differ from a jump or branch instruction?

An instruction offset is a value that is added to the current instruction's address to determine the location of the next instruction to be executed. A jump or branch instruction, on the other hand, specifies the exact address of the next instruction to be executed. Additionally, an instruction offset is relative to the current instruction, while a jump or branch instruction is absolute.

Similar threads

  • Computing and Technology
Replies
18
Views
1K
  • Computing and Technology
Replies
3
Views
1K
Replies
3
Views
2K
  • Quantum Interpretations and Foundations
2
Replies
42
Views
5K
  • Computing and Technology
Replies
12
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
Replies
10
Views
2K
  • Computing and Technology
Replies
3
Views
764
  • Computing and Technology
Replies
8
Views
2K
  • Programming and Computer Science
Replies
13
Views
2K
Back
Top