Please explain the x86 assembly language instruction lds si,[bp+0] in the code below

Viewed 126

The first 7 lines of code in a FAT16 boot sector are shown below. The lds instruction is on the 7th line. I read the Intel reference about lds. My interpretation is: the location of the data byte at [bp+0] will be used to set the values of the ds and si registers. There just isn't enough information in the code below to do that. (Note ds=0 and si=0x80 in the MBR code that runs just before the code shown below is started.)

QUESTION: Please tell me what are the values of ds and si after the 7th line of code runs.

xor cx,cx
mov ss,cx
mov sp,0x7bfc
push ss
pop es  
mov bp,0x78
lds si,[bp+0x0]
1 Answers

xor sets cx to zero. Then ss and sp are initialised to the far pointer 0:7BFCh. (It is important to set sp in the very next instruction after setting ss.) Then es is set to equal ss, that is zero. Then bp is set to 78h. 78h is 4 times 1Eh. That means the lds si loads a far pointer at dword [0:78h] into the ds:si register pair. 0:78h is where the interrupt vector for interrupt 1Eh lives. This happens to be used as a pointer to a DPT.

Related