It looks like the suggested way to set a register to 0 is:
xor %eax, %eax # like mov $0, %eax but sets FLAGS
What is the corresponding preferred way to set a register to 1? A few that I've thought of are:
mov $1, %eax
or $1, %eax # as discussed in comments, doesn't work for most EAX inputs
Additionally, is there a way in gdb or elsewhere to see quickly see the byte size of an instruction with all its operands? Unless my counting is wrong (and I'm pretty bad at counting in hex) it looks like the size is as follows from gdb:
>>> x/7i $rip
=> 0x400078 <_start>: xor %eax,%eax # 2 bytes
0x40007a <_start+2>: xor %rax,%rax # 3 bytes
0x40007d <_start+5>: or $0x1,%rax # 4 bytes
0x400081 <_start+9>: or $0x1,%eax # 3 bytes
0x400084 <_start+12>: mov $0x1,%eax # 5 bytes
0x400089 <_start+17>: mov $0x1,%rax # 7 bytes
0x400090 <_start+24>: