News for hackers. Stuff that matters.
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by kccqzy on Saturday June 10, 2017 @06:22PM (#14529519)
Regarding 5, no, it's five bytes (b8 01 00 00 00) for movl $1,%eax. If you actually have a 64-bit immediate, just the immediate itself would be 8 bytes, and the actual instruction is 10 bytes.
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by besselheim on Saturday June 10, 2017 @08:28PM (#14529971)
MOV RAX, 1 is seven bytes: 48 C7 C0 01 00 00 00
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by pcwalton on Saturday June 10, 2017 @08:47PM (#14530041)
The parent has a good point actually, because "mov eax,1" automatically zero-extends in 64-bit mode.

It's still one byte longer than the equivalent AArch64 instruction, though.

Re:Intel fires warning shots at Microsoft, says x86 emulatio... by kccqzy on Saturday June 10, 2017 @11:18PM (#14530431)
Fine. If you are really into getting the shortest instruction, try "xorl %eax,%eax" then "incl %eax" which is four bytes (31 c0 ff c0).
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by gsg on Sunday June 11, 2017 @12:35AM (#14530655)
push $1/pop %eax (6a 01 58) is shorter, but perhaps not the best idea.
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by nayuki on Sunday June 11, 2017 @12:16PM (#14532522)
Actually, there is no 32-bit pop instruction in x86-64 mode. Your code won't work.
Re:Intel fires warning shots at Microsoft, says x86 emulatio... by gsg on Sunday June 11, 2017 @01:24PM (#14532795)
You're right: it should be pushq $1/pop %rax (which is also three bytes, although there will be a prefix byte for registers r8 through r15).