|
本帖最后由 不点 于 2017-8-27 14:11 编辑
好像程序是错的,yaya。
- subl %es:(%di), %eax
- sbbl %es:4(%di), %edx /* EDX:EAX=new length */
- jb 5f /* start_address is below the base */
- + /* now EDX=0 */ 此处怎能断定 EDX=0 ? 在 4G 以上的空间,它可能是大于 0 的。用的是 64 位地址,不是 32 位。EDX 是 高32位,EAX 是低32位
- + testl %eax, %eax /* EAX also be zero? ZF holds it! */
- + jne 7f
- + /* Change memory address type from 1 (usable) to 2 (reserved). Note
- + * that original value is long integer of 1 (all higher 3 bytes = 0).
- + * So only the lowest byte needs to be incremented. */
- + incb %es:16(%di) /* memory address type */
- + jmp 5f
- +7:
- subl %es:8(%di), %eax
- sbbl %es:12(%di), %edx /* EDX:EAX=difference */
- jnb 5f /* new length is too big */
复制代码
就算 mdyblog 测试通过了,有问题的代码也是不能用的。
补充:感觉 yaya 的程序确实比我的简化了不少。赞!上述毛病稍微改进一下,不知道行不行:
- subl %es:(%di), %eax
- sbbl %es:4(%di), %edx /* EDX:EAX=new length */
- jb 5f /* start_address is below the base */
- + ja 7f <------------------- 就增加这一句
- + /* now EDX=0 */
- + testl %eax, %eax /* EAX also be zero? ZF holds it! */
- + jne 7f
- + /* Change memory address type from 1 (usable) to 2 (reserved). Note
- + * that original value is long integer of 1 (all higher 3 bytes = 0).
- + * So only the lowest byte needs to be incremented. */
- + incb %es:16(%di) /* memory address type */
- + jmp 5f
- +7:
- subl %es:8(%di), %eax
- sbbl %es:12(%di), %edx /* EDX:EAX=difference */
- jnb 5f /* new length is too big */
复制代码
我的那个程序可能比较罗嗦、复杂,但逻辑的正确性是没问题的(我只是检查了几遍,没发现问题;也不敢肯定真的没问题)。要是上述这个代码在逻辑上没问题的话,那可是非常漂亮的了。 |
|