- 论坛徽章:
- 0
|
本帖最后由 l4rmbr 于 2014-04-29 18:59 编辑
回复 3# stuman
LABEL_SEG_CODE32的值是? 运行出错信息是?
网上找到这么一段,你可以对照下,看你的情况跟这有什么不同:- The most common form of mixed-size instruction is the one used when writing a 32-bit OS: having done your setup in 16-bit mode, such as loading the kernel, you then have to boot it by switching into protected mode and jumping to the 32-bit kernel start address. In a fully 32-bit OS, this tends to be the only mixed-size instruction you need, since everything before it can be done in pure 16-bit code, and everything after it can be pure 32-bit.
- This jump must specify a 48-bit far address, since the target segment is a 32-bit one. However, it must be assembled in a 16-bit segment, so just coding, for example,
- jmp 0x1234:0x56789ABC ; wrong!
- will not work, since the offset part of the address will be truncated to 0x9ABC and the jump will be an ordinary 16-bit far one.
- The Linux kernel setup code gets round the inability of as86 to generate the required instruction by coding it manually, using DB instructions. NASM can go one better than that, by actually generating the right instruction itself. Here's how to do it right:
- jmp dword 0x1234:0x56789ABC ; right
- The DWORD prefix (strictly speaking, it should come after the colon, since it is declaring the offset field to be a doubleword; but NASM will accept either form, since both are unambiguous) forces the offset part to be treated as far, in the assumption that you are deliberately writing a jump from a 16-bit segment to a 32-bit one.
复制代码 |
|