曲径通幽论坛

标题: header.S 中的 start_of_setup 跳转用法 [打印本页]

作者: beyes    时间: 2010-12-24 20:30
标题: header.S 中的 start_of_setup 跳转用法
在 arch/x86/boot/header.S 的 _start 开始处有这么一个用法:
_start:
                 # Explicitly enter this as bytes, or the assembler
                 # tries to generate a 3-byte jump here, which causes
                 # everything else to push off to the wrong offset.
                 .byte   0xeb            # short (2-byte) jump
                 .byte   start_of_setup-1f
1:
....
start_of_setup:
...
实际上,这两个字节构成了一个跳转。这是一种硬编码用法。关于硬编码参考:http://www.groad.net/bbs/read.php?tid-3000.html

这里需要注意的是,在  .byte   start_of_setup-1f 中,1f 不是表示十六进制 0x1f。 1 这里是一个标号,f 表示 fordward ,在前面的;如果是在其后,则是 b (backword)。所以,这条语句算出了 start_of_setup 标号和 1 标号之间的偏移(字节数)。组合起来看,实际上就是跳转到了 start_of_setup 标号处。
作者: ofite    时间: 2012-4-12 15:32
我的妈呀,爱死你了








礼品




欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2