opposed to, say, "movb $1, %eax"
This instruction is invalid. You can't use eax with the movb instruction.
You would instead use an 8-bit register, or write the full register with a value that has the value you want in the low byte(s) you care about. For example:
movb $1, %al # AL = 1, merged with existing 3/7 bytes of previous EAX/RAX
movl $1, %eax # AL = 1, AX = 1, EAX = 1, RAX = 1
but isn't %eax a register that's
equivalent to the size of the system's
wordsize?
No. EAX will always be a 32-bit value, regardless of what mode you're in.
You are confusing C variable sizes with register sizes. C variable sizes may change depending on your system and compiler.
Assembly is simpler than C. In GAS AT&T assembly, instructions are suffixed with the letters "b", "s", "w", "l", "q" or "t" to determine what size operand is being manipulated. (Or a register operand can imply a size, like mov $1, %eax
implies movl
, unlike with mov $1, (%rdi)
which is ambiguous.
b
= byte (8 bit)
s
= single (32-bit floating point) used only for x87 instructions like flds (mem)
w
= word (16 bit)
l
= long (32 bit doubleword integer), or x87 64-bit floating point
q
= quad-word (64 bit)
t
= ten bytes (80-bit floating point)
These sizes are constant. They will never be changed. al is always 8-bits and eax is always 32-bits.
A "word" is always 16 bits in x86 terminology, and in modern x86 is unrelated to the concept of CPU or machine word size; x86 isn't a word-oriented architecture.