开发者

Calculate size in Hex Bytes

开发者 https://www.devze.com 2023-04-07 03:25 出处:网络
what is the proper way to calculate the size in hex bytes of a code segment. I am given: IP = 0848开发者_StackOverflowCS = 1488DS = 1808SS = 1C80ES = 1F88

what is the proper way to calculate the size in hex bytes of a code segment. I am given:

IP = 0848  开发者_StackOverflow  CS = 1488    DS = 1808   SS = 1C80    ES = 1F88

The practice exercise I am working on asks what is the size (in hex bytes) of the code segment and gives these choices:

A. 3800    B. 1488    C. 0830    D. 0380    E. none of the above

The correct answer is A. 3800, but I haven't a clue as to how to calculate this.


How to calculate the length:

  • Note CS. Find the segment register that's nearest to it, but greater.
  • Take the difference between the two, and multiply by 0x10 (read: tack on a 0).

In your example, DS is closest. 1808 - 1488 == 380. And 380 x 10 = 3800.

BTW, this only works on the 8086 and other, similarly boneheaded CPUs, and in real mode on x86. In protected mode on x86 (which is to say, unless you're writing a boot sector or a simple DOS program), the value of the segment register has very little to do with the size of the segment, and thus the stuff above simply doesn't apply.

0

精彩评论

暂无评论...
验证码 换一张
取 消