x86_64 ASM - 指令的最大字节数? [英] x86_64 ASM - maximum bytes for an instruction?

查看:37
本文介绍了x86_64 ASM - 指令的最大字节数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整指令在 x64 汇编代码中需要的最大字节数是多少?

What is the maximum number of bytes a complete instruction would require in x64 asm code?

我想像跳转到地址之类的东西可能最多占用 9 个字节:FF 00 00 00 00 11 12 3F 1F 但我不知道这是否是 x64 指令的最大字节数可以使用

Something like a jump to address might occupy up to 9 bytes I suppose: FF 00 00 00 00 11 12 3F 1F but I don't know if that's the maximum number of bytes a x64 instruction can use

推荐答案

x86 指令集(16、32 或 64 位,所有变体/模式)保证/要求指令最多为 15 个字节.除此之外的任何事情都会给出无效的操作码".如果不使用冗余前缀(例如,多个 0x66 或 0x67 前缀),您就无法实现这一点.

The x86 instruction set (16, 32 or 64 bit, all variants/modes) guarantees / requires that instructions are at most 15 bytes. Anything beyond that will give an "invalid opcode". You can't achieve that without using redundant prefixes (e.g. multiple 0x66 or 0x67 prefixes, for example).

实际将 64 位作为数据项的唯一指令是要注册的加载常量(Intel 语法:mov reg, 12345678ABCDEF00h,at&t 语法:movabs $12345678ABCDEF00,%reg) - 所以如果你想向前/向后跳转超过 31 位,它将目标位置移动到寄存器中,然后调用/跳转到寄存器.使用 32 位立即数和位移(在相对跳转和寻址模式下)在 64 位模式下的许多指令上节省了四个字节.

The only instruction that actually takes 64-bits as a data item is the load constant to register (Intel syntax: mov reg, 12345678ABCDEF00h, at&t syntax: movabs $12345678ABCDEF00, %reg) - so if you wanted to jump more than 31 bits forward/backward, it would be a move of the target location into a register, and then call/jump to the register. Using 32-bit immediates and displacements (in relative jumps and addressing modes) saves four bytes on many instructions in 64-bit mode.

这篇关于x86_64 ASM - 指令的最大字节数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆