Intel 64, rsi and rdi registers

These registers were originally implicitly used in repetitive instructions, for instance MOVSB, which copy a byte from DS:SI (DataSegment:SourceIndex) to ES:DI(ExtraSegment:DestinationIndex), at the time of the 16-bits computers with segmented memory in real mode. And also as index registers in 16-bit addressing modes like [bx + si].

Right now, these registers are for example used to transmit the first two (integer) function parameters in UNIX’s x86_64 ABI, far from their original purpose. (See also What are the calling conventions for UNIX & Linux system calls on i386 and x86-64)

The names of the new rXX 64-bit registers clearly show that old register names are only here for familiarity and retro-compatibility. (But note that some instructions do still only work with some registers, for example rep movsb only works as a memcpy(rdi, rsi, rcx), and is in fact why RDI and RSI were chosen as the first 2 arg-passing registers in the x86-64 System V ABI: some functions call memset or memcpy with their first 1 or 2 args, so inlining rep movsb/d is cheaper in that case.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)