Back in the 16-bit (8086) and 32-bit protected mode days, memory was often split into segments. If you needed to access data in a different segment, you had to update DS . LDS was an atomic, efficient way to switch your "view" to a new data area and get the pointer to a specific variable in one go. The Modern Reality: Flat Memory
Over the years, the x86 architecture has evolved, and new instructions have been added to the instruction set. However, the LDS instruction remains an essential part of the x86 architecture, particularly in legacy applications and operating systems.
; Load destination far pointer (ES:DI) from dst_ptr LES DI, [dst_ptr] ; DI = 0x0DEF, ES = 0x9ABC x86 lds
From a hardware perspective, LDS is a instruction in most x86 CPUs. That means it doesn't execute in a single cycle like MOV . Internally, the CPU breaks LDS into a series of µops:
When the CPU executes LDS , it performs a multi-step load operation: Back in the 16-bit (8086) and 32-bit protected
The LDS instruction was introduced in the 8086 processor as a way to load a data segment selector into the DS register. The instruction was used extensively in MS-DOS and early Windows applications to access data segments.
The LDS instruction is a relic of the era when managing memory segments was a daily hurdle for programmers. While it is obsolete for modern desktop development, understanding it is vital for: The Modern Reality: Flat Memory Over the years,
; Now perform a string move (e.g., MOVSB)
This article dissects the LDS instruction: what it does, how it works, why it was necessary, and why you almost never see it today.